Skip to content

Commit 7225fc9

Browse files
authored
Update warning and tests for python 3.12 (#61)
* Update warning and tests for python 3.12 * Use full python 3.12 prerelease version in CI * Use shutil.rmtree(onexc=) instead of onerror Due to deprecation. * Branch on python version for shutil.rmtree
1 parent 1366220 commit 7225fc9

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
fail-fast: false
5353
matrix:
5454
os: [ubuntu-latest, windows-latest, macos-latest]
55-
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
55+
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-rc.2"]
5656
include:
5757
- os: ubuntu-20.04
5858
python_version: "3.6"

weasel/tests/cli/test_cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import time
34

45
import pytest
@@ -113,6 +114,9 @@ def test_is_subpath_of(parent, child, expected):
113114
assert is_subpath_of(parent, child) == expected
114115

115116

117+
@pytest.mark.skipif(
118+
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
119+
)
116120
def test_local_remote_storage():
117121
with make_tempdir() as d:
118122
filename = "a.txt"
@@ -158,6 +162,9 @@ def test_local_remote_storage():
158162
assert file_.read() == content
159163

160164

165+
@pytest.mark.skipif(
166+
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
167+
)
161168
def test_local_remote_storage_pull_missing():
162169
# pulling from a non-existent remote pulls nothing gracefully
163170
with make_tempdir() as d:

weasel/tests/cli/test_cli_app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from pathlib import Path
23
from typing import Any, Dict
34

@@ -163,6 +164,9 @@ def test_project_clone(tmp_path: Path, options_string: str):
163164
assert (out / "README.md").is_file()
164165

165166

167+
@pytest.mark.skipif(
168+
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
169+
)
166170
def test_project_push_pull(tmp_path: Path, project_dir: Path):
167171
proj = dict(SAMPLE_PROJECT)
168172
remote = "xyz"

weasel/tests/cli/test_remote.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from pathlib import Path
23

34
import pytest
@@ -9,6 +10,9 @@
910

1011
runner = CliRunner()
1112

13+
if sys.version_info >= (3, 12):
14+
pytest.skip("Python 3.12+ not supported for remotes", allow_module_level=True)
15+
1216

1317
@pytest.fixture
1418
def project_dir(tmp_path_factory: pytest.TempPathFactory):

weasel/util/filesystem.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import shutil
33
import stat
4+
import sys
45
import tempfile
56
import warnings
67
from contextlib import contextmanager
@@ -45,7 +46,10 @@ def force_remove(rmfunc, path, ex):
4546
rmfunc(path)
4647

4748
try:
48-
shutil.rmtree(str(d), onerror=force_remove)
49+
if sys.version_info >= (3, 12):
50+
shutil.rmtree(str(d), onexc=force_remove)
51+
else:
52+
shutil.rmtree(str(d), onerror=force_remove)
4953
except PermissionError as e:
5054
warnings.warn(Warnings.W801.format(dir=d, msg=e))
5155

@@ -80,7 +84,7 @@ def ensure_pathy(path):
8084
except ImportError as e:
8185
import sys
8286

83-
if sys.version >= (3, 12):
87+
if sys.version_info >= (3, 12):
8488
warnings.warn(Warnings.W802)
8589
raise e
8690

0 commit comments

Comments
 (0)