def test_nonfunc_class(self, testdir, monkeypatch): """" """ cs1 = CodeSample("""\ class TestA(object): def test_one(self): print("1") def test_two(self): print("2") """) cs2 = CodeSample("""\ class TestA(object): def test_one(self): print("1") def test_twob(self): print("2") """) Module(cs2.source_code) test_a = testdir.makepyfile(test_a=cs1.source_code) result = testdir.runpytest("--testmon", "test_a.py::TestA::test_one", ) result.stdout.fnmatch_lines([ "*1 passed*", ]) testdir.makepyfile(test_a=cs2.source_code) test_a.setmtime(1424880935) result = testdir.runpytest("-v", "--collectonly", "--testmon") result.stdout.fnmatch_lines([ "*test_one*", ])
def test_classes_depggraph(self): module1 = Module(CodeSample("""\ class TestA(object): def test_one(self): print("1") def test_two(self): print("2") """).source_code) bs1 = module1.blocks module2 = Module(CodeSample("""\ class TestA(object): def test_one(self): print("1") def test_twob(self): print("2") """).source_code) bs2 = module2.blocks assert bs1[0] == bs2[0] assert bs1[1] != bs2[1] assert bs1[2] != bs2[2] assert len(module1.blocks) == len(module2.blocks) == 3 assert (bs1[1].start, bs1[1].end, bs1[1].checksum) == (bs2[1].start, bs2[1].end, bs2[1].checksum) assert (bs1[1].name) != (bs2[1].name) assert is_dependent({'test_s.py': [bs1[0].checksum, bs1[2].checksum]}, {'test_s.py': [b.checksum for b in bs2]}) == True assert is_dependent({'test_s.py': [bs1[1].checksum, bs1[2].checksum]}, {'test_s.py': [b.checksum for b in bs2]}) == True
def test_nonfunc_class_2(self, testdir): testdir.parseconfigure() cs2 = CodeSample("""\ class TestA(object): def test_one(self): print("1") def test_twob(self): print("2") """) testdir.makepyfile(test_a=cs2.source_code) result = testdir.runpytest("-vv", "--collectonly", "--testmon", ) result.stdout.fnmatch_lines([ "*test_one*", ])
def test_strange_argparse_handling(self, testdir): """" """ cs1 = CodeSample("""\ class TestA(object): def test_one(self): print("1") def test_two(self): print("2") """) testdir.makepyfile(test_a=cs1.source_code) result = testdir.runpytest("-v", "--testmon", "test_a.py::TestA::test_one") result.stdout.fnmatch_lines([ "*1 passed*", ])