示例#1
0
def test_write_read_data2(testdir):
    original = ({'a.py': 1.0}, {'n1': {'a.py': [1]}}, ['n1'])
    td = CoreTestmonData(testdir.tmpdir.strpath, 'default')
    td.mtimes, td.node_data, td.lastfailed = original
    td.write_data()
    td2 = CoreTestmonData(testdir.tmpdir.strpath, 'default')
    td2.read_data()
    assert original == (td2.mtimes, td2.node_data, td2.lastfailed)
示例#2
0
def test_write_read_data2(testdir):
    original = ({'a.py': 1.0}, {'n1': {'a.py': [1]}}, ['n1'])
    td = CoreTestmonData(testdir.tmpdir.strpath, 'default')
    td.mtimes, td.node_data, td.lastfailed = original
    td.write_data()
    td2 = CoreTestmonData(testdir.tmpdir.strpath, 'default')
    td2.read_data()
    assert original == (td2.mtimes, td2.node_data, td2.lastfailed)
示例#3
0
def test_write_read_data2(testdir):
    td = TestmonData(testdir.tmpdir.strpath, 'default')
    td.mtimes = {'a.py': 1.0}
    td.node_data = {'n1': {'a.py': [1]}}
    td.lastfailed = ['n1']
    td.write_data()
    td2 = TestmonData(testdir.tmpdir.strpath, 'default')
    td2.read_data()
    assert td == td2
示例#4
0
def test_write_read_data2(testdir):
    n1_node_data = {'a.py': [1]}
    td = CoreTestmonData(testdir.tmpdir.strpath, 'default')
    td.lastfailed = ['n1']
    td.write_data()
    td.set_dependencies('n1', n1_node_data, )
    td2 = CoreTestmonData(testdir.tmpdir.strpath, 'default')
    td2.read_data()
    assert td2.node_data['n1'] == n1_node_data
示例#5
0
def init_testmon_data(config, read_source=True):
    if not hasattr(config, 'testmon_data'):
        variant = eval_variant(config.getini('run_variant_expression'))
        config.project_dirs = config.getoption('project_directory') or [config.rootdir.strpath]
        testmon_data = TestmonData(config.project_dirs[0],
                                   variant=variant)
        testmon_data.read_data()
        if read_source:
            testmon_data.read_source()
        config.testmon_data = testmon_data
示例#6
0
 def test_write_read_data2(self, testdir):
     n1_node_data = {'test_a.py': [1]}
     td = CoreTestmonData(testdir.tmpdir.strpath, 'default')
     td.lastfailed = ['test_a.py::n1']
     td.write_data()
     td.set_dependencies('test_a.py::n1', n1_node_data, {})
     td2 = CoreTestmonData(testdir.tmpdir.strpath, 'default')
     td2.read_data()
     assert td2.node_data['test_a.py::n1'] == n1_node_data
     assert td2.f_tests['test_a.py'] == set(['test_a.py::n1'])
示例#7
0
 def test_skipped(self, testdir):
     testdir.makepyfile(test_a="""
         import pytest
         @pytest.mark.skip
         def test_add():
             1/0
     """, )
     testdir.inline_run("--testmon", "-v")
     testmon_data = CoreTestmonData(testdir.tmpdir.strpath)
     testmon_data.read_data()
     assert testmon_data.node_data['test_a.py::test_add']['test_a.py']
示例#8
0
    def test_skipped_under_dir(self, testdir):
        subdir = testdir.mkdir("tests")

        tf = subdir.join("test_a.py")
        tf.write("""
import pytest
@pytest.mark.skip
def test_add():
    1/0
        """, )
        tf.setmtime(1)
        testdir.inline_run("--testmon", "-v", "tests")

        testmon_data = CoreTestmonData(testdir.tmpdir.strpath)
        testmon_data.read_data()

        fname = os.path.sep.join(['tests', 'test_a.py'])
        assert testmon_data.node_data['tests/test_a.py::test_add'][fname]
示例#9
0
    def test_wrong_result_processing(self, testdir):
        tf = testdir.makepyfile(test_a="""
            def test_add():
                1/0
        """, )
        testdir.inline_run("--testmon", "-v")
        testmon_data = CoreTestmonData(testdir.tmpdir.strpath)
        testmon_data.read_data()
        assert len(testmon_data.fail_reports['test_a.py::test_add']) == 3

        tf = testdir.makepyfile(test_a="""
            import pytest
            @pytest.mark.skip
            def test_add():
                1/0/0
        """, )
        tf.setmtime(1)
        testdir.inline_run("--testmon", "-v")

        testmon_data.read_data()
        assert len(testmon_data.fail_reports['test_a.py::test_add']) == 0

        tf = testdir.makepyfile(test_a="""
            import pytest
            def test_add():
                1/0
        """, )
        tf.setmtime(2)
        testdir.inline_run("--testmon", "-v")

        testmon_data.read_data()
        assert len(testmon_data.fail_reports['test_a.py::test_add']) == 3