From 5852566ff0084043c8efb9ad7c9ca77795448abd Mon Sep 17 00:00:00 2001 From: Hugo Date: Sat, 24 Nov 2018 11:40:56 +0200 Subject: [PATCH] Upgrade unit tests to use more useful asserts --- tests/test_config.py | 10 +++++----- tests/test_parser.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_config.py b/tests/test_config.py index b5af3aa..1c4a3d9 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -78,7 +78,7 @@ class SimpleConfigTestCase(unittest.TestCase): ' spaces: 2\n' ' indent-sequences: true\n' ' check-multi-line-strings: false\n') - self.assertEqual(c.rules['indentation']['indent-sequences'], True) + self.assertTrue(c.rules['indentation']['indent-sequences']) self.assertEqual(c.rules['indentation']['check-multi-line-strings'], False) @@ -87,7 +87,7 @@ class SimpleConfigTestCase(unittest.TestCase): ' spaces: 2\n' ' indent-sequences: yes\n' ' check-multi-line-strings: false\n') - self.assertEqual(c.rules['indentation']['indent-sequences'], True) + self.assertTrue(c.rules['indentation']['indent-sequences']) self.assertEqual(c.rules['indentation']['check-multi-line-strings'], False) @@ -115,8 +115,8 @@ class SimpleConfigTestCase(unittest.TestCase): class Rule(object): ID = 'fake' - self.assertEqual(config.validate_rule_conf(Rule, False), False) - self.assertEqual(config.validate_rule_conf(Rule, 'disable'), False) + self.assertFalse(config.validate_rule_conf(Rule, False)) + self.assertFalse(config.validate_rule_conf(Rule, 'disable')) self.assertEqual(config.validate_rule_conf(Rule, {}), {'level': 'error'}) @@ -194,7 +194,7 @@ class ExtendedConfigTestCase(unittest.TestCase): new.extend(old) self.assertEqual(sorted(new.rules.keys()), ['colons', 'hyphens']) - self.assertEqual(new.rules['colons'], False) + self.assertFalse(new.rules['colons']) self.assertEqual(new.rules['hyphens']['max-spaces-after'], 2) self.assertEqual(len(new.enabled_rules(None)), 1) diff --git a/tests/test_parser.py b/tests/test_parser.py index e40b9ac..22145a8 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -65,12 +65,12 @@ class ParserTestCase(unittest.TestCase): def test_token_or_comment_generator(self): e = list(token_or_comment_generator('')) self.assertEqual(len(e), 2) - self.assertEqual(e[0].prev, None) + self.assertIsNone(e[0].prev) self.assertIsInstance(e[0].curr, yaml.Token) self.assertIsInstance(e[0].next, yaml.Token) self.assertEqual(e[1].prev, e[0].curr) self.assertEqual(e[1].curr, e[0].next) - self.assertEqual(e[1].next, None) + self.assertIsNone(e[1].next) e = list(token_or_comment_generator('---\n' 'k: v\n'))