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

[TEST] DO NOT MERGE #597

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import pytest
import vcr
from django.conf import settings
from pytest_django.fixtures import _set_suffix_to_test_databases
from pytest_django.lazy_django import skip_if_no_django
from shared.reports.resources import Report, ReportFile, ReportLine
from shared.utils.sessions import Session

Expand All @@ -22,6 +24,17 @@ def pytest_configure(config):
pass


@pytest.fixture(scope="session")
def django_db_modify_db_settings_xdist_suffix(request):
skip_if_no_django()

xdist_suffix = getattr(request.config, "workerinput", {}).get("workerid")
if xdist_suffix:
# 'gw0' -> '1', 'gw1' -> '2', ...
suffix = str(int(xdist_suffix.replace("gw", "")) + 1)
_set_suffix_to_test_databases(suffix=suffix)


@pytest.fixture
def codecov_vcr(request):
current_path = Path(request.node.fspath)
Expand All @@ -48,7 +61,7 @@ def mock_redis(mocker):
yield redis_server


@pytest.fixture(scope="class")
@pytest.fixture
def sample_report(request):
report = Report()
first_file = ReportFile("foo/file1.py")
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE = codecov.settings_dev
addopts = -p no:warnings --ignore=shared --ignore-glob=**/test_results*
addopts = --reuse-db -n 3 --dist no -p no:warnings --ignore=shared --ignore-glob=**/test_results*
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pytest-cov
pytest-django
pytest-mock
pytest-asyncio
pytest-xdist
python-dateutil
python-json-logger
python-redis-lock
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ elastic-apm==6.13.2
# via -r requirements.in
envier==0.5.1
# via ddtrace
execnet==2.1.1
# via pytest-xdist
factory-boy==3.2.0
# via -r requirements.in
faker==4.1.3
Expand Down Expand Up @@ -349,6 +351,7 @@ pytest==8.1.1
# pytest-cov
# pytest-django
# pytest-mock
# pytest-xdist
pytest-asyncio==0.23.6
# via -r requirements.in
pytest-cov==5.0.0
Expand All @@ -357,6 +360,8 @@ pytest-django==4.8.0
# via -r requirements.in
pytest-mock==3.14.0
# via -r requirements.in
pytest-xdist==3.6.1
# via -r requirements.in
python-dateutil==2.9.0.post0
# via
# -r requirements.in
Expand Down
2 changes: 1 addition & 1 deletion webhook_handlers/tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __getitem__(self, key):


class GithubWebhookHandlerTests(APITestCase):
@pytest.fixture(scope="function", autouse=True)
@pytest.fixture(autouse=True)
def inject_mocker(request, mocker):
request.mocker = mocker

Expand Down
2 changes: 1 addition & 1 deletion webhook_handlers/tests/test_gitlab_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class TestGitlabEnterpriseWebhookHandler(APITestCase):
@pytest.fixture(scope="function", autouse=True)
@pytest.fixture(autouse=True)
def inject_mocker(request, mocker):
request.mocker = mocker

Expand Down
Loading