Skip to content

Commit

Permalink
Update warning and tests for python 3.12 (#61)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
adrianeboyd authored Sep 14, 2023
1 parent 1366220 commit 7225fc9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12.0-rc.2"]
include:
- os: ubuntu-20.04
python_version: "3.6"
Expand Down
7 changes: 7 additions & 0 deletions weasel/tests/cli/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import time

import pytest
Expand Down Expand Up @@ -113,6 +114,9 @@ def test_is_subpath_of(parent, child, expected):
assert is_subpath_of(parent, child) == expected


@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
)
def test_local_remote_storage():
with make_tempdir() as d:
filename = "a.txt"
Expand Down Expand Up @@ -158,6 +162,9 @@ def test_local_remote_storage():
assert file_.read() == content


@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
)
def test_local_remote_storage_pull_missing():
# pulling from a non-existent remote pulls nothing gracefully
with make_tempdir() as d:
Expand Down
4 changes: 4 additions & 0 deletions weasel/tests/cli/test_cli_app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from pathlib import Path
from typing import Any, Dict

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


@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="Python 3.12+ not supported for remotes"
)
def test_project_push_pull(tmp_path: Path, project_dir: Path):
proj = dict(SAMPLE_PROJECT)
remote = "xyz"
Expand Down
4 changes: 4 additions & 0 deletions weasel/tests/cli/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from pathlib import Path

import pytest
Expand All @@ -9,6 +10,9 @@

runner = CliRunner()

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


@pytest.fixture
def project_dir(tmp_path_factory: pytest.TempPathFactory):
Expand Down
8 changes: 6 additions & 2 deletions weasel/util/filesystem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import shutil
import stat
import sys
import tempfile
import warnings
from contextlib import contextmanager
Expand Down Expand Up @@ -45,7 +46,10 @@ def force_remove(rmfunc, path, ex):
rmfunc(path)

try:
shutil.rmtree(str(d), onerror=force_remove)
if sys.version_info >= (3, 12):
shutil.rmtree(str(d), onexc=force_remove)
else:
shutil.rmtree(str(d), onerror=force_remove)
except PermissionError as e:
warnings.warn(Warnings.W801.format(dir=d, msg=e))

Expand Down Expand Up @@ -80,7 +84,7 @@ def ensure_pathy(path):
except ImportError as e:
import sys

if sys.version >= (3, 12):
if sys.version_info >= (3, 12):
warnings.warn(Warnings.W802)
raise e

Expand Down

0 comments on commit 7225fc9

Please sign in to comment.