1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Used more specific unittest assertions in tests.

This commit is contained in:
Mads Jensen 2021-04-16 23:19:25 +02:00 committed by Mariusz Felisiak
parent 7309393c3a
commit c51bf80d56
5 changed files with 8 additions and 8 deletions

View File

@ -241,7 +241,7 @@ class NonAggregateAnnotationTestCase(TestCase):
),
rating_count=Count('rating'),
).first()
self.assertEqual(book.isnull_pubdate, False)
self.assertIs(book.isnull_pubdate, False)
self.assertEqual(book.rating_count, 1)
@skipUnlessDBFeature('supports_boolean_expr_in_select_clause')

View File

@ -1035,7 +1035,7 @@ class ReadOnlyPasswordHashTest(SimpleTestCase):
hash_field = ReadOnlyPasswordHashField()
bound_field = TestForm()['hash_field']
self.assertEqual(bound_field.field.widget.id_for_label('id'), None)
self.assertIsNone(bound_field.field.widget.id_for_label('id'))
self.assertEqual(bound_field.label_tag(), '<label>Hash field:</label>')

View File

@ -501,7 +501,7 @@ class BackendTestCase(TransactionTestCase):
params, kwargs = mocked_logger.debug.call_args
self.assertIn('; alias=%s', params[0])
self.assertEqual(params[2], sql)
self.assertEqual(params[3], None)
self.assertIsNone(params[3])
self.assertEqual(params[4], connection.alias)
self.assertEqual(
list(kwargs['extra']),

View File

@ -57,7 +57,7 @@ class AbstractInheritanceTests(SimpleTestCase):
self.assertEqual(Child.check(), [])
inherited_field = Child._meta.get_field('name')
self.assertTrue(isinstance(inherited_field, models.CharField))
self.assertIsInstance(inherited_field, models.CharField)
self.assertEqual(inherited_field.max_length, 255)
def test_diamond_shaped_multiple_inheritance_is_depth_first(self):
@ -93,7 +93,7 @@ class AbstractInheritanceTests(SimpleTestCase):
self.assertEqual(Child.check(), [])
inherited_field = Child._meta.get_field('name')
self.assertTrue(isinstance(inherited_field, models.CharField))
self.assertIsInstance(inherited_field, models.CharField)
self.assertEqual(inherited_field.max_length, 255)
def test_target_field_may_be_pushed_down(self):
@ -124,7 +124,7 @@ class AbstractInheritanceTests(SimpleTestCase):
self.assertEqual(Child.check(), [])
inherited_field = Child._meta.get_field('name')
self.assertTrue(isinstance(inherited_field, models.IntegerField))
self.assertIsInstance(inherited_field, models.IntegerField)
def test_multiple_inheritance_cannot_shadow_concrete_inherited_field(self):
class ConcreteParent(models.Model):

View File

@ -405,7 +405,7 @@ class DiscoverRunnerTests(SimpleTestCase):
with runner.time_keeper.timed('test'):
pass
runner.time_keeper.print_results()
self.assertTrue(isinstance(runner.time_keeper, NullTimeKeeper))
self.assertIsInstance(runner.time_keeper, NullTimeKeeper)
self.assertNotIn('test', stderr.getvalue())
def test_timings_captured(self):
@ -414,7 +414,7 @@ class DiscoverRunnerTests(SimpleTestCase):
with runner.time_keeper.timed('test'):
pass
runner.time_keeper.print_results()
self.assertTrue(isinstance(runner.time_keeper, TimeKeeper))
self.assertIsInstance(runner.time_keeper, TimeKeeper)
self.assertIn('test', stderr.getvalue())
def test_log(self):