Upgrade unit tests to use more useful asserts

pull/152/head
Hugo 6 years ago committed by Adrien Vergé
parent 4a7986b4cf
commit 5852566ff0

@ -78,7 +78,7 @@ class SimpleConfigTestCase(unittest.TestCase):
' spaces: 2\n' ' spaces: 2\n'
' indent-sequences: true\n' ' indent-sequences: true\n'
' check-multi-line-strings: false\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'], self.assertEqual(c.rules['indentation']['check-multi-line-strings'],
False) False)
@ -87,7 +87,7 @@ class SimpleConfigTestCase(unittest.TestCase):
' spaces: 2\n' ' spaces: 2\n'
' indent-sequences: yes\n' ' indent-sequences: yes\n'
' check-multi-line-strings: false\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'], self.assertEqual(c.rules['indentation']['check-multi-line-strings'],
False) False)
@ -115,8 +115,8 @@ class SimpleConfigTestCase(unittest.TestCase):
class Rule(object): class Rule(object):
ID = 'fake' ID = 'fake'
self.assertEqual(config.validate_rule_conf(Rule, False), False) self.assertFalse(config.validate_rule_conf(Rule, False))
self.assertEqual(config.validate_rule_conf(Rule, 'disable'), False) self.assertFalse(config.validate_rule_conf(Rule, 'disable'))
self.assertEqual(config.validate_rule_conf(Rule, {}), self.assertEqual(config.validate_rule_conf(Rule, {}),
{'level': 'error'}) {'level': 'error'})
@ -194,7 +194,7 @@ class ExtendedConfigTestCase(unittest.TestCase):
new.extend(old) new.extend(old)
self.assertEqual(sorted(new.rules.keys()), ['colons', 'hyphens']) 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(new.rules['hyphens']['max-spaces-after'], 2)
self.assertEqual(len(new.enabled_rules(None)), 1) self.assertEqual(len(new.enabled_rules(None)), 1)

@ -65,12 +65,12 @@ class ParserTestCase(unittest.TestCase):
def test_token_or_comment_generator(self): def test_token_or_comment_generator(self):
e = list(token_or_comment_generator('')) e = list(token_or_comment_generator(''))
self.assertEqual(len(e), 2) 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].curr, yaml.Token)
self.assertIsInstance(e[0].next, yaml.Token) self.assertIsInstance(e[0].next, yaml.Token)
self.assertEqual(e[1].prev, e[0].curr) self.assertEqual(e[1].prev, e[0].curr)
self.assertEqual(e[1].curr, e[0].next) 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' e = list(token_or_comment_generator('---\n'
'k: v\n')) 'k: v\n'))

Loading…
Cancel
Save