tests: Avoid hidden logic with better .assert*() method choices

We'll get better failure messages if we use an assertion method that
understands the comparison we're trying to make.  If you make the
comparison by hand and assertTrue(), you don't get much constructive
feedback ;).
This commit is contained in:
W. Trevor King 2013-06-12 14:52:23 -04:00
commit 5a61600bc9
3 changed files with 6 additions and 6 deletions

View file

@ -108,7 +108,7 @@ class TestArticlesGenerator(unittest.TestCase):
sorted(['Default', 'TestCategory', 'Yeah', 'test', '指導書']),
sorted(['Default', 'TestCategory', 'yeah', 'test', '指導書']),
)
self.assertTrue(sorted(categories) in categories_alternatives)
self.assertIn(sorted(categories), categories_alternatives)
# test for slug
categories = [cat.slug for cat, _ in generator.categories]
categories_expected = ['default', 'testcategory', 'yeah', 'test',
@ -136,7 +136,7 @@ class TestArticlesGenerator(unittest.TestCase):
sorted(['Default', 'Yeah', 'test', '指導書']),
sorted(['Default', 'yeah', 'test', '指導書']),
)
self.assertTrue(sorted(categories) in categories_alternatives)
self.assertIn(sorted(categories), categories_alternatives)
# test for slug
categories = [cat.slug for cat, _ in generator.categories]
categories_expected = ['default', 'yeah', 'test', 'zhi-dao-shu']