Lines Matching refs:testdir

16     def test_config_cache_makedir(self, testdir):  argument
17 testdir.makeini("[pytest]")
18 config = testdir.parseconfigure()
25 def test_config_cache_dataerror(self, testdir): argument
26 testdir.makeini("[pytest]")
27 config = testdir.parseconfigure()
36 def test_cache_writefail_cachfile_silent(self, testdir): argument
37 testdir.makeini("[pytest]")
38 testdir.tmpdir.join(".pytest_cache").write("gone wrong")
39 config = testdir.parseconfigure()
47 def test_cache_writefail_permissions(self, testdir): argument
48 testdir.makeini("[pytest]")
49 cache_dir = str(testdir.tmpdir.ensure_dir(".pytest_cache"))
51 testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
53 config = testdir.parseconfigure()
57 testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
61 def test_cache_failure_warns(self, testdir, monkeypatch): argument
63 cache_dir = str(testdir.tmpdir.ensure_dir(".pytest_cache"))
65 testdir.tmpdir.ensure_dir(".pytest_cache").chmod(0)
67 testdir.makepyfile("def test_error(): raise Exception")
68 result = testdir.runpytest()
83 testdir.tmpdir.ensure_dir(".pytest_cache").chmod(mode)
85 def test_config_cache(self, testdir): argument
86 testdir.makeconftest(
93 testdir.makepyfile(
99 result = testdir.runpytest()
103 def test_cachefuncarg(self, testdir): argument
104 testdir.makepyfile(
116 result = testdir.runpytest()
120 def test_custom_rel_cache_dir(self, testdir): argument
122 testdir.makeini(
130 testdir.makepyfile(test_errored="def test_error():\n assert False")
131 testdir.runpytest()
132 assert testdir.tmpdir.join(rel_cache_dir).isdir()
134 def test_custom_abs_cache_dir(self, testdir, tmpdir_factory): argument
137 testdir.makeini(
145 testdir.makepyfile(test_errored="def test_error():\n assert False")
146 testdir.runpytest()
149 def test_custom_cache_dir_with_env_var(self, testdir, monkeypatch): argument
151 testdir.makeini(
159 testdir.makepyfile(test_errored="def test_error():\n assert False")
160 testdir.runpytest()
161 assert testdir.tmpdir.join("custom_cache_dir").isdir()
165 def test_cache_reportheader(env, testdir, monkeypatch): argument
166 testdir.makepyfile("""def test_foo(): pass""")
173 result = testdir.runpytest("-v")
177 def test_cache_reportheader_external_abspath(testdir, tmpdir_factory): argument
182 testdir.makepyfile("def test_hello(): pass")
183 testdir.makeini(
191 result = testdir.runpytest("-v")
197 def test_cache_show(testdir): argument
198 result = testdir.runpytest("--cache-show")
201 testdir.makeconftest(
212 result = testdir.runpytest()
215 result = testdir.runpytest("--cache-show")
232 result = testdir.runpytest("--cache-show", "*/hello")
250 def test_lastfailed_usecase(self, testdir, monkeypatch): argument
252 p = testdir.makepyfile(
259 result = testdir.runpytest(str(p))
261 p = testdir.makepyfile(
268 result = testdir.runpytest(str(p), "--lf")
276 result = testdir.runpytest(str(p), "--lf")
284 testdir.tmpdir.join(".pytest_cache").mkdir(".git")
285 result = testdir.runpytest(str(p), "--lf", "--cache-clear")
287 assert testdir.tmpdir.join(".pytest_cache", "README.md").isfile()
288 assert testdir.tmpdir.join(".pytest_cache", ".git").isdir()
293 result = testdir.runpytest("--lf", "--cache-clear")
296 def test_failedfirst_order(self, testdir): argument
297 testdir.makepyfile(
301 result = testdir.runpytest()
304 result = testdir.runpytest("--ff")
315 def test_lastfailed_failedfirst_order(self, testdir): argument
316 testdir.makepyfile(
320 result = testdir.runpytest()
323 result = testdir.runpytest("--lf", "--ff")
328 def test_lastfailed_difference_invocations(self, testdir, monkeypatch): argument
330 testdir.makepyfile(
337 p = testdir.tmpdir.join("test_a.py")
338 p2 = testdir.tmpdir.join("test_b.py")
340 result = testdir.runpytest()
342 result = testdir.runpytest("--lf", p2)
345 testdir.makepyfile(test_b="def test_b1(): assert 1")
346 result = testdir.runpytest("--lf", p2)
348 result = testdir.runpytest("--lf", p)
357 def test_lastfailed_usecase_splice(self, testdir, monkeypatch): argument
359 testdir.makepyfile(
362 p2 = testdir.tmpdir.join("test_something.py")
363 result = testdir.runpytest()
365 result = testdir.runpytest("--lf", p2)
367 result = testdir.runpytest("--lf")
370 def test_lastfailed_xpass(self, testdir): argument
371 testdir.inline_runsource(
379 config = testdir.parseconfigure()
383 def test_non_serializable_parametrize(self, testdir): argument
387 testdir.makepyfile(
398 result = testdir.runpytest()
401 def test_terminal_report_lastfailed(self, testdir): argument
402 test_a = testdir.makepyfile(
408 test_b = testdir.makepyfile(
414 result = testdir.runpytest()
417 result = testdir.runpytest("--lf")
426 result = testdir.runpytest(test_a, "--lf")
435 result = testdir.runpytest(test_b, "--lf")
444 result = testdir.runpytest("test_b.py::test_b1", "--lf")
453 def test_terminal_report_failedfirst(self, testdir): argument
454 testdir.makepyfile(
460 result = testdir.runpytest()
463 result = testdir.runpytest("--ff")
472 def test_lastfailed_collectfailure(self, testdir, monkeypatch): argument
474 testdir.makepyfile(
489 testdir.runpytest("-q")
490 config = testdir.parseconfigure()
503 def test_lastfailed_failure_subset(self, testdir, monkeypatch): argument
504 testdir.makepyfile(
515 testdir.makepyfile(
534 result = testdir.runpytest("-q", "--lf", *args)
535 config = testdir.parseconfigure()
556 def test_lastfailed_creates_cache_when_needed(self, testdir): argument
558 testdir.makepyfile(test_empty="")
559 testdir.runpytest("-q", "--lf")
562 testdir.makepyfile(test_successful="def test_success():\n assert True")
563 testdir.runpytest("-q", "--lf")
566 testdir.makepyfile(test_errored="def test_error():\n assert False")
567 testdir.runpytest("-q", "--lf")
570 def test_xfail_not_considered_failure(self, testdir): argument
571 testdir.makepyfile(
578 result = testdir.runpytest()
580 assert self.get_cached_last_failed(testdir) == []
582 def test_xfail_strict_considered_failure(self, testdir): argument
583 testdir.makepyfile(
590 result = testdir.runpytest()
592 assert self.get_cached_last_failed(testdir) == [
597 def test_failed_changed_to_xfail_or_skip(self, testdir, mark): argument
598 testdir.makepyfile(
604 result = testdir.runpytest()
605 assert self.get_cached_last_failed(testdir) == [
610 testdir.makepyfile(
619 result = testdir.runpytest()
621 assert self.get_cached_last_failed(testdir) == []
626 def test_lf_and_ff_prints_no_needless_message(self, quiet, opt, testdir): argument
628 testdir.makepyfile("def test(): assert 0")
632 result = testdir.runpytest(*args)
635 result = testdir.runpytest(*args)
641 def get_cached_last_failed(self, testdir): argument
642 config = testdir.parseconfigure()
645 def test_cache_cumulative(self, testdir): argument
648 test_bar = testdir.makepyfile(
654 test_foo = testdir.makepyfile(
660 testdir.runpytest()
661 assert self.get_cached_last_failed(testdir) == [
667 testdir.makepyfile(
673 result = testdir.runpytest(test_bar)
676 assert self.get_cached_last_failed(testdir) == ["test_foo.py::test_foo_4"]
678 result = testdir.runpytest("--last-failed")
686 assert self.get_cached_last_failed(testdir) == ["test_foo.py::test_foo_4"]
689 test_foo = testdir.makepyfile(
695 result = testdir.runpytest(test_foo, "--last-failed")
703 assert self.get_cached_last_failed(testdir) == []
705 result = testdir.runpytest("--last-failed")
707 assert self.get_cached_last_failed(testdir) == []
709 def test_lastfailed_no_failures_behavior_all_passed(self, testdir): argument
710 testdir.makepyfile(
716 result = testdir.runpytest()
718 result = testdir.runpytest("--lf")
720 result = testdir.runpytest("--lf", "--lfnf", "all")
725 testdir.makeconftest(
738 result = testdir.runpytest("--lf", "--lfnf", "none")
749 def test_lastfailed_no_failures_behavior_empty_cache(self, testdir): argument
750 testdir.makepyfile(
756 result = testdir.runpytest("--lf", "--cache-clear")
758 result = testdir.runpytest("--lf", "--cache-clear", "--lfnf", "all")
760 result = testdir.runpytest("--lf", "--cache-clear", "--lfnf", "none")
763 def test_lastfailed_skip_collection(self, testdir): argument
768 testdir.makepyfile(
786 result = testdir.runpytest()
789 result = testdir.runpytest("--lf")
799 testdir.makepyfile(
806 result = testdir.runpytest("--lf")
815 def test_lastfailed_with_known_failures_not_being_selected(self, testdir): argument
816 testdir.makepyfile(
822 result = testdir.runpytest()
826 result = testdir.runpytest("--lf")
836 testdir.makepyfile(**{"pkg1/test_1.py": """def test_1(): assert 0"""})
837 result = testdir.runpytest("--lf")
847 testdir.makepyfile(**{"pkg1/test_1.py": """def test_renamed(): assert 0"""})
848 result = testdir.runpytest("--lf", "-rf")
860 result = testdir.runpytest("--lf", "--co")
871 def test_lastfailed_args_with_deselected(self, testdir: Testdir) -> None:
877 testdir.makepyfile(
885 result = testdir.runpytest()
889 result = testdir.runpytest("pkg1/test_1.py::test_pass", "--lf", "--co")
902 result = testdir.runpytest(
917 def test_lastfailed_with_class_items(self, testdir: Testdir) -> None:
919 testdir.makepyfile(
930 result = testdir.runpytest()
934 result = testdir.runpytest("--lf", "--co")
951 def test_lastfailed_with_all_filtered(self, testdir: Testdir) -> None:
952 testdir.makepyfile(
960 result = testdir.runpytest()
965 testdir.makepyfile(
972 result = testdir.runpytest("--lf", "--co")
989 def test_newfirst_usecase(self, testdir): argument
990 testdir.makepyfile(
1000 testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
1002 result = testdir.runpytest("-v")
1007 result = testdir.runpytest("-v", "--nf")
1012 testdir.tmpdir.join("test_1/test_1.py").write(
1015 testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
1017 result = testdir.runpytest("--nf", "--collect-only", "-q")
1027 testdir.makepyfile(
1034 testdir.syspathinsert()
1035 result = testdir.runpytest("--nf", "-p", "myplugin", "--collect-only", "-q")
1045 def test_newfirst_parametrize(self, testdir): argument
1046 testdir.makepyfile(
1061 testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
1063 result = testdir.runpytest("-v")
1073 result = testdir.runpytest("-v", "--nf")
1083 testdir.tmpdir.join("test_1/test_1.py").write(
1088 testdir.tmpdir.join("test_1/test_1.py").setmtime(1)
1091 result = testdir.runpytest("-v", "--nf", "test_2/test_2.py")
1096 result = testdir.runpytest("-v", "--nf")
1109 def check_readme(self, testdir): argument
1110 config = testdir.parseconfigure()
1114 def test_readme_passed(self, testdir): argument
1115 testdir.makepyfile("def test_always_passes(): pass")
1116 testdir.runpytest()
1117 assert self.check_readme(testdir) is True
1119 def test_readme_failed(self, testdir): argument
1120 testdir.makepyfile("def test_always_fails(): assert 0")
1121 testdir.runpytest()
1122 assert self.check_readme(testdir) is True
1125 def test_gitignore(testdir): argument
1129 config = testdir.parseconfig()
1142 def test_does_not_create_boilerplate_in_existing_dirs(testdir): argument
1145 testdir.makeini(
1151 config = testdir.parseconfig()
1160 def test_cachedir_tag(testdir): argument
1165 config = testdir.parseconfig()