Mercurial > p > roundup > code
view test/pytest_patcher.py @ 7032:f529cca242dc
flake8: fix imports,
flake8 reported the following:
templating.py:25:1: F401 'base64' imported but unused
templating.py:25:1: F401 'mimetypes' imported but unused
templating.py:25:1: F401 'string' imported but unused
templating.py:28:1: F401 'time' imported but unused
templating.py:28:1: F401 'hashlib' imported but unused
templating.py:34:1: F401 'roundup.i18n' imported but unused
templating.py:35:1: F401 'roundup.i18n._' imported but unused
templating.py:36:1: F401 'roundup.anypy.strings.b2s' imported but unused
templating.py:36:1: F401 'roundup.anypy.strings.s2b' imported but unused
templating.py:43:1: F401 'roundup.anypy.random_' imported but unused
templating.py:47:5: F401 'pickle' imported but unused
Turns out time import was used by test_templating via
from roundup.cgi.templating import *
so added import time to test_templating
Also split out multiple imports on one line into sepearate lines.
Changed
todo =
to
__todo__
to make flake8 shut up about module level imports not at top of
file. Moved definiton of _disable_url_schemes for same reason.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sun, 09 Oct 2022 18:40:46 -0400 |
| parents | 1c94afabb2cb |
| children |
line wrap: on
line source
""" The following code was taken from: https://github.com/pytest-dev/pytest/issues/568#issuecomment-216569420 to resolve a bug with using pytest.mark.skip(). Once the bug is resolved in pytest this file can be removed along with all the wrapper mark_class() references in the other test files. """ import types def mark_class(marker): '''Workaround for https://github.com/pytest-dev/pytest/issues/568''' def copy_func(f): try: return types.FunctionType(f.__code__, f.__globals__, name=f.__name__, argdefs=f.__defaults__, closure=f.__closure__) except AttributeError: return types.FunctionType(f.func_code, f.func_globals, name=f.func_name, argdefs=f.func_defaults, closure=f.func_closure) def mark(cls): if isinstance(cls, types.FunctionType): return marker(copy_func(cls)) for method in dir(cls): if method.startswith('test'): f = copy_func(getattr(cls, method)) setattr(cls, method, marker(f)) return cls return mark
