Kaydet (Commit) f53b1c77 authored tarafından Tim Graham's avatar Tim Graham

Fixed #23099 -- Removed usage of deprecated initial data in Django's test suite.

Thanks Claude Paroz for assistance with debugging the tests.
üst 73ff4498
......@@ -21,6 +21,7 @@ if HAS_GEOS and HAS_SPATIAL_DB:
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB and not mysql,
"Geos and spatial db (not mysql) are required.")
class DistanceTest(TestCase):
fixtures = ['initial']
if HAS_GEOS and HAS_SPATIAL_DB:
# A point we are testing distances with -- using a WGS84
......@@ -219,7 +220,7 @@ class DistanceTest(TestCase):
ref_zips = ['77002', '77025', '77401']
for buf in [buf1, buf2]:
qs = CensusZipcode.objects.exclude(name='77005').transform(32140).distance(buf)
qs = CensusZipcode.objects.exclude(name='77005').transform(32140).distance(buf).order_by('name')
self.assertListEqual(ref_zips, self.get_names(qs))
for i, z in enumerate(qs):
self.assertAlmostEqual(z.distance.m, dists_m[i], 5)
......@@ -361,7 +362,7 @@ class DistanceTest(TestCase):
# SELECT ST_Perimeter(distapp_southtexaszipcode.poly) FROM distapp_southtexaszipcode;
perim_m = [18404.3550889361, 15627.2108551001, 20632.5588368978, 17094.5996143697]
tol = 2 if oracle else 7
for i, z in enumerate(SouthTexasZipcode.objects.perimeter()):
for i, z in enumerate(SouthTexasZipcode.objects.order_by('name').perimeter()):
self.assertAlmostEqual(perim_m[i], z.perimeter.m, tol)
# Running on points; should return 0.
......
......@@ -17,6 +17,7 @@ if HAS_GEOS:
@override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoapp.urls')
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoFeedTest(TestCase):
fixtures = ['initial']
def setUp(self):
Site(id=settings.SITE_ID, domain="example.com", name="example.com").save()
......
......@@ -17,6 +17,7 @@ if HAS_GEOS:
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoRegressionTests(TestCase):
fixtures = ['initial']
def test_update(self):
"Testing GeoQuerySet.update(). See #10411."
......
......@@ -30,6 +30,7 @@ def postgis_bug_version():
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoModelTest(TestCase):
fixtures = ['initial']
def test_fixtures(self):
"Testing geographic model initialization from fixtures."
......@@ -206,6 +207,7 @@ class GeoModelTest(TestCase):
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoLookupTest(TestCase):
fixtures = ['initial']
@no_mysql
def test_disjoint_lookup(self):
......@@ -397,6 +399,8 @@ class GeoLookupTest(TestCase):
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class GeoQuerySetTest(TestCase):
fixtures = ['initial']
# Please keep the tests in GeoQuerySet method's alphabetic order
@no_mysql
......
......@@ -19,6 +19,7 @@ if HAS_GEOS:
@skipUnless(HAS_GEOS and postgis, "Geos and postgis are required.")
class GeographyTest(TestCase):
fixtures = ['initial']
def test01_fixture_load(self):
"Ensure geography features loaded properly."
......
[
{
"pk": 1,
"model": "relatedapp.location",
"fields": {
"point": "SRID=4326;POINT (-97.516111 33.058333)"
}
},
{
"pk": 2,
"model": "relatedapp.location",
"fields": {
"point": "SRID=4326;POINT (-104.528056 33.387222)"
}
},
{
"pk": 3,
"model": "relatedapp.location",
"fields": {
"point": "SRID=4326;POINT (-79.460734 40.18476)"
}
},
{
"pk": 4,
"model": "relatedapp.location",
"fields": {
"point": "SRID=4326;POINT (-95.363151 29.763374)"
}
},
{
"pk": 5,
"model": "relatedapp.location",
"fields": {
"point": "SRID=4326;POINT (-96.801611 32.782057)"
}
},
{
"pk": 1,
"model": "relatedapp.city",
"fields": {
"name": "Aurora",
"state": "TX",
"location": 1
}
},
{
"pk": 2,
"model": "relatedapp.city",
"fields": {
"name": "Roswell",
"state": "NM",
"location": 2
}
},
{
"pk": 3,
"model": "relatedapp.city",
"fields": {
"name": "Kecksburg",
"state": "PA",
"location": 3
}
},
{
"pk": 4,
"model": "relatedapp.city",
"fields": {
"name": "Dallas",
"state": "TX",
"location": 5
}
},
{
"pk": 5,
"model": "relatedapp.city",
"fields": {
"name": "Houston",
"state": "TX",
"location": 4
}
},
{
"pk": 6,
"model": "relatedapp.city",
"fields": {
"name": "Fort Worth",
"state": "TX",
"location": 5
}
},
{
"pk": 1,
"model": "relatedapp.Author",
"fields": {
"name": "Trevor Paglen",
"dob": "1974-5-23"
}
},
{
"pk": 2,
"model": "relatedapp.Author",
"fields": {
"name": "William Patry",
"dob": "1950-1-1"
}
},
{
"pk": 1,
"model": "relatedapp.Book",
"fields": {
"title": "Torture Taxi",
"author": 1
}
},
{
"pk": 2,
"model": "relatedapp.Book",
"fields": {
"title": "I Could Tell You But Then You Would Have to be Destroyed by Me",
"author": 1
}
},
{
"pk": 3,
"model": "relatedapp.Book",
"fields": {
"title": "Blank Spots on the Map",
"author": 1
}
},
{
"pk": 4,
"model": "relatedapp.Book",
"fields": {
"title": "Patry on Copyright",
"author": 2
}
}
]
\ No newline at end of file
......@@ -16,6 +16,7 @@ if HAS_GEOS:
@skipUnless(HAS_GEOS and HAS_SPATIAL_DB, "Geos and spatial db are required.")
class RelatedGeoModelTest(TestCase):
fixtures = ['initial']
def test02_select_related(self):
"Testing `select_related` on geographic models (see #7126)."
......@@ -284,7 +285,7 @@ class RelatedGeoModelTest(TestCase):
# Even though Dallas and Ft. Worth share same point, Collect doesn't
# consolidate -- that's why 4 points in MultiPoint.
self.assertEqual(4, len(coll))
self.assertEqual(ref_geom, coll)
self.assertTrue(ref_geom.equals(coll))
def test15_invalid_select_related(self):
"Testing doing select_related on the related name manager of a unique FK. See #13934."
......
......@@ -69,6 +69,7 @@ class FixtureLoadingTests(DumpDataAssertMixin, TestCase):
def test_initial_data(self):
# migrate introduces 1 initial data object from initial_data.json.
# this behavior is deprecated and will be removed in Django 1.9
self.assertQuerysetEqual(Book.objects.all(), [
'<Book: Achieving self-awareness of Python programs>'
])
......
......@@ -67,6 +67,7 @@ class FixtureTestCase(TestCase):
def test_initial_data(self):
"Fixtures can load initial data into models defined in packages"
# migrate introduces 1 initial data object from initial_data.json
# this behavior is deprecated and will be removed in Django 1.9
self.assertQuerysetEqual(
Book.objects.all(), [
'Achieving self-awareness of Python programs'
......
......@@ -221,6 +221,11 @@ def django_tests(verbosity, interactive, failfast, test_labels):
"use '<app_label>/sql' instead.",
RemovedInDjango19Warning
)
warnings.filterwarnings(
'ignore',
'initial_data fixtures are deprecated. Use data migrations instead.',
RemovedInDjango19Warning
)
warnings.filterwarnings(
'ignore',
'IPAddressField has been deprecated. Use GenericIPAddressField instead.',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment