Skip to content

Commit

Permalink
Fix test_bad_lock_file for other OSes (#242)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: TheMatt2 <TheMatt2@users.noreply.github.com>
Co-authored-by: Bernát Gábor <bgabor8@bloomberg.net>
  • Loading branch information
4 people committed Jun 10, 2023
1 parent 34ff501 commit 64034a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ repos:
rev: "0.11.2"
hooks:
- id: pyproject-fmt
additional_dependencies: ["tox>=4.6"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.9-for-vscode"
hooks:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
build-backend = "hatchling.build"
requires = [
"hatch-vcs>=0.3",
"hatchling>=1.17",
"hatchling>=1.17.1",
]

[project]
Expand Down Expand Up @@ -31,6 +31,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Internet",
"Topic :: Software Development :: Libraries",
"Topic :: System",
Expand Down
15 changes: 10 additions & 5 deletions tests/test_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ def test_ro_file(lock_type: type[BaseFileLock], tmp_file_ro: Path) -> None:
pytest.param(FileNotFoundError, "No such file or directory:", "a/b", id="non_existent_directory"),
pytest.param(FileNotFoundError, "No such file or directory:", "", id="blank_filename"),
pytest.param(ValueError, "embedded null (byte|character)", "\0", id="null_byte"),
pytest.param(
PermissionError if sys.platform == "win32" else IsADirectoryError,
"Permission denied:" if sys.platform == "win32" else "Is a directory",
".",
id="current_directory",
# Should be PermissionError on Windows
pytest.param(PermissionError, "Permission denied:", ".", id="current_directory")
if sys.platform == "win32"
else (
# Should be IsADirectoryError on MacOS and Linux
pytest.param(IsADirectoryError, "Is a directory", ".", id="current_directory")
if sys.platform in ["darwin", "linux"]
else
# Should be some type of OSError at least on other operating systems
pytest.param(OSError, None, ".", id="current_directory")
),
]
+ [pytest.param(OSError, "Invalid argument", i, id=f"invalid_{i}", marks=WindowsOnly) for i in '<>:"|?*\a']
Expand Down

0 comments on commit 64034a2

Please sign in to comment.