Skip to content

Commit 8975b73

Browse files
committed
Adjust test_makefile_warts (via makefile-ext-none)
1 parent 42d2bda commit 8975b73

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

testing/test_pytester.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,13 +1085,23 @@ def test_makefile_warts(testdir: Testdir) -> None:
10851085
Additional issues:
10861086
- always strips and dedents.
10871087
"""
1088+
1089+
def list_files():
1090+
return sorted([os.path.basename(x) for x in testdir.tmpdir.listdir()])
1091+
10881092
# Requires "ext".
10891093
with pytest.raises(TypeError, match="required positional argument"):
10901094
testdir.makefile(foo="") # type: ignore[call-arg] # noqa: F821
10911095

1092-
# Cannot create a file named "ext".
1093-
p1 = testdir.makefile(ext="")
1094-
assert p1 is None
1096+
# Requires items to be created.
1097+
with pytest.raises(TypeError):
1098+
testdir.makefile() # type: ignore[call-arg] # noqa: F821
1099+
with pytest.raises(ValueError, match=r"^no files to create$"):
1100+
testdir.makefile(None)
1101+
with pytest.raises(ValueError, match=r"^no files to create$"):
1102+
testdir.makefile(ext="")
1103+
assert list_files() == []
1104+
10951105
assert testdir.tmpdir.listdir() == []
10961106

10971107
with pytest.raises(TypeError, match="got multiple values for argument 'ext'"):

0 commit comments

Comments
 (0)