Skip to content

Commit 5f70444

Browse files
authored
Silence various warnings in tests (#267)
* tests: silence various warnings * tests: silence botocore warning * ci: update actions * ci: silence pip error on macos py38
1 parent e508246 commit 5f70444

File tree

7 files changed

+58
-19
lines changed

7 files changed

+58
-19
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Check out the repository
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 0
1919

2020
- name: Set up Python 3.10
21-
uses: actions/setup-python@v4
21+
uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.10'
2424

.github/workflows/tests.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ jobs:
3131

3232
steps:
3333
- name: Check out the repository
34-
uses: actions/checkout@v3
34+
uses: actions/checkout@v4
3535
with:
3636
fetch-depth: 0
3737

3838
- name: Set up Python ${{ matrix.pyv }}
39-
uses: actions/setup-python@v4
39+
uses: actions/setup-python@v5
40+
env:
41+
PIP_DISABLE_PIP_VERSION_CHECK: ${{ matrix.pyv == '3.8' && matrix.os == 'macos-latest' }}
4042
with:
4143
python-version: ${{ matrix.pyv }}
4244

@@ -57,7 +59,7 @@ jobs:
5759
uses: actions/checkout@v4
5860

5961
- name: Set up Python ${{ matrix.pyv }}
60-
uses: actions/setup-python@v4
62+
uses: actions/setup-python@v5
6163
with:
6264
python-version: '3.8'
6365

@@ -72,12 +74,12 @@ jobs:
7274

7375
steps:
7476
- name: Check out the repository
75-
uses: actions/checkout@v3
77+
uses: actions/checkout@v4
7678
with:
7779
fetch-depth: 0
7880

7981
- name: Set up Python ${{ matrix.pyv }}
80-
uses: actions/setup-python@v4
82+
uses: actions/setup-python@v5
8183
with:
8284
python-version: '3.10'
8385

@@ -95,12 +97,12 @@ jobs:
9597
runs-on: ubuntu-latest
9698
steps:
9799
- name: Check out the repository
98-
uses: actions/checkout@v3
100+
uses: actions/checkout@v4
99101
with:
100102
fetch-depth: 0
101103

102104
- name: Set up Python ${{ matrix.pyv }}
103-
uses: actions/setup-python@v4
105+
uses: actions/setup-python@v5
104106
with:
105107
python-version: '3.10'
106108

upath/tests/implementations/test_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def test_query_parameters_passthrough():
171171
),
172172
(
173173
"http://www.example.com/a/b/index.html",
174-
"ftp://other.com/image.png",
175-
"ftp://other.com/image.png",
174+
"sftp://other.com/image.png",
175+
"sftp://other.com/image.png",
176176
),
177177
(
178178
"http://www.example.com/a/b/index.html",

upath/tests/implementations/test_s3.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""see upath/tests/conftest.py for fixtures
22
"""
33

4+
import sys
5+
46
import fsspec
57
import pytest # noqa: F401
68

@@ -10,6 +12,20 @@
1012
from ..cases import BaseTests
1113

1214

15+
def silence_botocore_datetime_deprecation(cls):
16+
# botocore uses datetime.datetime.utcnow in 3.12 which is deprecated
17+
# see: https://github.com/boto/boto3/issues/3889#issuecomment-1751296363
18+
if sys.version_info >= (3, 12):
19+
return pytest.mark.filterwarnings(
20+
"ignore"
21+
r":datetime.datetime.utcnow\(\) is deprecated"
22+
":DeprecationWarning"
23+
)(cls)
24+
else:
25+
return cls
26+
27+
28+
@silence_botocore_datetime_deprecation
1329
class TestUPathS3(BaseTests):
1430
SUPPORTS_EMPTY_DIRS = False
1531

@@ -42,9 +58,9 @@ def test_relative_to(self):
4258
)
4359

4460
def test_iterdir_root(self):
45-
client_kwargs = self.path._kwargs["client_kwargs"]
61+
client_kwargs = self.path.storage_options["client_kwargs"]
4662
bucket_path = UPath("s3://other_test_bucket", client_kwargs=client_kwargs)
47-
bucket_path.mkdir(mode="private")
63+
bucket_path.mkdir()
4864

4965
(bucket_path / "test1.txt").touch()
5066
(bucket_path / "test2.txt").touch()

upath/tests/implementations/test_webdav.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1-
import pytest # noqa: F401
1+
import sys
2+
3+
import pytest
24

35
from upath import UPath
46

57
from ..cases import BaseTests
68

79

10+
def silence_wsigdav_deprecation(cls):
11+
# wsgidav deprecated python 3.8 while still shipping versions supporting it?
12+
if sys.version_info < (3, 9):
13+
return pytest.mark.filterwarnings(
14+
"ignore"
15+
":Support for Python version less than `3.9` is deprecated"
16+
":DeprecationWarning"
17+
)(cls)
18+
else:
19+
return cls
20+
21+
22+
@silence_wsigdav_deprecation
823
class TestUPathWebdav(BaseTests):
924
@pytest.fixture(autouse=True, scope="function")
1025
def path(self, webdav_fixture):

upath/tests/pathlib/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515

1616

17-
def pytest_ignore_collect(collection_path, path, config):
17+
def pytest_ignore_collect(collection_path):
1818
"""prevents pathlib tests from other python version than the current to be collected
1919
2020
(otherwise we see a lot of skipped tests in the pytest output)

upath/tests/test_core.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ def test_subclass(local_testdir):
9999
class MyPath(UPath):
100100
pass
101101

102-
path = MyPath(local_testdir)
102+
with pytest.warns(
103+
DeprecationWarning, match=r"MyPath\(...\) detected protocol '' .*"
104+
):
105+
path = MyPath(local_testdir)
103106
assert str(path) == str(pathlib.Path(local_testdir))
104107
assert issubclass(MyPath, UPath)
105108
assert isinstance(path, pathlib.Path)
@@ -285,13 +288,16 @@ def __fspath__(self):
285288
def test_access_to_private_kwargs_and_url(urlpath):
286289
# fixme: this should be deprecated...
287290
pth = UPath(urlpath)
288-
assert isinstance(pth._kwargs, Mapping)
289-
assert pth._kwargs == {}
291+
with pytest.warns(DeprecationWarning, match="UPath._kwargs is deprecated"):
292+
assert isinstance(pth._kwargs, Mapping)
293+
with pytest.warns(DeprecationWarning, match="UPath._kwargs is deprecated"):
294+
assert pth._kwargs == {}
290295
assert isinstance(pth._url, SplitResult)
291296
assert pth._url.scheme == "" or pth._url.scheme in pth.fs.protocol
292297
assert pth._url.path == pth.path
293298
subpth = pth / "foo"
294-
assert subpth._kwargs == {}
299+
with pytest.warns(DeprecationWarning, match="UPath._kwargs is deprecated"):
300+
assert subpth._kwargs == {}
295301
assert isinstance(subpth._url, SplitResult)
296302
assert subpth._url.scheme == "" or subpth._url.scheme in subpth.fs.protocol
297303
assert subpth._url.path == subpth.path

0 commit comments

Comments
 (0)