mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-46125: Refactor tests to test traversable API directly. Includes changes from importlib_resources 5.4.0. (GH-30189)
This commit is contained in:
parent
fe68486197
commit
9b52920173
11 changed files with 152 additions and 211 deletions
|
@ -1,10 +1,8 @@
|
|||
import abc
|
||||
import contextlib
|
||||
import importlib
|
||||
import io
|
||||
import sys
|
||||
import types
|
||||
import warnings
|
||||
from pathlib import Path, PurePath
|
||||
|
||||
from .. import data01
|
||||
|
@ -69,13 +67,6 @@ def create_package(file=None, path=None, is_package=True, contents=()):
|
|||
)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def suppress_known_deprecation():
|
||||
with warnings.catch_warnings(record=True) as ctx:
|
||||
warnings.simplefilter('default', category=DeprecationWarning)
|
||||
yield ctx
|
||||
|
||||
|
||||
class CommonTests(metaclass=abc.ABCMeta):
|
||||
"""
|
||||
Tests shared by test_open, test_path, and test_read.
|
||||
|
@ -106,18 +97,6 @@ class CommonTests(metaclass=abc.ABCMeta):
|
|||
path = PurePath('utf-8.file')
|
||||
self.execute(data01, path)
|
||||
|
||||
def test_absolute_path(self):
|
||||
# An absolute path is a ValueError.
|
||||
path = Path(__file__)
|
||||
full_path = path.parent / 'utf-8.file'
|
||||
with self.assertRaises(ValueError):
|
||||
self.execute(data01, full_path)
|
||||
|
||||
def test_relative_path(self):
|
||||
# A reative path is a ValueError.
|
||||
with self.assertRaises(ValueError):
|
||||
self.execute(data01, '../data01/utf-8.file')
|
||||
|
||||
def test_importing_module_as_side_effect(self):
|
||||
# The anchor package can already be imported.
|
||||
del sys.modules[data01.__name__]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue