mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
* Add Lib/test/archiver_tests.py @ 3.13.5 Needed for updated zipfile tests. * Update zipfile to 3.13.5 Notes: - I have to skip some brand new tests due to shift_jis encoding not being supported - `test_write_filtered_python_package` marked as `expectedFailure` with "AttributeError: module 'os' has no attribute 'supports_effective_ids'" - I didn't want to do a partial or full update to os module in this PR --------- Co-authored-by: Jack O'Connor <jack@jackoconnor.dev>
40 lines
905 B
Python
Vendored
40 lines
905 B
Python
Vendored
import functools
|
|
import types
|
|
|
|
from ._itertools import always_iterable
|
|
|
|
|
|
def parameterize(names, value_groups):
|
|
"""
|
|
Decorate a test method to run it as a set of subtests.
|
|
|
|
Modeled after pytest.parametrize.
|
|
"""
|
|
|
|
def decorator(func):
|
|
@functools.wraps(func)
|
|
def wrapped(self):
|
|
for values in value_groups:
|
|
resolved = map(Invoked.eval, always_iterable(values))
|
|
params = dict(zip(always_iterable(names), resolved))
|
|
with self.subTest(**params):
|
|
func(self, **params)
|
|
|
|
return wrapped
|
|
|
|
return decorator
|
|
|
|
|
|
class Invoked(types.SimpleNamespace):
|
|
"""
|
|
Wrap a function to be invoked for each usage.
|
|
"""
|
|
|
|
@classmethod
|
|
def wrap(cls, func):
|
|
return cls(func=func)
|
|
|
|
@classmethod
|
|
def eval(cls, cand):
|
|
return cand.func() if isinstance(cand, cls) else cand
|