Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 1.10 error: No fixture named 'django_admin_smoke_tests' found #9

Open
jcushman opened this issue Sep 9, 2016 · 3 comments · May be fixed by #16 or #21
Open

Django 1.10 error: No fixture named 'django_admin_smoke_tests' found #9

jcushman opened this issue Sep 9, 2016 · 3 comments · May be fixed by #16 or #21

Comments

@jcushman
Copy link
Contributor

jcushman commented Sep 9, 2016

Django 1.10 appears to throw an error if a fixture cannot be found, which breaks the default setup described in the README. This isn't fixed by the #8 pull request.

Following the install instructions from README results in this error:

Traceback (most recent call last):
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/test/testcases.py", line 209, in __call__
    self._pre_setup()
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/test/testcases.py", line 839, in _pre_setup
    self._fixture_setup()
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/test/testcases.py", line 895, in _fixture_setup
    **{'verbosity': 0, 'database': db_name})
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 130, in call_command
    return command.execute(*args, **defaults)
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 64, in handle
    self.loaddata(fixture_labels)
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 97, in loaddata
    if self.find_fixtures(fixture_label):
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper
    result = user_function(*args, **kwds)
  File "/home/vagrant/.virtualenvs/perma/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 253, in find_fixtures
    raise CommandError("No fixture named '%s' found." % fixture_name)
CommandError: No fixture named 'django_admin_smoke_tests' found.

The workaround is either for the user to provide a django_admin_smoke_tests fixture (which isn't documented), or to override fixtures in the test class.

It looks like the tests are passing in the sample project because they all set fixtures = [], which doesn't seem ideal. Probably would be better to override _fixture_setup to only include the fixture if it exists, although I haven't worked out how to do that.

@jcushman
Copy link
Contributor Author

jcushman commented Sep 9, 2016

Actually, I think the best thing would be to remove the fixtures = ['django_admin_smoke_test'] line in the first place.

  • It's an undocumented feature.
  • It adds auto-magic configuration that will be confusing for projects that use it, without saving much code.
  • It causes AdminSiteSmokeTestMixin to block fixtures from the base model. For example:
class MyBaseTestCase(TransactionTestCase):
    fixtures = ['fixtures/test.json',]

class AdminTestCase(AdminSiteSmokeTestMixin, MyBaseTestCase):
    pass
    # surprise! fixtures/test.json is not loaded

@SeanHayes
Copy link
Member

That's a good point about it blocking other fixtures.

Feel free to submit a PR removing this feature. Include a note in the README mentioning that it's been removed, since it was requested by another user of this lib.

@jnoortheen jnoortheen linked a pull request Apr 27, 2018 that will close this issue
@tolomea
Copy link

tolomea commented Sep 5, 2020

I'm seeing this on Django 2.2

Creating a "fixtures/django_admin_smoke_tests.json" file containing just "[]" in one of my apps fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants