Skip to content

Commit bfd0d18

Browse files
authored
tests: test_config: move tests (#6796)
Originally added in a289142 (with `TestRootdir`), but then accidentally moved to `TestOverrideIniArgs` in 802755c.
1 parent 9928c77 commit bfd0d18

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

testing/test_config.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,37 @@ def test_with_specific_inifile(self, tmpdir) -> None:
944944
rootdir, _, _ = determine_setup(inifile, [tmpdir])
945945
assert rootdir == tmpdir
946946

947+
def test_with_arg_outside_cwd_without_inifile(self, tmpdir, monkeypatch) -> None:
948+
monkeypatch.chdir(str(tmpdir))
949+
a = tmpdir.mkdir("a")
950+
b = tmpdir.mkdir("b")
951+
rootdir, inifile, _ = determine_setup(None, [a, b])
952+
assert rootdir == tmpdir
953+
assert inifile is None
954+
955+
def test_with_arg_outside_cwd_with_inifile(self, tmpdir) -> None:
956+
a = tmpdir.mkdir("a")
957+
b = tmpdir.mkdir("b")
958+
inifile = a.ensure("pytest.ini")
959+
rootdir, parsed_inifile, _ = determine_setup(None, [a, b])
960+
assert rootdir == a
961+
assert inifile == parsed_inifile
962+
963+
@pytest.mark.parametrize("dirs", ([], ["does-not-exist"], ["a/does-not-exist"]))
964+
def test_with_non_dir_arg(self, dirs, tmpdir) -> None:
965+
with tmpdir.ensure(dir=True).as_cwd():
966+
rootdir, inifile, _ = determine_setup(None, dirs)
967+
assert rootdir == tmpdir
968+
assert inifile is None
969+
970+
def test_with_existing_file_in_subdir(self, tmpdir) -> None:
971+
a = tmpdir.mkdir("a")
972+
a.ensure("exist")
973+
with tmpdir.as_cwd():
974+
rootdir, inifile, _ = determine_setup(None, ["a/exist"])
975+
assert rootdir == tmpdir
976+
assert inifile is None
977+
947978

948979
class TestOverrideIniArgs:
949980
@pytest.mark.parametrize("name", "setup.cfg tox.ini pytest.ini".split())
@@ -1080,37 +1111,6 @@ def test():
10801111
result = testdir.runpytest("--override-ini", "python_files=unittest_*.py")
10811112
result.stdout.fnmatch_lines(["*1 passed in*"])
10821113

1083-
def test_with_arg_outside_cwd_without_inifile(self, tmpdir, monkeypatch) -> None:
1084-
monkeypatch.chdir(str(tmpdir))
1085-
a = tmpdir.mkdir("a")
1086-
b = tmpdir.mkdir("b")
1087-
rootdir, inifile, _ = determine_setup(None, [a, b])
1088-
assert rootdir == tmpdir
1089-
assert inifile is None
1090-
1091-
def test_with_arg_outside_cwd_with_inifile(self, tmpdir) -> None:
1092-
a = tmpdir.mkdir("a")
1093-
b = tmpdir.mkdir("b")
1094-
inifile = a.ensure("pytest.ini")
1095-
rootdir, parsed_inifile, _ = determine_setup(None, [a, b])
1096-
assert rootdir == a
1097-
assert inifile == parsed_inifile
1098-
1099-
@pytest.mark.parametrize("dirs", ([], ["does-not-exist"], ["a/does-not-exist"]))
1100-
def test_with_non_dir_arg(self, dirs, tmpdir) -> None:
1101-
with tmpdir.ensure(dir=True).as_cwd():
1102-
rootdir, inifile, _ = determine_setup(None, dirs)
1103-
assert rootdir == tmpdir
1104-
assert inifile is None
1105-
1106-
def test_with_existing_file_in_subdir(self, tmpdir) -> None:
1107-
a = tmpdir.mkdir("a")
1108-
a.ensure("exist")
1109-
with tmpdir.as_cwd():
1110-
rootdir, inifile, _ = determine_setup(None, ["a/exist"])
1111-
assert rootdir == tmpdir
1112-
assert inifile is None
1113-
11141114
def test_addopts_before_initini(self, monkeypatch, _config_for_test, _sys_snapshot):
11151115
cache_dir = ".custom_cache"
11161116
monkeypatch.setenv("PYTEST_ADDOPTS", "-o cache_dir=%s" % cache_dir)

0 commit comments

Comments
 (0)