Describe the bug
Tests crash in a counterintuitive way when attempting to autouse a fixture which uses fs_session
Is this a limitation?
command_name = 'migrate', args = ()
options = {'database': 'default', 'interactive': False, 'run_syncdb': True, 'verbosity': 0}
def call_command(command_name, *args, **options):
"""
Call the given command, with the given options and args/kwargs.
This is the primary API you should use for calling specific commands.
`command_name` may be a string or a command object. Using a string is
preferred unless the command object is required for further processing or
testing.
Some examples:
call_command('migrate')
call_command('shell', plain=True)
call_command('sqlmigrate', 'myapp')
from django.core.management.commands import flush
cmd = flush.Command()
call_command(cmd, verbosity=0, interactive=False)
# Do something with cmd ...
"""
if isinstance(command_name, BaseCommand):
# Command object passed in.
command = command_name
command_name = command.__class__.__module__.split(".")[-1]
else:
# Load the command object by name.
try:
app_name = get_commands()[command_name]
except KeyError:
raise CommandError("Unknown command: %r" % command_name)
E django.core.management.base.CommandError: Unknown command: 'migrate'
see full stack trace in the attachment.
trace.txt
How To Reproduce
The following minimal test case will probably produce the above result in any django project.
from django.contrib.auth.models import User
import pytest
@pytest.fixture(
# remove this line and the test passes
autouse=True
)
def auto_use_fake_fs(fs_session):
yield
def test_fake_fs(db, auto_use_fake_fs):
User.objects.create()
Your environment
Linux-6.14.0-37-generic-x86_64-with-glibc2.39
Python 3.12.3 (main, Nov 6 2025, 13:44:16) [GCC 13.3.0]
pyfakefs 6.0.0
pytest 9.0.2
django==6.0
pytest-django==4.11.1
pyfakefs==6.0.0
Describe the bug
Tests crash in a counterintuitive way when attempting to autouse a fixture which uses fs_session
Is this a limitation?
see full stack trace in the attachment.
trace.txt
How To Reproduce
The following minimal test case will probably produce the above result in any django project.
Your environment
Linux-6.14.0-37-generic-x86_64-with-glibc2.39
Python 3.12.3 (main, Nov 6 2025, 13:44:16) [GCC 13.3.0]
pyfakefs 6.0.0
pytest 9.0.2
django==6.0
pytest-django==4.11.1
pyfakefs==6.0.0