Skip to content

Commit

Permalink
use django 3&4
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Jan 4, 2024
1 parent 74000da commit 9022218
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import shutil
import sys
import textwrap
from pathlib import Path

import py
import pytest
from tox import __version__ as TOX_VERSION

FIX_PROJECT = py.path.local(__file__).dirpath("fixture-project")
IS_TOX_4 = TOX_VERSION[0] == "4"
FIX_PROJECT = Path(__file__).with_name("fixture-project")


@pytest.fixture(autouse=True)
Expand All @@ -18,25 +17,20 @@ def clean_env(monkeypatch):

def setup_project(tmpdir, tox_config):
for filename in ("demo.py", "pdm.lock", "pyproject.toml"):
FIX_PROJECT.join(filename).copy(tmpdir.join(filename))
shutil.copy(FIX_PROJECT / filename, tmpdir)
with tmpdir.join("tox.ini").open("w", ensure=True) as f:
f.write(tox_config)
with tmpdir.join(".pdm.toml").open("w", ensure=True) as f:
f.write(
"""[python]
path = "{}"
""".format(
sys.executable.replace("\\", "/")
)
""".format(sys.executable.replace("\\", "/"))
)


def execute_config(tmpdir, config: str):
__tracebackhide__ = True
if IS_TOX_4:
from tox.run import run as main
else:
from tox.session import main
from tox.run import run as main

setup_project(tmpdir, textwrap.dedent(config))

Expand All @@ -50,10 +44,7 @@ def execute_config(tmpdir, config: str):
if code != 0:
pytest.fail(f"non-zero exit code: {code}")

if TOX_VERSION[0] == "4":
package = tmpdir.join(".tox/.pkg/dist/demo-0.1.0.tar.gz")
else:
package = tmpdir.join(".tox/dist/demo-0.1.0.tar.gz")
package = tmpdir.join(".tox/.pkg/dist/demo-0.1.0.tar.gz")
assert package.exists()


Expand All @@ -62,16 +53,16 @@ def test_install_conditional_deps(tmpdir):
tmpdir,
"""
[tox]
envlist = django{2,3}
envlist = django{3,4}
passenv = LD_PRELOAD
isolated_build = True
[testenv]
groups =
lint
deps =
django2: Django~=2.0
django3: Django~=3.0
django2: Django~=3.0
django3: Django~=4.0
commands =
django-admin --version
flake8 --version
Expand Down

0 comments on commit 9022218

Please sign in to comment.