def test_dump_fixture(self):
     """
     Test dump_fixture calls dumpdata management command
     and tries to save it to file."""
     # Load test data
     call_command('loaddata', 'cities_light/tests/fixtures/angouleme.json')
     # Dump
     try:
         fixture_path = 'cities_light/tests/fixtures/test_dump_fixture.json'
         cmd = Command()
         cmd.dump_fixture('cities_light.City', fixture_path)
         with bz2.BZ2File(fixture_path, mode='r') as bzfile:
             data = bzfile.read()
         with open(fixture_path, mode='wb') as file:
             file.write(data)
         Fixture(fixture_path, models=[City]).assertNoDiff()
     finally:
         if os.path.exists(fixture_path):
             os.remove(fixture_path)
 def test_dump_fixture(self):
     """
     Test dump_fixture calls dumpdata management command
     and tries to save it to file."""
     # Load test data
     destination = FixtureDir('import').get_file_path('angouleme.json')
     call_command('loaddata', destination)
     # Dump
     try:
         fixture_path = 'cities_light/tests/fixtures/test_dump_fixture.json'
         cmd = Command()
         cmd.dump_fixture('cities_light.City', fixture_path)
         with bz2.BZ2File(fixture_path, mode='r') as bzfile:
             data = bzfile.read()
         with open(fixture_path, mode='wb') as file:
             file.write(data)
         Fixture(fixture_path, models=[City]).assertNoDiff()
     finally:
         if os.path.exists(fixture_path):
             os.remove(fixture_path)
 def test_dump_fixture(self):
     """
     Test dump_fixture calls dumpdata management command
     and tries to save it to file."""
     # Load test data
     destination = FixtureDir('import').get_file_path('angouleme.json')
     call_command('loaddata', destination)
     # Dump
     try:
         fixture_path = os.path.join(os.path.dirname(__file__), "fixtures",
                                     "test_dump_fixture.json")
         cmd = Command()
         cmd.dump_fixture('cities_light.City', fixture_path)
         with bz2.BZ2File(fixture_path, mode='r') as bzfile:
             data = bzfile.read()
         with open(fixture_path, mode='wb') as file:
             file.write(data)
         Fixture(fixture_path, models=[City]).assertNoDiff()
     finally:
         if os.path.exists(fixture_path):
             os.remove(fixture_path)