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

Fix env-var name for parallel tox tests #1112

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

meshy
Copy link
Contributor

@meshy meshy commented Feb 9, 2024

When running tests in parallel, we need to add a suffix to Django DB names to avoid clashes. This previously used TOX_PARALLEL_ENV, but Tox no longer sets this environment variable.

Tox does set an environment variable called TOX_ENV_NAME, which works for this purpose, so use that instead.


I was able to get my local Tox tests running in parallel using this fixture, and it seemed as though the version in this repo should be updated.

import os
import pytest
from pytest_django import fixtures


@pytest.fixture(scope="session")
def django_db_modify_db_settings_tox_suffix() -> None:
    fixtures.skip_if_no_django()

    tox_environment = os.getenv("TOX_ENV_NAME")
    if tox_environment:
        fixtures._set_suffix_to_test_databases(suffix=tox_environment)

@meshy meshy marked this pull request as draft February 9, 2024 18:34
When running tests in parallel, we need to add a suffix to Django DB names to avoid clashes. This previously used `TOX_PARALLEL_ENV`, but Tox no longer sets this environment variable.

Tox does set an environment variable called `TOX_ENV_NAME`, which works for this purpose, so use that instead.
@meshy
Copy link
Contributor Author

meshy commented Feb 9, 2024

Oh dear, this broke more tests that I accounted for.
I've moved this into draft for now.

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

Successfully merging this pull request may close these issues.

1 participant