Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Used more specific test assertions.

  • Loading branch information...
commit 2791fbf59d85a20adac22ed73c88a97fc0350426 1 parent 11e7254
@aaugustin aaugustin authored
View
3  django/contrib/auth/tests/test_views.py
@@ -475,8 +475,7 @@ def test_current_site_in_context_after_login(self):
self.assertEqual(response.context['site_name'], site.name)
else:
self.assertIsInstance(response.context['site'], RequestSite)
- self.assertTrue(isinstance(response.context['form'], AuthenticationForm),
- 'Login form is not an AuthenticationForm')
+ self.assertIsInstance(response.context['form'], AuthenticationForm)
def test_security_check(self, password='password'):
login_url = reverse('login')
View
4 django/contrib/formtools/tests/wizard/test_forms.py
@@ -246,11 +246,11 @@ class SessionFormTests(TestCase):
def test_init(self):
request = get_request()
testform = SessionWizardView.as_view([('start', Step1)])
- self.assertTrue(isinstance(testform(request), TemplateResponse))
+ self.assertIsInstance(testform(request), TemplateResponse)
class CookieFormTests(TestCase):
def test_init(self):
request = get_request()
testform = CookieWizardView.as_view([('start', Step1)])
- self.assertTrue(isinstance(testform(request), TemplateResponse))
+ self.assertIsInstance(testform(request), TemplateResponse)
View
2  django/contrib/gis/geoip/tests.py
@@ -106,7 +106,7 @@ def test04_city(self):
self.assertEqual('TX', d['region'])
self.assertEqual(713, d['area_code'])
geom = g.geos(query)
- self.assertTrue(isinstance(geom, GEOSGeometry))
+ self.assertIsInstance(geom, GEOSGeometry)
lon, lat = (-95.4010, 29.7079)
lat_lon = g.lat_lon(query)
lat_lon = (lat_lon[1], lat_lon[0])
View
2  django/contrib/gis/tests/geoapp/tests.py
@@ -201,7 +201,7 @@ def test_raw_sql_query(self):
as_text = 'ST_AsText' if postgis else 'asText'
cities2 = City.objects.raw('select id, name, %s(point) from geoapp_city' % as_text)
self.assertEqual(len(cities1), len(list(cities2)))
- self.assertTrue(isinstance(cities2[0].point, Point))
+ self.assertIsInstance(cities2[0].point, Point)
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
View
6 django/contrib/gis/tests/relatedapp/tests.py
@@ -179,8 +179,8 @@ def test07_values(self):
for m, d, t in zip(gqs, gvqs, gvlqs):
# The values should be Geometry objects and not raw strings returned
# by the spatial database.
- self.assertTrue(isinstance(d['point'], Geometry))
- self.assertTrue(isinstance(t[1], Geometry))
+ self.assertIsInstance(d['point'], Geometry)
+ self.assertIsInstance(t[1], Geometry)
self.assertEqual(m.point, d['point'])
self.assertEqual(m.point, t[1])
@@ -255,7 +255,7 @@ def test13c_count(self):
qs = Location.objects.filter(id=5).annotate(num_cities=Count('city')).values('id', 'point', 'num_cities')
self.assertEqual(1, len(qs))
self.assertEqual(2, qs[0]['num_cities'])
- self.assertTrue(isinstance(qs[0]['point'], GEOSGeometry))
+ self.assertIsInstance(qs[0]['point'], GEOSGeometry)
# TODO: The phantom model does appear on Oracle.
@no_oracle
View
2  django/contrib/gis/tests/test_measure.py
@@ -93,7 +93,7 @@ def testMultiplication(self):
self.assertEqual(d5, 50)
a5 = d1 * D(m=10)
- self.assertTrue(isinstance(a5, Area))
+ self.assertIsInstance(a5, Area)
self.assertEqual(a5.sq_m, 100 * 10)
with self.assertRaises(TypeError):
View
6 django/contrib/sites/tests.py
@@ -26,7 +26,7 @@ def test_save_another(self):
def test_site_manager(self):
# Make sure that get_current() does not return a deleted Site object.
s = Site.objects.get_current()
- self.assertTrue(isinstance(s, Site))
+ self.assertIsInstance(s, Site)
s.delete()
self.assertRaises(ObjectDoesNotExist, Site.objects.get_current)
@@ -57,7 +57,7 @@ def test_get_current_site(self):
"SERVER_PORT": "80",
}
site = get_current_site(request)
- self.assertTrue(isinstance(site, Site))
+ self.assertIsInstance(site, Site)
self.assertEqual(site.id, settings.SITE_ID)
# Test that an exception is raised if the sites framework is installed
@@ -68,7 +68,7 @@ def test_get_current_site(self):
# A RequestSite is returned if the sites framework is not installed
with self.modify_settings(INSTALLED_APPS={'remove': 'django.contrib.sites'}):
site = get_current_site(request)
- self.assertTrue(isinstance(site, RequestSite))
+ self.assertIsInstance(site, RequestSite)
self.assertEqual(site.name, "example.com")
def test_domain_name_with_whitespaces(self):
View
4 django/test/testcases.py
@@ -620,8 +620,8 @@ def assertFieldOutput(self, fieldclass, valid, invalid, field_args=None,
# test that max_length and min_length are always accepted
if issubclass(fieldclass, CharField):
field_kwargs.update({'min_length': 2, 'max_length': 20})
- self.assertTrue(isinstance(fieldclass(*field_args, **field_kwargs),
- fieldclass))
+ self.assertIsInstance(fieldclass(*field_args, **field_kwargs),
+ fieldclass)
def assertHTMLEqual(self, html1, html2, msg=None):
"""
View
4 tests/backends/tests.py
@@ -646,7 +646,7 @@ def test_cursor_contextmanager(self):
Test that cursors can be used as a context manager
"""
with connection.cursor() as cursor:
- self.assertTrue(isinstance(cursor, CursorWrapper))
+ self.assertIsInstance(cursor, CursorWrapper)
# Both InterfaceError and ProgrammingError seem to be used when
# accessing closed cursor (psycopg2 has InterfaceError, rest seem
# to use ProgrammingError).
@@ -661,7 +661,7 @@ def test_cursor_contextmanager_closing(self):
# psycopg2 offers us a way to check that by closed attribute.
# So, run only on psycopg2 for that reason.
with connection.cursor() as cursor:
- self.assertTrue(isinstance(cursor, CursorWrapper))
+ self.assertIsInstance(cursor, CursorWrapper)
self.assertTrue(cursor.closed)
View
4 tests/forms_tests/tests/test_forms.py
@@ -1908,7 +1908,7 @@ def __init__(self, fields=(), *args, **kwargs):
field = ChoicesField()
field2 = copy.deepcopy(field)
- self.assertTrue(isinstance(field2, ChoicesField))
+ self.assertIsInstance(field2, ChoicesField)
self.assertFalse(id(field2.fields) == id(field.fields))
self.assertFalse(id(field2.fields[0].choices) ==
id(field.fields[0].choices))
@@ -2152,7 +2152,7 @@ def test_error_list(self):
e.append('Foo')
e.append(ValidationError('Foo%(bar)s', code='foobar', params={'bar': 'bar'}))
- self.assertTrue(isinstance(e, list))
+ self.assertIsInstance(e, list)
self.assertIn('Foo', e)
self.assertIn('Foo', forms.ValidationError(e))
View
2  tests/model_fields/tests.py
@@ -298,7 +298,7 @@ def test_return_type(self):
# conversions are applied with an offset
b5 = BooleanModel.objects.all().extra(
select={'string_col': 'string'})[0]
- self.assertFalse(isinstance(b5.pk, bool))
+ self.assertNotIsInstance(b5.pk, bool)
def test_select_related(self):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.