Skip to content

Commit 64034a2

Browse files
TheMatt2pre-commit-ci[bot]gaborbernat
authored
Fix test_bad_lock_file for other OSes (#242)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: TheMatt2 <[email protected]> Co-authored-by: Bernát Gábor <[email protected]>
1 parent 34ff501 commit 64034a2

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ repos:
2222
rev: "0.11.2"
2323
hooks:
2424
- id: pyproject-fmt
25+
additional_dependencies: ["tox>=4.6"]
2526
- repo: https://github.com/pre-commit/mirrors-prettier
2627
rev: "v3.0.0-alpha.9-for-vscode"
2728
hooks:

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
build-backend = "hatchling.build"
33
requires = [
44
"hatch-vcs>=0.3",
5-
"hatchling>=1.17",
5+
"hatchling>=1.17.1",
66
]
77

88
[project]
@@ -31,6 +31,7 @@ classifiers = [
3131
"Programming Language :: Python :: 3.9",
3232
"Programming Language :: Python :: 3.10",
3333
"Programming Language :: Python :: 3.11",
34+
"Programming Language :: Python :: 3.12",
3435
"Topic :: Internet",
3536
"Topic :: Software Development :: Libraries",
3637
"Topic :: System",

tests/test_filelock.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,16 @@ def test_ro_file(lock_type: type[BaseFileLock], tmp_file_ro: Path) -> None:
115115
pytest.param(FileNotFoundError, "No such file or directory:", "a/b", id="non_existent_directory"),
116116
pytest.param(FileNotFoundError, "No such file or directory:", "", id="blank_filename"),
117117
pytest.param(ValueError, "embedded null (byte|character)", "\0", id="null_byte"),
118-
pytest.param(
119-
PermissionError if sys.platform == "win32" else IsADirectoryError,
120-
"Permission denied:" if sys.platform == "win32" else "Is a directory",
121-
".",
122-
id="current_directory",
118+
# Should be PermissionError on Windows
119+
pytest.param(PermissionError, "Permission denied:", ".", id="current_directory")
120+
if sys.platform == "win32"
121+
else (
122+
# Should be IsADirectoryError on MacOS and Linux
123+
pytest.param(IsADirectoryError, "Is a directory", ".", id="current_directory")
124+
if sys.platform in ["darwin", "linux"]
125+
else
126+
# Should be some type of OSError at least on other operating systems
127+
pytest.param(OSError, None, ".", id="current_directory")
123128
),
124129
]
125130
+ [pytest.param(OSError, "Invalid argument", i, id=f"invalid_{i}", marks=WindowsOnly) for i in '<>:"|?*\a']

0 commit comments

Comments
 (0)