From 91b8380cc053d25ccd36711e6f857d8e459296ea Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Sat, 20 Jul 2024 11:57:09 -0400 Subject: [PATCH] test: Try changing Python path --- .github/workflows/tests.yml | 4 ++-- pyproject.toml | 3 +++ tests/conftest.py | 3 +++ tests/mockserver.py | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 448777c1..9d0f0818 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: cache-dependency-path: setup.py - run: pip install -e .[test] - if: matrix.python-version != 'pypy-3.9' || matrix.os != 'windows-latest' - run: pytest tests --cov scrapyd + run: python -m pytest tests --cov scrapyd - if: matrix.python-version != 'pypy-3.9' || matrix.os != 'macos-latest' name: Run integration tests run: | @@ -25,7 +25,7 @@ jobs: mkdir logs scrapyd > scrapyd.log 2>&1 & sleep 1 - pytest integration_tests + python -m pytest integration_tests cat scrapyd.log - env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 583ce628..95ed445f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ +[tool.pytest.ini_options] +pythonpaths = ["."] + [tool.ruff] line-length = 119 target-version = "py38" diff --git a/tests/conftest.py b/tests/conftest.py index c0b21f83..b0acdf08 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,5 @@ +import sys + import pytest from twisted.web import http from twisted.web.http import Request @@ -19,6 +21,7 @@ def txrequest(): # Use this fixture when testing the Scrapyd web UI or API or writing configuration files. @pytest.fixture() def chdir(monkeypatch, tmpdir): + print(sys.path) # noqa: T201 for debugging in CI return monkeypatch.chdir(tmpdir) diff --git a/tests/mockserver.py b/tests/mockserver.py index d0d55ef2..e6d4d001 100644 --- a/tests/mockserver.py +++ b/tests/mockserver.py @@ -18,8 +18,8 @@ class MockScrapydServer: def __init__(self, authentication=None): self.authentication = authentication - def __enter__(self, authentication=None): - """Launch Scrapyd application object with ephemeral port""" + def __enter__(self): + print(sys.path) # noqa: T201 for debugging in CI command = [sys.executable, "-m", "tests.start_mock_app", get_ephemeral_port()] if self.authentication is not None: command.append("--auth=" + self.authentication)