|
| 1 | +import contextlib |
1 | 2 | import io |
2 | 3 | import itertools |
3 | | -import contextlib |
4 | 4 | import pathlib |
5 | 5 | import pickle |
6 | 6 | import stat |
|
10 | 10 | import zipfile |
11 | 11 | import zipfile._path |
12 | 12 |
|
13 | | -from test.support.os_helper import temp_dir, FakePath |
| 13 | +from test.support.os_helper import FakePath, temp_dir |
14 | 14 |
|
15 | 15 | from ._functools import compose |
16 | 16 | from ._itertools import Counter |
17 | | - |
18 | | -from ._test_params import parameterize, Invoked |
| 17 | +from ._test_params import Invoked, parameterize |
19 | 18 |
|
20 | 19 |
|
21 | 20 | class jaraco: |
@@ -194,10 +193,10 @@ def test_encoding_warnings(self, alpharep): |
194 | 193 | """EncodingWarning must blame the read_text and open calls.""" |
195 | 194 | assert sys.flags.warn_default_encoding |
196 | 195 | root = zipfile.Path(alpharep) |
197 | | - with self.assertWarns(EncodingWarning) as wc: |
| 196 | + with self.assertWarns(EncodingWarning) as wc: # noqa: F821 (astral-sh/ruff#13296) |
198 | 197 | root.joinpath("a.txt").read_text() |
199 | 198 | assert __file__ == wc.filename |
200 | | - with self.assertWarns(EncodingWarning) as wc: |
| 199 | + with self.assertWarns(EncodingWarning) as wc: # noqa: F821 (astral-sh/ruff#13296) |
201 | 200 | root.joinpath("a.txt").open("r").close() |
202 | 201 | assert __file__ == wc.filename |
203 | 202 |
|
@@ -365,6 +364,17 @@ def test_root_name(self, alpharep): |
365 | 364 | root = zipfile.Path(alpharep) |
366 | 365 | assert root.name == 'alpharep.zip' == root.filename.name |
367 | 366 |
|
| 367 | + @pass_alpharep |
| 368 | + def test_root_on_disk(self, alpharep): |
| 369 | + """ |
| 370 | + The name/stem of the root should match the zipfile on disk. |
| 371 | +
|
| 372 | + This condition must hold across platforms. |
| 373 | + """ |
| 374 | + root = zipfile.Path(self.zipfile_ondisk(alpharep)) |
| 375 | + assert root.name == 'alpharep.zip' == root.filename.name |
| 376 | + assert root.stem == 'alpharep' == root.filename.stem |
| 377 | + |
368 | 378 | @pass_alpharep |
369 | 379 | def test_suffix(self, alpharep): |
370 | 380 | """ |
|
0 commit comments