From 2e7b4f2027a1147ca28301e4f88adf8274b39a1f Mon Sep 17 00:00:00 2001 From: DUVAL Thomas Date: Thu, 9 Jun 2016 09:11:50 +0200 Subject: Update Keystone core to Mitaka. Change-Id: Ia10d6add16f4a9d25d1f42d420661c46332e69db --- .../keystone/tests/unit/test_hacking_checks.py | 42 +++++++++++++--------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'keystone-moon/keystone/tests/unit/test_hacking_checks.py') diff --git a/keystone-moon/keystone/tests/unit/test_hacking_checks.py b/keystone-moon/keystone/tests/unit/test_hacking_checks.py index 962f5f8a..e279cc7f 100644 --- a/keystone-moon/keystone/tests/unit/test_hacking_checks.py +++ b/keystone-moon/keystone/tests/unit/test_hacking_checks.py @@ -86,25 +86,44 @@ class TestAssertingNoneEquality(BaseStyleCheck): self.assert_has_errors(code, expected_errors=errors) -class TestCheckForDebugLoggingIssues(BaseStyleCheck): +class BaseLoggingCheck(BaseStyleCheck): def get_checker(self): return checks.CheckForLoggingIssues + def get_fixture(self): + return hacking_fixtures.HackingLogging() + + def assert_has_errors(self, code, expected_errors=None): + + # pull out the parts of the error that we'll match against + actual_errors = (e[:3] for e in self.run_check(code)) + # adjust line numbers to make the fixture data more readable. + import_lines = len(self.code_ex.shared_imports.split('\n')) - 1 + actual_errors = [(e[0] - import_lines, e[1], e[2]) + for e in actual_errors] + self.assertEqual(expected_errors or [], actual_errors) + + +class TestCheckForDebugLoggingIssues(BaseLoggingCheck): + def test_for_translations(self): fixture = self.code_ex.assert_no_translations_for_debug_logging - code = fixture['code'] + code = self.code_ex.shared_imports + fixture['code'] errors = fixture['expected_errors'] self.assert_has_errors(code, expected_errors=errors) -class TestCheckForNonDebugLoggingIssues(BaseStyleCheck): +class TestLoggingWithWarn(BaseLoggingCheck): - def get_checker(self): - return checks.CheckForLoggingIssues + def test(self): + data = self.code_ex.assert_not_using_deprecated_warn + code = self.code_ex.shared_imports + data['code'] + errors = data['expected_errors'] + self.assert_has_errors(code, expected_errors=errors) - def get_fixture(self): - return hacking_fixtures.HackingLogging() + +class TestCheckForNonDebugLoggingIssues(BaseLoggingCheck): def test_for_translations(self): for example in self.code_ex.examples: @@ -112,15 +131,6 @@ class TestCheckForNonDebugLoggingIssues(BaseStyleCheck): errors = example['expected_errors'] self.assert_has_errors(code, expected_errors=errors) - def assert_has_errors(self, code, expected_errors=None): - # pull out the parts of the error that we'll match against - actual_errors = (e[:3] for e in self.run_check(code)) - # adjust line numbers to make the fixure data more readable. - import_lines = len(self.code_ex.shared_imports.split('\n')) - 1 - actual_errors = [(e[0] - import_lines, e[1], e[2]) - for e in actual_errors] - self.assertEqual(expected_errors or [], actual_errors) - class TestDictConstructorWithSequenceCopy(BaseStyleCheck): -- cgit 1.2.3-korg