Skip to content
Merged
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
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ jobs:
image: [linux, windows, macOs]
py27:
image: [linux, windows, macOs]
pypy:
image: [linux]
pypy3:
image: [linux]
py36:
image: [linux, windows, macOs]
py35:
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1378.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``current_tox_py`` for ``pypy`` / ``pypy3`` - by :user:`asottile`
2 changes: 1 addition & 1 deletion src/tox/_pytestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def build_session(config):
def current_tox_py():
"""generate the current (test runners) python versions key
e.g. py37 when running under Python 3.7"""
return "py{}".format("".join(str(i) for i in sys.version_info[0:2]))
return "{}{}{}".format("pypy" if tox.INFO.IS_PYPY else "py", *sys.version_info)


def pytest_runtest_setup(item):
Expand Down
103 changes: 54 additions & 49 deletions tests/integration/test_package_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ def test_package_setuptools(initproj, cmd):
initproj(
"magic-0.1",
filedefs={
"tox.ini": """
[tox]
isolated_build = true
[testenv:.package]
basepython = python
""",
"pyproject.toml": """
[build-system]
requires = ["setuptools >= 35.0.2", "setuptools_scm >= 2.0.0, <3"]
build-backend = "setuptools.build_meta"
""",
"tox.ini": """\
[tox]
isolated_build = true
[testenv:.package]
basepython = {}
""".format(
sys.executable
),
"pyproject.toml": """\
[build-system]
requires = ["setuptools >= 35.0.2", "setuptools_scm >= 2.0.0, <3"]
build-backend = "setuptools.build_meta"
""",
},
)
run(cmd, "magic-0.1.tar.gz")
Expand All @@ -37,26 +39,28 @@ def test_package_flit(initproj, cmd):
initproj(
"magic-0.1",
filedefs={
"tox.ini": """
[tox]
isolated_build = true
[testenv:.package]
basepython = python
""",
"pyproject.toml": """
[build-system]
requires = ["flit"]
build-backend = "flit.buildapi"

[tool.flit.metadata]
module = "magic"
author = "Happy Harry"
author-email = "happy@harry.com"
home-page = "https://github.com/happy-harry/is"
requires = [
"tox",
]
""",
"tox.ini": """\
[tox]
isolated_build = true
[testenv:.package]
basepython = {}
""".format(
sys.executable
),
"pyproject.toml": """\
[build-system]
requires = ["flit"]
build-backend = "flit.buildapi"

[tool.flit.metadata]
module = "magic"
author = "Happy Harry"
author-email = "happy@harry.com"
home-page = "https://github.com/happy-harry/is"
requires = [
"tox",
]
""",
".gitignore": ".tox",
},
add_missing_setup_py=False,
Expand All @@ -78,24 +82,25 @@ def test_package_poetry(initproj, cmd):
initproj(
"magic-0.1",
filedefs={
"tox.ini": """
[tox]
isolated_build = true
[testenv:.package]
basepython = python
""",
"pyproject.toml": """
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.poetry]
name = "magic"
version = "0.1.0"
description = ""
authors = ["Name <email@email.com>"]

""",
"tox.ini": """\
[tox]
isolated_build = true
[testenv:.package]
basepython = {}
""".format(
sys.executable
),
"pyproject.toml": """\
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.poetry]
name = "magic"
version = "0.1.0"
description = ""
authors = ["Name <email@email.com>"]
""",
".gitignore": ".tox",
},
add_missing_setup_py=False,
Expand Down
16 changes: 10 additions & 6 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,17 +1909,21 @@ def test_default_factors(self, newconfig):

def test_default_factors_conflict(self, newconfig, capsys):
with pytest.warns(UserWarning, match=r"conflicting basepython .*"):
exe = "pypy3" if tox.INFO.IS_PYPY else "python3"
env = "pypy27" if tox.INFO.IS_PYPY else "py27"
config = newconfig(
"""
"""\
[testenv]
basepython=python3
[testenv:py27]
basepython={}
[testenv:{}]
commands = python --version
"""
""".format(
exe, env
)
)
assert len(config.envconfigs) == 1
envconfig = config.envconfigs["py27"]
assert envconfig.basepython == "python3"
envconfig = config.envconfigs[env]
assert envconfig.basepython == exe

def test_default_factors_conflict_lying_name(
self, newconfig, capsys, tmpdir, recwarn, monkeypatch
Expand Down
1 change: 1 addition & 0 deletions tests/unit/interpreters/test_interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def create_interpreters_instance():
return Interpreters(hook=pm.hook)


@pytest.mark.skipif(tox.INFO.IS_PYPY, reason="testing cpython interpreter discovery")
def test_tox_get_python_executable():
class envconfig:
basepython = sys.executable
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,8 @@ def test_install_command_not_installed_bash(newmocksession):


def test_install_python3(newmocksession):
if not py.path.local.sysfind("python3"):
pytest.skip("needs python3")
if not py.path.local.sysfind("python3") or tox.INFO.IS_PYPY:
pytest.skip("needs cpython3")
mocksession = newmocksession(
[],
"""\
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/test_z_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,11 +784,13 @@ def test_notest(initproj, cmd):
initproj(
"example123",
filedefs={
"tox.ini": """
# content of: tox.ini
[testenv:py26]
basepython=python
"""
"tox.ini": """\
# content of: tox.ini
[testenv:py26]
basepython={}
""".format(
sys.executable
)
},
)
result = cmd("-v", "--notest")
Expand Down