summaryrefslogtreecommitdiff
path: root/tests/tox_env/python/test_python_api.py
diff options
context:
space:
mode:
authorBernát Gábor <bgabor8@bloomberg.net>2021-04-05 00:59:13 +0100
committerGitHub <noreply@github.com>2021-04-05 00:59:13 +0100
commit18a95899444372822a4a6063a471e865f8c58edf (patch)
tree60c832841a5ab3ef64b673c5b337be9fc3181841 /tests/tox_env/python/test_python_api.py
parent54e6310f5376c7bd7e2b4871c700fe00cabf1c32 (diff)
downloadtox-git-18a95899444372822a4a6063a471e865f8c58edf.tar.gz
Start plugin interface documentation and installer (#1991)
- Add documentation for the plugin interface - Introduce the installer abstraction - Rework how we handle tox deps section, requirement and constraint files - Support for escaping comments in tox.ini configs Signed-off-by: Bernát Gábor <gaborjbernat@gmail.com>
Diffstat (limited to 'tests/tox_env/python/test_python_api.py')
-rw-r--r--tests/tox_env/python/test_python_api.py58
1 files changed, 17 insertions, 41 deletions
diff --git a/tests/tox_env/python/test_python_api.py b/tests/tox_env/python/test_python_api.py
index 66ccf2bb..722d5db6 100644
--- a/tests/tox_env/python/test_python_api.py
+++ b/tests/tox_env/python/test_python_api.py
@@ -3,40 +3,10 @@ from pathlib import Path
from typing import Callable, Tuple
import pytest
-from packaging.requirements import Requirement
from pytest_mock import MockerFixture
from tox.pytest import ToxProjectCreator
-from tox.tox_env.python.api import Python, PythonDep
-
-
-def test_deps_path_eq() -> None:
- dep_1 = PythonDep(Path.cwd())
- dep_2 = PythonDep(Path.cwd())
- assert dep_1 == dep_2
-
-
-def test_deps_path_ne() -> None:
- dep_1 = PythonDep(Path.cwd())
- dep_2 = PythonDep(Path.cwd() / "a")
- assert dep_1 != dep_2
-
-
-def test_deps_req_eq() -> None:
- dep_1 = PythonDep(Requirement("pytest"))
- dep_2 = PythonDep(Requirement("pytest"))
- assert dep_1 == dep_2
-
-
-def test_deps_req_ne() -> None:
- dep_1 = PythonDep(Requirement("pytest"))
- dep_2 = PythonDep(Requirement("tox"))
- assert dep_1 != dep_2
-
-
-def test_deps_repr() -> None:
- dep_1 = PythonDep(Path.cwd())
- assert repr(dep_1) == f"PythonDep(value={Path.cwd()!r})"
+from tox.tox_env.python.api import Python
def test_requirements_txt(tox_project: ToxProjectCreator) -> None:
@@ -51,7 +21,7 @@ def test_requirements_txt(tox_project: ToxProjectCreator) -> None:
result.assert_success()
assert execute_calls.call_count == 1
- exp = ["python", "-I", "-m", "pip", "install", "nose"]
+ exp = ["python", "-I", "-m", "pip", "install", "-r", "requirements.txt"]
got_cmd = execute_calls.call_args[0][3].cmd
assert got_cmd == exp
@@ -73,19 +43,25 @@ def test_build_wheel_in_non_base_pkg_env(
mocker.patch("tox.tox_env.python.virtual_env.api.session_via_cli")
prev_ver, impl = patch_prev_py(True)
prev_py = f"py{prev_ver}"
- pkg_env = f".pkg-{impl}{prev_ver}"
prj = tox_project({"tox.ini": f"[tox]\nenv_list= {prev_py}\n[testenv]\npackage=wheel"})
execute_calls = prj.patch_execute(lambda r: 0 if "install" in r.run_id else None)
result = prj.run("-r", "--root", str(demo_pkg_inline))
result.assert_success()
calls = [(i[0][0].conf.name, i[0][3].run_id) for i in execute_calls.call_args_list]
assert calls == [
- (".pkg", "get_requires_for_build_wheel"),
- (".pkg", "prepare_metadata_for_build_wheel"),
- (".pkg", "build_wheel"),
- (pkg_env, "get_requires_for_build_wheel"),
- (pkg_env, "build_wheel"),
- (pkg_env, "_exit"),
- (prev_py, "install_package"),
- (".pkg", "_exit"),
+ (f".pkg-{impl}{prev_ver}", "get_requires_for_build_wheel"),
+ (f".pkg-{impl}{prev_ver}", "build_wheel"),
+ (f"py{prev_ver}", "install_package"),
+ (f".pkg-{impl}{prev_ver}", "_exit"),
]
+
+
+def test_diff_msg_added_removed_changed() -> None:
+ before = {"A": "1", "F": "8", "C": "3", "D": "4", "E": "6"}
+ after = {"G": "9", "B": "2", "C": "3", "D": "5", "E": "7"}
+ expected = "python added A='1' | F='8', removed G='9' | B='2', changed D='4'->'5' | E='6'->'7'"
+ assert Python._diff_msg(before, after) == expected
+
+
+def test_diff_msg_no_diff() -> None:
+ assert Python._diff_msg({}, {}) == "python "