Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.6.x] Stopped calling loaddata with commit=False.

This was a stealth option only used by the tests, and it isn't useful
any more since `atomic` provides nested transactions.

Backport of 2c40681 from master.
  • Loading branch information...
commit d2550042894726c5b74a9a2374304b75a4ac30bc 1 parent b930733
@aaugustin aaugustin authored
View
56 tests/fixtures/tests.py
@@ -56,7 +56,7 @@ def test_initial_data(self):
def test_loading_and_dumping(self):
Site.objects.all().delete()
# Load fixture 1. Single JSON file, with two objects.
- management.call_command('loaddata', 'fixture1.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture1.json', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: Time to reform copyright>',
'<Article: Poker has no place on ESPN>',
@@ -87,7 +87,7 @@ def test_loading_and_dumping(self):
self._dumpdata_assert(['fixtures.Category', 'sites'], '[{"pk": 1, "model": "fixtures.category", "fields": {"description": "Latest news stories", "title": "News Stories"}}, {"pk": 1, "model": "sites.site", "fields": {"domain": "example.com", "name": "example.com"}}]')
# Load fixture 2. JSON file imported by default. Overwrites some existing objects
- management.call_command('loaddata', 'fixture2.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture2.json', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: Django conquers world!>',
'<Article: Copyright is fine the way it is>',
@@ -95,7 +95,7 @@ def test_loading_and_dumping(self):
])
# Load fixture 3, XML format.
- management.call_command('loaddata', 'fixture3.xml', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture3.xml', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: XML identified as leading cause of cancer>',
'<Article: Django conquers world!>',
@@ -104,14 +104,14 @@ def test_loading_and_dumping(self):
])
# Load fixture 6, JSON file with dynamic ContentType fields. Testing ManyToOne.
- management.call_command('loaddata', 'fixture6.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture6.json', verbosity=0)
self.assertQuerysetEqual(Tag.objects.all(), [
'<Tag: <Article: Copyright is fine the way it is> tagged "copyright">',
'<Tag: <Article: Copyright is fine the way it is> tagged "law">',
], ordered=False)
# Load fixture 7, XML file with dynamic ContentType fields. Testing ManyToOne.
- management.call_command('loaddata', 'fixture7.xml', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture7.xml', verbosity=0)
self.assertQuerysetEqual(Tag.objects.all(), [
'<Tag: <Article: Copyright is fine the way it is> tagged "copyright">',
'<Tag: <Article: Copyright is fine the way it is> tagged "legal">',
@@ -120,7 +120,7 @@ def test_loading_and_dumping(self):
], ordered=False)
# Load fixture 8, JSON file with dynamic Permission fields. Testing ManyToMany.
- management.call_command('loaddata', 'fixture8.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture8.json', verbosity=0)
self.assertQuerysetEqual(Visa.objects.all(), [
'<Visa: Django Reinhardt Can add user, Can change user, Can delete user>',
'<Visa: Stephane Grappelli Can add user>',
@@ -128,7 +128,7 @@ def test_loading_and_dumping(self):
], ordered=False)
# Load fixture 9, XML file with dynamic Permission fields. Testing ManyToMany.
- management.call_command('loaddata', 'fixture9.xml', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture9.xml', verbosity=0)
self.assertQuerysetEqual(Visa.objects.all(), [
'<Visa: Django Reinhardt Can add user, Can change user, Can delete user>',
'<Visa: Stephane Grappelli Can add user, Can delete user>',
@@ -143,15 +143,13 @@ def test_loading_and_dumping(self):
# Loading a fixture that doesn't exist emits a warning
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
- management.call_command('loaddata', 'unknown.json', verbosity=0,
- commit=False)
+ management.call_command('loaddata', 'unknown.json', verbosity=0)
self.assertEqual(len(w), 1)
self.assertTrue(w[0].message, "No fixture named 'unknown' found.")
# An attempt to load a nonexistent 'initial_data' fixture isn't an error
with warnings.catch_warnings(record=True) as w:
- management.call_command('loaddata', 'initial_data.json', verbosity=0,
- commit=False)
+ management.call_command('loaddata', 'initial_data.json', verbosity=0)
self.assertEqual(len(w), 0)
# object list is unaffected
@@ -178,7 +176,7 @@ def test_loading_and_dumping(self):
def test_dumpdata_with_excludes(self):
# Load fixture1 which has a site, two articles, and a category
Site.objects.all().delete()
- management.call_command('loaddata', 'fixture1.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture1.json', verbosity=0)
# Excluding fixtures app should only leave sites
self._dumpdata_assert(
@@ -226,8 +224,8 @@ def test_dumpdata_with_filtering_manager(self):
self._dumpdata_assert(['fixtures.Spy'], '[{"pk": %d, "model": "fixtures.spy", "fields": {"cover_blown": true}}, {"pk": %d, "model": "fixtures.spy", "fields": {"cover_blown": false}}]' % (spy2.pk, spy1.pk), use_base_manager=True)
def test_dumpdata_with_pks(self):
- management.call_command('loaddata', 'fixture1.json', verbosity=0, commit=False)
- management.call_command('loaddata', 'fixture2.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture1.json', verbosity=0)
+ management.call_command('loaddata', 'fixture2.json', verbosity=0)
self._dumpdata_assert(
['fixtures.Article'],
'[{"pk": 2, "model": "fixtures.article", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16T12:00:00"}}, {"pk": 3, "model": "fixtures.article", "fields": {"headline": "Copyright is fine the way it is", "pub_date": "2006-06-16T14:00:00"}}]',
@@ -266,21 +264,21 @@ def test_dumpdata_with_pks(self):
def test_compress_format_loading(self):
# Load fixture 4 (compressed), using format specification
- management.call_command('loaddata', 'fixture4.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture4.json', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: Django pets kitten>',
])
def test_compressed_specified_loading(self):
# Load fixture 5 (compressed), using format *and* compression specification
- management.call_command('loaddata', 'fixture5.json.zip', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture5.json.zip', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: WoW subscribers now outnumber readers>',
])
def test_compressed_loading(self):
# Load fixture 5 (compressed), only compression specification
- management.call_command('loaddata', 'fixture5.zip', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture5.zip', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: WoW subscribers now outnumber readers>',
])
@@ -288,13 +286,13 @@ def test_compressed_loading(self):
def test_ambiguous_compressed_fixture(self):
# The name "fixture5" is ambigous, so loading it will raise an error
with self.assertRaises(management.CommandError) as cm:
- management.call_command('loaddata', 'fixture5', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture5', verbosity=0)
self.assertIn("Multiple fixtures named 'fixture5'", cm.exception.args[0])
def test_db_loading(self):
# Load db fixtures 1 and 2. These will load using the 'default' database identifier implicitly
- management.call_command('loaddata', 'db_fixture_1', verbosity=0, commit=False)
- management.call_command('loaddata', 'db_fixture_2', verbosity=0, commit=False)
+ management.call_command('loaddata', 'db_fixture_1', verbosity=0)
+ management.call_command('loaddata', 'db_fixture_2', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: Who needs more than one database?>',
'<Article: Who needs to use compressed data?>',
@@ -312,13 +310,13 @@ def test_loaddata_error_message(self):
if connection.vendor == 'mysql':
connection.cursor().execute("SET sql_mode = 'TRADITIONAL'")
with self.assertRaises(IntegrityError) as cm:
- management.call_command('loaddata', 'invalid.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'invalid.json', verbosity=0)
self.assertIn("Could not load fixtures.Article(pk=1):", cm.exception.args[0])
def test_loading_using(self):
# Load db fixtures 1 and 2. These will load using the 'default' database identifier explicitly
- management.call_command('loaddata', 'db_fixture_1', verbosity=0, using='default', commit=False)
- management.call_command('loaddata', 'db_fixture_2', verbosity=0, using='default', commit=False)
+ management.call_command('loaddata', 'db_fixture_1', verbosity=0, using='default')
+ management.call_command('loaddata', 'db_fixture_2', verbosity=0, using='default')
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: Who needs more than one database?>',
'<Article: Who needs to use compressed data?>',
@@ -327,18 +325,18 @@ def test_loading_using(self):
def test_unmatched_identifier_loading(self):
# Try to load db fixture 3. This won't load because the database identifier doesn't match
with warnings.catch_warnings(record=True):
- management.call_command('loaddata', 'db_fixture_3', verbosity=0, commit=False)
+ management.call_command('loaddata', 'db_fixture_3', verbosity=0)
with warnings.catch_warnings(record=True):
- management.call_command('loaddata', 'db_fixture_3', verbosity=0, using='default', commit=False)
+ management.call_command('loaddata', 'db_fixture_3', verbosity=0, using='default')
self.assertQuerysetEqual(Article.objects.all(), [])
def test_output_formats(self):
# Load back in fixture 1, we need the articles from it
- management.call_command('loaddata', 'fixture1', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture1', verbosity=0)
# Try to load fixture 6 using format discovery
- management.call_command('loaddata', 'fixture6', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture6', verbosity=0)
self.assertQuerysetEqual(Tag.objects.all(), [
'<Tag: <Article: Time to reform copyright> tagged "copyright">',
'<Tag: <Article: Time to reform copyright> tagged "law">'
@@ -364,7 +362,7 @@ class FixtureTransactionTests(DumpDataAssertMixin, TransactionTestCase):
@skipUnlessDBFeature('supports_forward_references')
def test_format_discovery(self):
# Load fixture 1 again, using format discovery
- management.call_command('loaddata', 'fixture1', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture1', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: Time to reform copyright>',
'<Article: Poker has no place on ESPN>',
@@ -386,7 +384,7 @@ def test_format_discovery(self):
self._dumpdata_assert(['fixtures'], '[{"pk": 1, "model": "fixtures.category", "fields": {"description": "Latest news stories", "title": "News Stories"}}, {"pk": 2, "model": "fixtures.article", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16T12:00:00"}}, {"pk": 3, "model": "fixtures.article", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16T13:00:00"}}, {"pk": 10, "model": "fixtures.book", "fields": {"name": "Achieving self-awareness of Python programs", "authors": []}}]')
# Load fixture 4 (compressed), using format discovery
- management.call_command('loaddata', 'fixture4', verbosity=0, commit=False)
+ management.call_command('loaddata', 'fixture4', verbosity=0)
self.assertQuerysetEqual(Article.objects.all(), [
'<Article: Django pets kitten>',
'<Article: Time to reform copyright>',
View
7 tests/fixtures_model_package/tests.py
@@ -60,7 +60,6 @@ def test_flush(self):
'flush',
verbosity=0,
interactive=False,
- commit=False,
load_initial_data=False
)
self.assertQuerysetEqual(Book.objects.all(), [])
@@ -83,7 +82,7 @@ def test_initial_data(self):
def test_loaddata(self):
"Fixtures can load data into models defined in packages"
# Load fixture 1. Single JSON file, with two objects
- management.call_command("loaddata", "fixture1.json", verbosity=0, commit=False)
+ management.call_command("loaddata", "fixture1.json", verbosity=0)
self.assertQuerysetEqual(
Article.objects.all(), [
"Time to reform copyright",
@@ -94,7 +93,7 @@ def test_loaddata(self):
# Load fixture 2. JSON file imported by default. Overwrites some
# existing objects
- management.call_command("loaddata", "fixture2.json", verbosity=0, commit=False)
+ management.call_command("loaddata", "fixture2.json", verbosity=0)
self.assertQuerysetEqual(
Article.objects.all(), [
"Django conquers world!",
@@ -107,7 +106,7 @@ def test_loaddata(self):
# Load a fixture that doesn't exist
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
- management.call_command("loaddata", "unknown.json", verbosity=0, commit=False)
+ management.call_command("loaddata", "unknown.json", verbosity=0)
self.assertEqual(len(w), 1)
self.assertTrue(w[0].message, "No fixture named 'unknown' found.")
View
32 tests/fixtures_regress/tests.py
@@ -45,7 +45,6 @@ def test_duplicate_pk(self):
'loaddata',
'sequence',
verbosity=0,
- commit=False
)
# Create a new animal. Without a sequence reset, this new object
@@ -84,7 +83,6 @@ def test_loaddata_not_found_fields_ignore(self):
'sequence_extra',
ignore=True,
verbosity=0,
- commit=False
)
self.assertEqual(Animal.specimens.all()[0].name, 'Lion')
@@ -98,7 +96,6 @@ def test_loaddata_not_found_fields_ignore_xml(self):
'sequence_extra_xml',
ignore=True,
verbosity=0,
- commit=False
)
self.assertEqual(Animal.specimens.all()[0].name, 'Wolf')
@@ -113,7 +110,6 @@ def test_pretty_print_xml(self):
'loaddata',
'pretty.xml',
verbosity=0,
- commit=False
)
self.assertEqual(Stuff.objects.all()[0].name, None)
self.assertEqual(Stuff.objects.all()[0].owner, None)
@@ -129,7 +125,6 @@ def test_pretty_print_xml_empty_strings(self):
'loaddata',
'pretty.xml',
verbosity=0,
- commit=False
)
self.assertEqual(Stuff.objects.all()[0].name, '')
self.assertEqual(Stuff.objects.all()[0].owner, None)
@@ -152,7 +147,6 @@ def test_absolute_path(self):
'loaddata',
load_absolute_path,
verbosity=0,
- commit=False
)
self.assertEqual(Absolute.load_count, 1)
@@ -168,7 +162,6 @@ def test_unknown_format(self):
'loaddata',
'bad_fixture1.unkn',
verbosity=0,
- commit=False,
)
@override_settings(SERIALIZATION_MODULES={'unkn': 'unexistent.path'})
@@ -182,7 +175,6 @@ def test_unimportable_serializer(self):
'loaddata',
'bad_fixture1.unkn',
verbosity=0,
- commit=False,
)
def test_invalid_data(self):
@@ -197,7 +189,6 @@ def test_invalid_data(self):
'loaddata',
'bad_fixture2.xml',
verbosity=0,
- commit=False,
)
def test_invalid_data_no_ext(self):
@@ -212,7 +203,6 @@ def test_invalid_data_no_ext(self):
'loaddata',
'bad_fixture2',
verbosity=0,
- commit=False,
)
def test_empty(self):
@@ -226,7 +216,6 @@ def test_empty(self):
'loaddata',
'empty',
verbosity=0,
- commit=False,
)
def test_error_message(self):
@@ -240,7 +229,6 @@ def test_error_message(self):
'bad_fixture2',
'animal',
verbosity=0,
- commit=False,
)
def test_pg_sequence_resetting_checks(self):
@@ -253,7 +241,6 @@ def test_pg_sequence_resetting_checks(self):
'loaddata',
'model-inheritance.json',
verbosity=0,
- commit=False
)
self.assertEqual(Parent.objects.all()[0].id, 1)
self.assertEqual(Child.objects.all()[0].id, 1)
@@ -270,7 +257,6 @@ def test_close_connection_after_loaddata(self):
'loaddata',
'big-fixture.json',
verbosity=0,
- commit=False
)
articles = Article.objects.exclude(id=9)
self.assertEqual(
@@ -297,7 +283,6 @@ def test_field_value_coerce(self):
'loaddata',
'animal.xml',
verbosity=0,
- commit=False,
)
self.assertEqual(
self.pre_save_checks,
@@ -319,13 +304,11 @@ def test_dumpdata_uses_default_manager(self):
'loaddata',
'animal.xml',
verbosity=0,
- commit=False,
)
management.call_command(
'loaddata',
'sequence.json',
verbosity=0,
- commit=False,
)
animal = Animal(
name='Platypus',
@@ -390,7 +373,6 @@ def test_loaddata_works_when_fixture_has_forward_refs(self):
'loaddata',
'forward_ref.json',
verbosity=0,
- commit=False
)
self.assertEqual(Book.objects.all()[0].id, 1)
self.assertEqual(Person.objects.all()[0].id, 4)
@@ -405,7 +387,6 @@ def test_loaddata_raises_error_when_fixture_has_invalid_foreign_key(self):
'loaddata',
'forward_ref_bad_data.json',
verbosity=0,
- commit=False,
)
_cur_dir = os.path.dirname(os.path.abspath(upath(__file__)))
@@ -422,7 +403,6 @@ def test_loaddata_forward_refs_split_fixtures(self):
'forward_ref_1.json',
'forward_ref_2.json',
verbosity=0,
- commit=False
)
self.assertEqual(Book.objects.all()[0].id, 1)
self.assertEqual(Person.objects.all()[0].id, 4)
@@ -437,7 +417,6 @@ def test_loaddata_no_fixture_specified(self):
management.call_command(
'loaddata',
verbosity=0,
- commit=False,
)
def test_loaddata_not_existant_fixture_file(self):
@@ -447,7 +426,6 @@ def test_loaddata_not_existant_fixture_file(self):
'loaddata',
'this_fixture_doesnt_exist',
verbosity=2,
- commit=False,
stdout=stdout_output,
)
self.assertTrue("No fixture 'this_fixture_doesnt_exist' in" in
@@ -465,13 +443,11 @@ def test_nk_deserialize(self):
'loaddata',
'model-inheritance.json',
verbosity=0,
- commit=False
)
management.call_command(
'loaddata',
'nk-inheritance.json',
verbosity=0,
- commit=False
)
self.assertEqual(
NKChild.objects.get(pk=1).data,
@@ -492,19 +468,16 @@ def test_nk_deserialize_xml(self):
'loaddata',
'model-inheritance.json',
verbosity=0,
- commit=False
)
management.call_command(
'loaddata',
'nk-inheritance.json',
verbosity=0,
- commit=False
)
management.call_command(
'loaddata',
'nk-inheritance2.xml',
verbosity=0,
- commit=False
)
self.assertEqual(
NKChild.objects.get(pk=2).data,
@@ -524,7 +497,6 @@ def test_nk_on_serialize(self):
'loaddata',
'forward_ref_lookup.json',
verbosity=0,
- commit=False
)
stdout = StringIO()
@@ -662,19 +634,16 @@ def test_normal_pk(self):
'loaddata',
'non_natural_1.json',
verbosity=0,
- commit=False
)
management.call_command(
'loaddata',
'forward_ref_lookup.json',
verbosity=0,
- commit=False
)
management.call_command(
'loaddata',
'non_natural_2.xml',
verbosity=0,
- commit=False
)
books = Book.objects.all()
self.assertEqual(
@@ -696,7 +665,6 @@ def ticket_11101(self):
'loaddata',
'thingy.json',
verbosity=0,
- commit=False
)
self.assertEqual(Thingy.objects.count(), 1)
transaction.rollback()
View
2  tests/proxy_models/tests.py
@@ -358,7 +358,7 @@ def test_proxy_bug(self):
)
def test_proxy_load_from_fixture(self):
- management.call_command('loaddata', 'mypeople.json', verbosity=0, commit=False)
+ management.call_command('loaddata', 'mypeople.json', verbosity=0)
p = MyPerson.objects.get(pk=100)
self.assertEqual(p.name, 'Elvis Presley')
Please sign in to comment.
Something went wrong with that request. Please try again.