Skip to content

Commit

Permalink
Add ignore_dependencies configuration option and bump version to 2.0.…
Browse files Browse the repository at this point in the history
…9dev0
  • Loading branch information
tarpas committed May 30, 2023
1 parent d99dfa8 commit 6be91ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion testmon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""PYTEST_DONT_REWRITE"""
VERSION = "2.0.8"
VERSION = "2.0.9dev0"
18 changes: 12 additions & 6 deletions testmon/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@

def get_system_packages_raw():
return (
f"{pkg.metadata['Name']} {pkg.version}"
(pkg.metadata["Name"], pkg.version)
for pkg in importlib.metadata.distributions()
)

except ImportError:
import pkg_resources

def get_system_packages_raw():
return (
f"{pkg.project_name} {pkg.version}" for pkg in pkg_resources.working_set
)
return ((pkg.project_name, pkg.version) for pkg in pkg_resources.working_set)


from pathlib import Path
Expand All @@ -35,8 +33,16 @@ def get_logger(name):
logger = get_logger(__name__)


def get_system_packages():
return ", ".join(sorted(set(get_system_packages_raw())))
def get_system_packages(ignore=None):
return ", ".join(
sorted(
{
f"{package} {version}"
for (package, version) in get_system_packages_raw()
if not ignore or not package in ignore
}
)
)


def drop_patch_version(system_packages):
Expand Down
7 changes: 6 additions & 1 deletion testmon/pytest_testmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def pytest_addoption(parser):
)

parser.addini("environment_expression", "environment expression", default="")
parser.addini("ignore_dependencies", "ignore dependencies", default=[])
parser.addini("testmon_url", "URL of the testmon.net api server.")
parser.addini("tmnet_api_key", "testmon api key")

Expand All @@ -131,7 +132,11 @@ def init_testmon_data(config):
environment = config.getoption("environment_expression") or eval_environment(
config.getini("environment_expression")
)
system_packages = get_system_packages()
ignore_dependencies_str = config.getini("ignore_dependencies")
ignore_dependencies = (
ignore_dependencies_str.split("\n") if ignore_dependencies_str else None
)
system_packages = get_system_packages(ignore=ignore_dependencies)

url = config.getini("testmon_url")
rpc_proxy = None
Expand Down

0 comments on commit 6be91ed

Please sign in to comment.