Ejemplo n.º 1
0
 def set_dependencies(self, nodeid, coverage_data, rootdir):
     result = {}
     for filename, value in coverage_data.lines.items():
         if os.path.exists(filename):
             result[filename] = checksum_coverage(self.parse_cache(filename).blocks, value.keys())
     if not result:
         filename = os.path.join(rootdir, nodeid).split("::",1)[0]
         result[filename] = checksum_coverage(self.parse_cache(filename).blocks,[1])
     self.node_data[nodeid] = result
Ejemplo n.º 2
0
 def set_dependencies(self, nodeid, coverage_data, rootdir):
     result = {}
     for filename in coverage_data.measured_files():
         lines = coverage_data.lines(filename)
         if os.path.exists(filename):
             result[filename] = checksum_coverage(self.parse_cache(filename).blocks, lines)
     if not result:
         filename = os.path.join(rootdir, nodeid).split("::", 1)[0]
         result[filename] = checksum_coverage(self.parse_cache(filename).blocks, [1])
     self.node_data[nodeid] = result
Ejemplo n.º 3
0
 def get_nodedata(self, nodeid, coverage_data, rootdir):
     result = {}
     for filename in coverage_data.measured_files():
         relfilename = os.path.relpath(filename, rootdir)
         lines = coverage_data.lines(filename)
         if os.path.exists(filename):
             result[relfilename] = checksum_coverage(self.source_tree.get_file(relfilename).blocks, lines)
     if not result:  # when testmon kicks-in the test module is already imported. If the test function is skipped
         # coverage_data is empty. However, we need to write down, that we depend on the
         # file where the test is stored (so that we notice e.g. when the test is no longer skipped.)
         relfilename = os.path.relpath(os.path.join(rootdir, nodeid).split("::", 1)[0], self.rootdir)
         result[relfilename] = checksum_coverage(self.source_tree.get_file(relfilename).blocks, [1])
     return result
Ejemplo n.º 4
0
 def test_miss_before(self):
     assert checksum_coverage([
         Block(2, 3, 101),
         GLOBAL_BLOCK,
     ], [1]) == [
         1000,
     ]
Ejemplo n.º 5
0
def test_subprocesss_recursive(testdir, monkeypatch):
    monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1)
    a = testdir.makepyfile(test_a="""\
    def test_1():
        a=1
    """)
    def func():
        testdir.runpytest("test_a.py", "--testmon", "--capture=no")

    deps = track_it(testdir, func)

    assert {os.path.abspath(a.strpath):
                checksum_coverage(Module(file_name=a.strpath).blocks, [2])} == deps
Ejemplo n.º 6
0
    def test_track_pytest_equal(self, testdir, monkeypatch):
        a = testdir.makepyfile(test_a="""\
        def test_1():
            a=1
        """)

        def func():
            testdir.runpytest("test_a.py")

        deps = track_it(testdir, func)

        assert {os.path.relpath(a.strpath, testdir.tmpdir.strpath):
                    checksum_coverage(Module(file_name=a.strpath).blocks, [2])} == deps
Ejemplo n.º 7
0
    def test_testmon_recursive(self, testdir, monkeypatch):
        a = testdir.makepyfile(test_a="""\
        def test_1():
            a=1
        """)

        def func():
            testdir.runpytest("test_a.py", "--testmon", "--capture=no")

        deps = track_it(testdir, func)
        # os.environ.pop('COVERAGE_TEST_TRACER', None)

        assert {os.path.abspath(a.strpath):
                    checksum_coverage(Module(file_name=a.strpath).blocks, [2])} == deps
Ejemplo n.º 8
0
def test_subprocesss(testdir, monkeypatch):
    monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1)
    a = testdir.makepyfile(test_a="""\
    def test_1():
        a=1
    """)

    def func():
        testdir.runpytest("test_a.py")

    deps = track_it(testdir, func)

    assert {os.path.relpath(a.strpath, testdir.tmpdir.strpath):
                checksum_coverage(Module(file_name=a.strpath).blocks, [2])} == deps
Ejemplo n.º 9
0
def test_subprocess_recursive(testdir, monkeypatch):
    monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1)
    # os.environ['COVERAGE_TEST_TRACER']='py'
    a = testdir.makepyfile(test_a="""\
    def test_1():
        a=1
    """)

    def func():
        testdir.runpytest("test_a.py", "--testmon", "--capture=no")

    deps = track_it(testdir, func)
    # os.environ.pop('COVERAGE_TEST_TRACER', None)

    assert {os.path.abspath(a.strpath):
                checksum_coverage(Module(file_name=a.strpath).blocks, [2])} == deps
Ejemplo n.º 10
0
 def test_hit_second(self):
     assert checksum_coverage([GLOBAL_BLOCK, Block(2, 3, 101), Block(5, 6, 102)], [5]) == [1000, 102]
Ejemplo n.º 11
0
 def test_hit_first3(self):
     assert checksum_coverage([Block(2, 3, 102), Block(6, 7, 103), GLOBAL_BLOCK], [6]) == [1000, 103]
Ejemplo n.º 12
0
 def test_hit_first(self):
     assert checksum_coverage([Block(2, 3, 102), GLOBAL_BLOCK], [2]) == [1000, 102]
Ejemplo n.º 13
0
 def test_miss_before(self):
     assert checksum_coverage([Block(2, 3, 101), GLOBAL_BLOCK, ], [1]) == [1000, ]
Ejemplo n.º 14
0
 def checksum(code_sample):
     module = Module(code_sample.source_code, 'a.py')
     covdata = code_sample.expected_coverage
     return checksum_coverage(module.blocks, covdata)
Ejemplo n.º 15
0
 def test_miss_both(self, lines):
     assert checksum_coverage([GLOBAL_BLOCK, Block(2, 3, 101), Block(5, 6, 102)], lines) == [1000, ]
Ejemplo n.º 16
0
 def test_hit_second_twice(self):
     assert checksum_coverage([GLOBAL_BLOCK, Block(2, 3, 101), Block(4, 7, 102)], [5, 6]) == [1000, 102]
Ejemplo n.º 17
0
 def test_miss_after(self):
     assert checksum_coverage([GLOBAL_BLOCK, Block(1, 2, 103)], [3]) == [1000, ]