Skip to content

Commit

Permalink
Big refactoring. Start of v2 development. pytest-testmon will become …
Browse files Browse the repository at this point in the history
…a client for testmon.net .
  • Loading branch information
tarpas committed Jan 20, 2023
1 parent f914f15 commit 6746483
Show file tree
Hide file tree
Showing 8 changed files with 562 additions and 362 deletions.
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include README.md
include LICENSE
prune tests/
prune tests
prune tox.ini
prune tmserver
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pytest-testmon
version = 1.4.5
version = 2.0.0a0
license = AGPL
author_email = [email protected]
author = Tibor Arpas, Tomas Matlovic
Expand All @@ -14,6 +14,7 @@ platforms =
linux
osx
win32

classifiers =
Development Status :: 4 - Beta
Intended Audience :: Developers
Expand Down
2 changes: 2 additions & 0 deletions testmon/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def dumy():
pass
50 changes: 28 additions & 22 deletions testmon/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
except ImportError:
from coverage.pytracer import PyTracer as Tracer

from dataclasses import dataclass


def _is_dogfooding(coverage_stack):
return coverage_stack
Expand All @@ -19,36 +21,25 @@ def _is_coverage():
return False


def _deactivate_on_xdist(options):
return False
return (
options.get("numprocesses", False)
or options.get("distload", False)
or options.get("dist", "no") != "no"
)


def _get_notestmon_reasons(options, xdist):
def _get_notestmon_reasons(options):
if options["no-testmon"]:
return "deactivated through --no-testmon"

if options["testmon_noselect"] and options["testmon_nocollect"]:
return "deactivated, both noselect and nocollect options used"

if not any(
options[t]
options.get(t, False)
for t in [
"testmon",
"testmon_noselect",
"testmon_nocollect",
"testmon_forceselect",
"tmnet",
]
):
return "not mentioned"

if xdist:
return "deactivated, execution with xdist is not supported"

return None


Expand Down Expand Up @@ -106,20 +97,35 @@ def _formulate_deactivation(what, reasons):
return []


@dataclass
class TmConf:
message: str
collect: bool
select: bool
tmnet: bool = False

def __eq__(self, other):
return (
self.message == other.message
and self.collect == other.collect
and self.select == other.select
and self.tmnet == other.tmnet
)


def _header_collect_select(
options,
debugger=False,
coverage=False,
dogfooding=False,
xdist=False,
cov_plugin=False,
):
notestmon_reasons = _get_notestmon_reasons(options, xdist=xdist)
) -> TmConf:
notestmon_reasons = _get_notestmon_reasons(options)

if notestmon_reasons == "not mentioned":
return None, False, False
return TmConf(None, False, False)
if notestmon_reasons:
return "testmon: " + notestmon_reasons, False, False
return TmConf("testmon: " + notestmon_reasons, False, False)

nocollect_reasons = _get_nocollect_reasons(
options,
Expand All @@ -139,20 +145,20 @@ def _header_collect_select(
else:
message = ""

return (
return TmConf(
f"testmon: {message}",
not bool(nocollect_reasons),
not bool(noselect_reasons),
bool(options.get("tmnet")),
)


def header_collect_select(config, coverage_stack, cov_plugin=None):
def header_collect_select(config, coverage_stack, cov_plugin=None) -> TmConf:
options = vars(config.option)
return _header_collect_select(
options,
debugger=_is_debugger(),
coverage=_is_coverage(),
dogfooding=_is_dogfooding(coverage_stack),
xdist=_deactivate_on_xdist(options),
cov_plugin=cov_plugin,
)
Loading

0 comments on commit 6746483

Please sign in to comment.