Skip to content

Commit

Permalink
Bump to v1.0.3 and minor formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
tarpas committed Aug 5, 2020
1 parent 73ba0ea commit 176600d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 38 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
name="pytest-testmon",
description="selects tests affected by changed files and methods",
long_description=long_description,
version="1.0.2",
version="1.0.3",
license="AGPL",
platforms=["linux", "osx", "win32"],
packages=["testmon",],
Expand Down
8 changes: 4 additions & 4 deletions t.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

if __name__ == '__main__':
if __name__ == "__main__":
# test/test_testmon.py::TestmonDeselect::test_nonfunc_class
# test/test_testmon.py::TestmonDeselect::test_tlf
pytest.main("--tb=native -v" )
#pytest.main("-v -n 2 --tx=popen//python=python3")
#pytest.main("--help -v")
pytest.main("--tb=native -v")
# pytest.main("-v -n 2 --tx=popen//python=python3")
# pytest.main("--help -v")
11 changes: 3 additions & 8 deletions testmon/pytest_testmon.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import os
from collections import defaultdict

Expand Down Expand Up @@ -76,7 +75,6 @@ def pytest_addoption(parser):
""",
)


group.addoption(
"--testmon-env",
action="store",
Expand Down Expand Up @@ -118,14 +116,12 @@ def pytest_configure(config):

plugin = None


testmon_config = TestmonConfig()
message, should_collect, should_select = testmon_config.header_collect_select(
config, coverage_stack, cov_plugin=plugin
)
config.testmon_config = (message, should_collect, should_select)
if should_select or should_collect:
config.option.continue_on_collection_errors = True

try:
init_testmon_data(config)
Expand Down Expand Up @@ -207,7 +203,7 @@ def sort_items_by_duration(items, reports):

class TestmonCollect(object):
def __init__(self, testmon, testmon_data):
self.testmon_data = testmon_data
self.testmon_data: TestmonData = testmon_data
self.testmon = testmon

self.reports = defaultdict(lambda: {})
Expand Down Expand Up @@ -274,14 +270,13 @@ def get_failing(all_nodes):

class TestmonSelect:
def __init__(self, config, testmon_data):
self.testmon_data = testmon_data
self.testmon_data: TestmonData = testmon_data
self.config = config

self.deselected_files = testmon_data.stable_files
self.deselected_nodes = testmon_data.stable_nodeids

failing_files, failing_nodes = get_failing(testmon_data.all_nodes)

_, failing_nodes = get_failing(testmon_data.all_nodes)

self.failing_nodes = failing_nodes

Expand Down
28 changes: 3 additions & 25 deletions testmon/testmon_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ def blob_to_checksums(blob):
return a.tolist()




class cached_property(object):


def __init__(self, func):
self.__doc__ = getattr(func, "__doc__")
self.func = func
Expand All @@ -53,7 +49,6 @@ def __get__(self, obj, cls):
return value



def _get_python_lib_paths():
res = [sys.prefix]
for attr in ["exec_prefix", "real_prefix", "base_prefix"]:
Expand All @@ -75,9 +70,7 @@ def is_python_file(file_path):


def get_measured_relfiles(rootdir, cov, test_file):
files = {
test_file: set()
}
files = {test_file: set()}
c = cov.config
for filename in cov.get_data().measured_files():
if not is_python_file(filename):
Expand All @@ -96,8 +89,6 @@ class TestmonException(Exception):


class SourceTree:


def __init__(self, rootdir=""):
self.rootdir = rootdir
self.cache = {}
Expand Down Expand Up @@ -359,7 +350,6 @@ def write_node_data(self, nodeid, nodedata, result={}, fake=False):
)
node_id = cursor.lastrowid


for filename in nodedata:
if fake:
mtime, checksum = None, None
Expand All @@ -382,9 +372,7 @@ def write_node_data(self, nodeid, nodedata, result={}, fake=False):
(filename, fingerprint,),
).fetchone()

if (
db_checksum != checksum or db_mtime != mtime
):
if db_checksum != checksum or db_mtime != mtime:
self.update_mtimes([(mtime, checksum, fingerprint_id)])

con.execute(
Expand Down Expand Up @@ -437,11 +425,9 @@ def update_mtimes(self, new_mtimes):
)

def run_filters(self):


filenames_fingerprints = self.filenames_fingerprints


_, mtime_misses = split_filter(
self.source_tree, check_mtime, filenames_fingerprints
)
Expand All @@ -454,7 +440,6 @@ def run_filters(self):
{checksum_miss["fingerprint_id"] for checksum_miss in checksum_misses}
)


fingerprint_hits, fingerprint_misses = split_filter(
self.source_tree, check_fingerprint, changed_file_data
)
Expand All @@ -480,7 +465,7 @@ def determine_stable(self):


def get_new_mtimes(filesystem, hits):

for hit in hits:
module = filesystem.get_file(hit[0])
if module:
Expand All @@ -504,21 +489,17 @@ def setup_coverage(self, subprocess, cov_plugin=None):
"omit": _get_python_lib_paths(),
}



self.cov = Coverage(
data_file=getattr(self, "sub_cov_file", None), config_file=False, **params
)
self.cov._warn_no_data = False


def start(self):

Testmon.coverage_stack.append(self.cov)
self.cov.erase()
self.cov.start()


def stop(self):
self.cov.stop()
Testmon.coverage_stack.pop()
Expand All @@ -537,8 +518,6 @@ def close(self):


class TestmonConfig:


def _is_debugger(self):
return sys.gettrace() and not isinstance(sys.gettrace(), CTracer)

Expand Down Expand Up @@ -584,7 +563,6 @@ def _get_nocollect_reasons(
if options["testmon_nocollect"]:
return [None]


if coverage and not dogfooding:
return ["it's not compatible with coverage.py"]

Expand Down

0 comments on commit 176600d

Please sign in to comment.