@@ -24,6 +24,44 @@ def test_foobar():
24
24
assert outcomes ["passed" ] == 1
25
25
26
26
27
+ @pytest .mark .django_project (project_root = "django_project_root" , create_manage_py = True )
28
+ def test_django_project_found_with_k (django_testdir , monkeypatch ):
29
+ """Test that cwd is checked as fallback with non-args via '-k foo'."""
30
+ testfile = django_testdir .create_test_module (
31
+ """
32
+ def test_foobar():
33
+ assert True
34
+ """ ,
35
+ "sub/test_in_sub.py" ,
36
+ )
37
+
38
+ monkeypatch .chdir (testfile .dirname )
39
+ result = django_testdir .runpytest_subprocess ("-k" , "test_foobar" )
40
+ assert result .ret == 0
41
+
42
+ outcomes = result .parseoutcomes ()
43
+ assert outcomes ["passed" ] == 1
44
+
45
+
46
+ @pytest .mark .django_project (project_root = "django_project_root" , create_manage_py = True )
47
+ def test_django_project_found_with_k_and_cwd (django_testdir , monkeypatch ):
48
+ """Cover cwd not used as fallback if present already in args."""
49
+ testfile = django_testdir .create_test_module (
50
+ """
51
+ def test_foobar():
52
+ assert True
53
+ """ ,
54
+ "sub/test_in_sub.py" ,
55
+ )
56
+
57
+ monkeypatch .chdir (testfile .dirname )
58
+ result = django_testdir .runpytest_subprocess (testfile .dirname , "-k" , "test_foobar" )
59
+ assert result .ret == 0
60
+
61
+ outcomes = result .parseoutcomes ()
62
+ assert outcomes ["passed" ] == 1
63
+
64
+
27
65
@pytest .mark .django_project (project_root = "django_project_root" , create_manage_py = True )
28
66
def test_django_project_found_absolute (django_testdir , monkeypatch ):
29
67
"""This only tests that "." is added as an absolute path (#637)."""
0 commit comments