mirror of
https://github.com/fedora-python/tox-current-env.git
synced 2025-01-11 00:46:15 +01:00
Support report of installed packages in CI (#64)
* Support report of installed packages in CI Fixes: https://github.com/fedora-python/tox-current-env/issues/63 Co-authored-by: Miro Hrončok <miro@hroncok.cz>
This commit is contained in:
parent
bf900a5c7c
commit
daf3872164
@ -15,6 +15,11 @@ from tox.plugin import impl
|
||||
from tox.tox_env.python.api import PythonInfo
|
||||
from tox.tox_env.python.runner import PythonRun
|
||||
|
||||
try:
|
||||
import importlib.metadata as importlib_metadata
|
||||
except ImportError:
|
||||
import importlib_metadata
|
||||
|
||||
|
||||
@impl
|
||||
def tox_register_tox_env(register):
|
||||
@ -106,6 +111,15 @@ class Installer:
|
||||
def install(self, *args, **kwargs):
|
||||
return None
|
||||
|
||||
def installed(self):
|
||||
"""Return list of installed packages like `pip freeze`."""
|
||||
return [
|
||||
"{}=={}".format(d.metadata.get("name"), d.version)
|
||||
for d in sorted(
|
||||
importlib_metadata.distributions(), key=lambda d: d.metadata.get("name")
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class CurrentEnvLocalSubProcessExecutor(Execute):
|
||||
def build_instance(
|
||||
|
@ -421,3 +421,12 @@ def test_pass_env(projdir, pass_env):
|
||||
assert result.returncode == 0
|
||||
assert "\nassertme\n" in result.stdout
|
||||
assert "\nNone\n" not in result.stdout
|
||||
|
||||
|
||||
def test_report_installed(projdir):
|
||||
# tox4 only reports installed when a CI is detected
|
||||
env = {"CI": "true"}
|
||||
result = tox("-e", NATIVE_TOXENV, "--current-env", env=env, quiet=False)
|
||||
assert result.returncode == 0
|
||||
assert "tox==" in result.stdout
|
||||
assert "pytest==" in result.stdout
|
||||
|
Loading…
Reference in New Issue
Block a user