Loading django/core/management/commands/dumpdata.py +4 −3 Original line number Diff line number Diff line Loading @@ -21,8 +21,9 @@ class Command(BaseCommand): help='Use natural keys if they are available.'), make_option('-a', '--all', action='store_true', dest='use_base_manager', default=False, help="Use Django's base manager to dump all models stored in the database, including those that would otherwise be filtered or modified by a custom manager."), make_option('--pks', dest='primary_keys', action='append', default=[], help="Only dump objects with given primary keys. Accepts a comma seperated list of keys. This option will only work when you specify one model."), make_option('--pks', dest='primary_keys', help="Only dump objects with " "given primary keys. Accepts a comma seperated list of keys. " "This option will only work when you specify one model."), ) help = ("Output the contents of the database as a fixture of the given " "format (using each model's default manager unless --all is " Loading @@ -44,7 +45,7 @@ class Command(BaseCommand): if pks: primary_keys = pks.split(',') else: primary_keys = False primary_keys = [] excluded_apps = set() excluded_models = set() Loading tests/admin_scripts/tests.py +19 −0 Original line number Diff line number Diff line Loading @@ -1682,3 +1682,22 @@ class DiffSettings(AdminScriptTestCase): out, err = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, "### STATIC_URL = None") class Dumpdata(AdminScriptTestCase): """Tests for dumpdata management command.""" def setUp(self): self.write_settings('settings.py') def tearDown(self): self.remove_settings('settings.py') def test_pks_parsing(self): """Regression for #20509 Test would raise an exception rather than printing an error message. """ args = ['dumpdata', '--pks=1'] out, err = self.run_manage(args) self.assertOutput(err, "You can only use --pks option with one model") self.assertNoOutput(out) tests/fixtures/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ class TestCaseFixtureLoadingTests(TestCase): class DumpDataAssertMixin(object): def _dumpdata_assert(self, args, output, format='json', natural_keys=False, use_base_manager=False, exclude_list=[], primary_keys=[]): use_base_manager=False, exclude_list=[], primary_keys=''): new_io = six.StringIO() management.call_command('dumpdata', *args, **{'format': format, 'stdout': new_io, Loading Loading
django/core/management/commands/dumpdata.py +4 −3 Original line number Diff line number Diff line Loading @@ -21,8 +21,9 @@ class Command(BaseCommand): help='Use natural keys if they are available.'), make_option('-a', '--all', action='store_true', dest='use_base_manager', default=False, help="Use Django's base manager to dump all models stored in the database, including those that would otherwise be filtered or modified by a custom manager."), make_option('--pks', dest='primary_keys', action='append', default=[], help="Only dump objects with given primary keys. Accepts a comma seperated list of keys. This option will only work when you specify one model."), make_option('--pks', dest='primary_keys', help="Only dump objects with " "given primary keys. Accepts a comma seperated list of keys. " "This option will only work when you specify one model."), ) help = ("Output the contents of the database as a fixture of the given " "format (using each model's default manager unless --all is " Loading @@ -44,7 +45,7 @@ class Command(BaseCommand): if pks: primary_keys = pks.split(',') else: primary_keys = False primary_keys = [] excluded_apps = set() excluded_models = set() Loading
tests/admin_scripts/tests.py +19 −0 Original line number Diff line number Diff line Loading @@ -1682,3 +1682,22 @@ class DiffSettings(AdminScriptTestCase): out, err = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, "### STATIC_URL = None") class Dumpdata(AdminScriptTestCase): """Tests for dumpdata management command.""" def setUp(self): self.write_settings('settings.py') def tearDown(self): self.remove_settings('settings.py') def test_pks_parsing(self): """Regression for #20509 Test would raise an exception rather than printing an error message. """ args = ['dumpdata', '--pks=1'] out, err = self.run_manage(args) self.assertOutput(err, "You can only use --pks option with one model") self.assertNoOutput(out)
tests/fixtures/tests.py +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ class TestCaseFixtureLoadingTests(TestCase): class DumpDataAssertMixin(object): def _dumpdata_assert(self, args, output, format='json', natural_keys=False, use_base_manager=False, exclude_list=[], primary_keys=[]): use_base_manager=False, exclude_list=[], primary_keys=''): new_io = six.StringIO() management.call_command('dumpdata', *args, **{'format': format, 'stdout': new_io, Loading