Skip to content

Commit 9184b5f

Browse files
committed
Split problematic test into two separate tests and skip one on Windows
1 parent 2e30808 commit 9184b5f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

tests/test_cmd2.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,18 +1793,14 @@ def test_commandresult_falsy(commandresult_app):
17931793
assert commandresult_app.last_result == cmd2.CommandResult('', arg)
17941794

17951795

1796-
def test_is_text_file_bad_input(base_app):
1797-
# Test with a non-existent file - on GitHub Actions Windows test runners, we get a PermissionError
1798-
file_name = 'does_not_exist.txt'
1799-
if sys.platform.startswith('win'):
1800-
# For Windows, depending on setup you might get a FileNotFoundError or a PermissionError
1801-
with pytest.raises(OSError): # noqa: PT011
1802-
utils.is_text_file(file_name)
1803-
else:
1804-
# For Linux or macOS you should reliably get a FileNotFoundError
1805-
with pytest.raises(FileNotFoundError):
1806-
utils.is_text_file(file_name)
1796+
@pytest.mark.skipif(sys.platform.startswith('win'), reason="Test is unreliable on GitHub Actions Windows runners")
1797+
def test_is_text_file_bad_no_exist(base_app):
1798+
# Test with a non-existent file
1799+
with pytest.raises(FileNotFoundError):
1800+
utils.is_text_file('does_not_exist.txt')
1801+
18071802

1803+
def test_is_text_file_bad_is_dir(base_app):
18081804
# Test with a directory
18091805
with pytest.raises(IsADirectoryError):
18101806
utils.is_text_file('.')

0 commit comments

Comments
 (0)