'Test a dumpdata/loaddata cycle with geographic data.'

def test_dumpdata_loaddata_cycle(self):

    out = StringIO()
    original_data = list(City.objects.all().order_by('name'))
    call_command('dumpdata', 'geoapp.City', stdout=out)
    result = out.getvalue()
    houston = City.objects.get(name='Houston')
    self.assertIn(('"point":    "%s"' % houston.point.ewkt), result)
    with tempfile.NamedTemporaryFile(mode='w', suffix='.json') as tmp:
        tmp.write(result)
        tmp.seek(0)
        call_command('loaddata', tmp.name, verbosity=0)
    self.assertEqual(original_data, list(City.objects.all().order_by('name')))
