loud-laptop-17949
12/10/2021, 8:47 PMCreating test database for alias 'default'...
and a working database. When running the same tests with pants, the django testing framework does not appear to create the test database. Am I missing something obvious here?witty-crayon-22786
12/10/2021, 8:57 PMhappy-kitchen-89482
12/10/2021, 9:01 PMhappy-kitchen-89482
12/10/2021, 9:01 PMhappy-kitchen-89482
12/10/2021, 9:02 PMloud-laptop-17949
12/10/2021, 9:05 PMloud-laptop-17949
12/10/2021, 9:05 PMloud-laptop-17949
12/10/2021, 9:05 PMclean-city-64472
12/10/2021, 11:21 PM[pytest]
execution_slot_var = "PANTS_PROCESS_EXECUTION_SLOT"
extra_requirements = [
"pytest-django==4.4.0",
]
The other important piece is conftest.py
import importlib.util
import os
import pytest
def _set_suffix_to_test_databases(suffix):
from django.conf import settings
for db_settings in settings.DATABASES.values():
db_settings.setdefault("TEST", {})
db_settings["TEST"]["NAME"] = "test_dealroom_{}".format(suffix)
def pytest_cmdline_preparse(args):
if importlib.util.find_spec("clofo.dealroom.dealroom") is not None:
args[:] = args + ["--reuse-db"]
def pytest_configure(config):
if importlib.util.find_spec("clofo.dealroom.dealroom") is not None:
from django.conf import settings
os.environ["DJANGO_SETTINGS_MODULE"] = "clofo.dealroom.dealroom.pytest_settings"
settings.DATABASES
clean-city-64472
12/10/2021, 11:22 PMfixtures
that are provided by pytest-django
package to bootstrap one database per process execution slot.clean-city-64472
12/10/2021, 11:22 PMfind_spec
thing is to avoid running this code if we aren't actually testing anything related to our django apphappy-kitchen-89482
12/11/2021, 3:47 AMhundreds-father-404
12/13/2021, 7:41 PMi am considering trying to just get it working with plain pytest first before trying to move to pants@loud-laptop-17949 you can use
./pants peek
+ skip_tests
to incrementally port your test suite to Pants https://www.pantsbuild.org/docs/existing-repositories#3-set-up-tests