Remove no longer needed `noqa: F821` uses
Not needed since pyflakes 2.2.0.
This commit is contained in:
parent
fc702ab7e4
commit
a2f021b6f3
|
@ -98,12 +98,12 @@ class AlwaysDispatchingPrettyPrinter(pprint.PrettyPrinter):
|
||||||
level: int,
|
level: int,
|
||||||
) -> None:
|
) -> None:
|
||||||
# Type ignored because _dispatch is private.
|
# Type ignored because _dispatch is private.
|
||||||
p = self._dispatch.get(type(object).__repr__, None) # type: ignore[attr-defined] # noqa: F821
|
p = self._dispatch.get(type(object).__repr__, None) # type: ignore[attr-defined]
|
||||||
|
|
||||||
objid = id(object)
|
objid = id(object)
|
||||||
if objid in context or p is None:
|
if objid in context or p is None:
|
||||||
# Type ignored because _format is private.
|
# Type ignored because _format is private.
|
||||||
super()._format( # type: ignore[misc] # noqa: F821
|
super()._format( # type: ignore[misc]
|
||||||
object, stream, indent, allowance, context, level,
|
object, stream, indent, allowance, context, level,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
|
@ -146,7 +146,7 @@ class pytestPDB:
|
||||||
|
|
||||||
# Type ignored because mypy doesn't support "dynamic"
|
# Type ignored because mypy doesn't support "dynamic"
|
||||||
# inheritance like this.
|
# inheritance like this.
|
||||||
class PytestPdbWrapper(pdb_cls): # type: ignore[valid-type,misc] # noqa: F821
|
class PytestPdbWrapper(pdb_cls): # type: ignore[valid-type,misc]
|
||||||
_pytest_capman = capman
|
_pytest_capman = capman
|
||||||
_continued = False
|
_continued = False
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ def _enter_pdb(
|
||||||
rep.toterminal(tw)
|
rep.toterminal(tw)
|
||||||
tw.sep(">", "entering PDB")
|
tw.sep(">", "entering PDB")
|
||||||
tb = _postmortem_traceback(excinfo)
|
tb = _postmortem_traceback(excinfo)
|
||||||
rep._pdbshown = True # type: ignore[attr-defined] # noqa: F821
|
rep._pdbshown = True # type: ignore[attr-defined]
|
||||||
post_mortem(tb)
|
post_mortem(tb)
|
||||||
return rep
|
return rep
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,7 @@ class DoctestItem(pytest.Item):
|
||||||
failures = [] # type: List[doctest.DocTestFailure]
|
failures = [] # type: List[doctest.DocTestFailure]
|
||||||
# Type ignored because we change the type of `out` from what
|
# Type ignored because we change the type of `out` from what
|
||||||
# doctest expects.
|
# doctest expects.
|
||||||
self.runner.run(self.dtest, out=failures) # type: ignore[arg-type] # noqa: F821
|
self.runner.run(self.dtest, out=failures) # type: ignore[arg-type]
|
||||||
if failures:
|
if failures:
|
||||||
raise MultipleDoctestFailures(failures)
|
raise MultipleDoctestFailures(failures)
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ class DoctestItem(pytest.Item):
|
||||||
sys.stderr.write(err)
|
sys.stderr.write(err)
|
||||||
|
|
||||||
# TODO: Type ignored -- breaks Liskov Substitution.
|
# TODO: Type ignored -- breaks Liskov Substitution.
|
||||||
def repr_failure( # type: ignore[override] # noqa: F821
|
def repr_failure( # type: ignore[override]
|
||||||
self, excinfo: ExceptionInfo[BaseException],
|
self, excinfo: ExceptionInfo[BaseException],
|
||||||
) -> Union[str, TerminalRepr]:
|
) -> Union[str, TerminalRepr]:
|
||||||
import doctest
|
import doctest
|
||||||
|
@ -329,7 +329,7 @@ class DoctestItem(pytest.Item):
|
||||||
lineno = test.lineno + example.lineno + 1
|
lineno = test.lineno + example.lineno + 1
|
||||||
message = type(failure).__name__
|
message = type(failure).__name__
|
||||||
# TODO: ReprFileLocation doesn't expect a None lineno.
|
# TODO: ReprFileLocation doesn't expect a None lineno.
|
||||||
reprlocation = ReprFileLocation(filename, lineno, message) # type: ignore[arg-type] # noqa: F821
|
reprlocation = ReprFileLocation(filename, lineno, message) # type: ignore[arg-type]
|
||||||
checker = _get_checker()
|
checker = _get_checker()
|
||||||
report_choice = _get_report_choice(
|
report_choice = _get_report_choice(
|
||||||
self.config.getoption("doctestreport")
|
self.config.getoption("doctestreport")
|
||||||
|
@ -567,9 +567,9 @@ def _setup_fixtures(doctest_item: DoctestItem) -> FixtureRequest:
|
||||||
def func() -> None:
|
def func() -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
doctest_item.funcargs = {} # type: ignore[attr-defined] # noqa: F821
|
doctest_item.funcargs = {} # type: ignore[attr-defined]
|
||||||
fm = doctest_item.session._fixturemanager
|
fm = doctest_item.session._fixturemanager
|
||||||
doctest_item._fixtureinfo = fm.getfixtureinfo( # type: ignore[attr-defined] # noqa: F821
|
doctest_item._fixtureinfo = fm.getfixtureinfo( # type: ignore[attr-defined]
|
||||||
node=doctest_item, func=func, cls=None, funcargs=False
|
node=doctest_item, func=func, cls=None, funcargs=False
|
||||||
)
|
)
|
||||||
fixture_request = FixtureRequest(doctest_item)
|
fixture_request = FixtureRequest(doctest_item)
|
||||||
|
|
|
@ -248,7 +248,7 @@ def get_parametrized_fixture_keys(item: "nodes.Item", scopenum: int) -> Iterator
|
||||||
the specified scope. """
|
the specified scope. """
|
||||||
assert scopenum < scopenum_function # function
|
assert scopenum < scopenum_function # function
|
||||||
try:
|
try:
|
||||||
callspec = item.callspec # type: ignore[attr-defined] # noqa: F821
|
callspec = item.callspec # type: ignore[attr-defined]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -266,7 +266,7 @@ def get_parametrized_fixture_keys(item: "nodes.Item", scopenum: int) -> Iterator
|
||||||
elif scopenum == 2: # module
|
elif scopenum == 2: # module
|
||||||
key = (argname, param_index, item.fspath)
|
key = (argname, param_index, item.fspath)
|
||||||
elif scopenum == 3: # class
|
elif scopenum == 3: # class
|
||||||
item_cls = item.cls # type: ignore[attr-defined] # noqa: F821
|
item_cls = item.cls # type: ignore[attr-defined]
|
||||||
key = (argname, param_index, item.fspath, item_cls)
|
key = (argname, param_index, item.fspath, item_cls)
|
||||||
yield key
|
yield key
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ class FixtureRequest:
|
||||||
fixturedefs = self._fixturemanager.getfixturedefs(argname, parentid)
|
fixturedefs = self._fixturemanager.getfixturedefs(argname, parentid)
|
||||||
# TODO: Fix this type ignore. Either add assert or adjust types.
|
# TODO: Fix this type ignore. Either add assert or adjust types.
|
||||||
# Can this be None here?
|
# Can this be None here?
|
||||||
self._arg2fixturedefs[argname] = fixturedefs # type: ignore[assignment] # noqa: F821
|
self._arg2fixturedefs[argname] = fixturedefs # type: ignore[assignment]
|
||||||
# fixturedefs list is immutable so we maintain a decreasing index
|
# fixturedefs list is immutable so we maintain a decreasing index
|
||||||
index = self._arg2index.get(argname, 0) - 1
|
index = self._arg2index.get(argname, 0) - 1
|
||||||
if fixturedefs is None or (-index > len(fixturedefs)):
|
if fixturedefs is None or (-index > len(fixturedefs)):
|
||||||
|
@ -723,7 +723,7 @@ class FixtureRequest:
|
||||||
if scope == "package":
|
if scope == "package":
|
||||||
# FIXME: _fixturedef is not defined on FixtureRequest (this class),
|
# FIXME: _fixturedef is not defined on FixtureRequest (this class),
|
||||||
# but on FixtureRequest (a subclass).
|
# but on FixtureRequest (a subclass).
|
||||||
node = get_scope_package(self._pyfuncitem, self._fixturedef) # type: ignore[attr-defined] # noqa: F821
|
node = get_scope_package(self._pyfuncitem, self._fixturedef) # type: ignore[attr-defined]
|
||||||
else:
|
else:
|
||||||
node = get_scope_node(self._pyfuncitem, scope)
|
node = get_scope_node(self._pyfuncitem, scope)
|
||||||
if node is None and scope == "class":
|
if node is None and scope == "class":
|
||||||
|
@ -944,7 +944,7 @@ def _eval_scope_callable(
|
||||||
try:
|
try:
|
||||||
# Type ignored because there is no typing mechanism to specify
|
# Type ignored because there is no typing mechanism to specify
|
||||||
# keyword arguments, currently.
|
# keyword arguments, currently.
|
||||||
result = scope_callable(fixture_name=fixture_name, config=config) # type: ignore[call-arg] # noqa: F821
|
result = scope_callable(fixture_name=fixture_name, config=config) # type: ignore[call-arg]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"Error evaluating {} while defining fixture '{}'.\n"
|
"Error evaluating {} while defining fixture '{}'.\n"
|
||||||
|
@ -1081,7 +1081,7 @@ def resolve_fixture_function(
|
||||||
if fixturedef.unittest:
|
if fixturedef.unittest:
|
||||||
if request.instance is not None:
|
if request.instance is not None:
|
||||||
# bind the unbound method to the TestCase instance
|
# bind the unbound method to the TestCase instance
|
||||||
fixturefunc = fixturedef.func.__get__(request.instance) # type: ignore[union-attr] # noqa: F821
|
fixturefunc = fixturedef.func.__get__(request.instance) # type: ignore[union-attr]
|
||||||
else:
|
else:
|
||||||
# the fixture function needs to be bound to the actual
|
# the fixture function needs to be bound to the actual
|
||||||
# request.instance so that code working with "fixturedef" behaves
|
# request.instance so that code working with "fixturedef" behaves
|
||||||
|
@ -1090,12 +1090,12 @@ def resolve_fixture_function(
|
||||||
# handle the case where fixture is defined not in a test class, but some other class
|
# handle the case where fixture is defined not in a test class, but some other class
|
||||||
# (for example a plugin class with a fixture), see #2270
|
# (for example a plugin class with a fixture), see #2270
|
||||||
if hasattr(fixturefunc, "__self__") and not isinstance(
|
if hasattr(fixturefunc, "__self__") and not isinstance(
|
||||||
request.instance, fixturefunc.__self__.__class__ # type: ignore[union-attr] # noqa: F821
|
request.instance, fixturefunc.__self__.__class__ # type: ignore[union-attr]
|
||||||
):
|
):
|
||||||
return fixturefunc
|
return fixturefunc
|
||||||
fixturefunc = getimfunc(fixturedef.func)
|
fixturefunc = getimfunc(fixturedef.func)
|
||||||
if fixturefunc != fixturedef.func:
|
if fixturefunc != fixturedef.func:
|
||||||
fixturefunc = fixturefunc.__get__(request.instance) # type: ignore[union-attr] # noqa: F821
|
fixturefunc = fixturefunc.__get__(request.instance) # type: ignore[union-attr]
|
||||||
return fixturefunc
|
return fixturefunc
|
||||||
|
|
||||||
|
|
||||||
|
@ -1167,7 +1167,7 @@ def wrap_function_to_error_out_if_called_directly(function, fixture_marker):
|
||||||
|
|
||||||
# keep reference to the original function in our own custom attribute so we don't unwrap
|
# keep reference to the original function in our own custom attribute so we don't unwrap
|
||||||
# further than this point and lose useful wrappings like @mock.patch (#3774)
|
# further than this point and lose useful wrappings like @mock.patch (#3774)
|
||||||
result.__pytest_wrapped__ = _PytestWrapper(function) # type: ignore[attr-defined] # noqa: F821
|
result.__pytest_wrapped__ = _PytestWrapper(function) # type: ignore[attr-defined]
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -1209,7 +1209,7 @@ class FixtureFunctionMarker:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Type ignored because https://github.com/python/mypy/issues/2087.
|
# Type ignored because https://github.com/python/mypy/issues/2087.
|
||||||
function._pytestfixturefunction = self # type: ignore[attr-defined] # noqa: F821
|
function._pytestfixturefunction = self # type: ignore[attr-defined]
|
||||||
return function
|
return function
|
||||||
|
|
||||||
|
|
||||||
|
@ -1503,7 +1503,7 @@ class FixtureManager:
|
||||||
def pytest_plugin_registered(self, plugin: _PluggyPlugin) -> None:
|
def pytest_plugin_registered(self, plugin: _PluggyPlugin) -> None:
|
||||||
nodeid = None
|
nodeid = None
|
||||||
try:
|
try:
|
||||||
p = py.path.local(plugin.__file__) # type: ignore[attr-defined] # noqa: F821
|
p = py.path.local(plugin.__file__) # type: ignore[attr-defined]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -281,7 +281,7 @@ class _NodeReporter:
|
||||||
self.__dict__.clear()
|
self.__dict__.clear()
|
||||||
# Type ignored becuase mypy doesn't like overriding a method.
|
# Type ignored becuase mypy doesn't like overriding a method.
|
||||||
# Also the return value doesn't match...
|
# Also the return value doesn't match...
|
||||||
self.to_xml = lambda: py.xml.raw(data) # type: ignore # noqa: F821
|
self.to_xml = lambda: py.xml.raw(data) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def _warn_incompatibility_with_xunit2(
|
def _warn_incompatibility_with_xunit2(
|
||||||
|
|
|
@ -165,7 +165,7 @@ class PercentStyleMultiline(logging.PercentStyle):
|
||||||
if "\n" in record.message:
|
if "\n" in record.message:
|
||||||
if hasattr(record, "auto_indent"):
|
if hasattr(record, "auto_indent"):
|
||||||
# passed in from the "extra={}" kwarg on the call to logging.log()
|
# passed in from the "extra={}" kwarg on the call to logging.log()
|
||||||
auto_indent = self._get_auto_indent(record.auto_indent) # type: ignore[attr-defined] # noqa: F821
|
auto_indent = self._get_auto_indent(record.auto_indent) # type: ignore[attr-defined]
|
||||||
else:
|
else:
|
||||||
auto_indent = self._auto_indent
|
auto_indent = self._auto_indent
|
||||||
|
|
||||||
|
@ -755,7 +755,7 @@ class _LiveLoggingStreamHandler(logging.StreamHandler):
|
||||||
:param _pytest.terminal.TerminalReporter terminal_reporter:
|
:param _pytest.terminal.TerminalReporter terminal_reporter:
|
||||||
:param _pytest.capture.CaptureManager capture_manager:
|
:param _pytest.capture.CaptureManager capture_manager:
|
||||||
"""
|
"""
|
||||||
logging.StreamHandler.__init__(self, stream=terminal_reporter) # type: ignore[arg-type] # noqa: F821
|
logging.StreamHandler.__init__(self, stream=terminal_reporter) # type: ignore[arg-type]
|
||||||
self.capture_manager = capture_manager
|
self.capture_manager = capture_manager
|
||||||
self.reset()
|
self.reset()
|
||||||
self.set_when(None)
|
self.set_when(None)
|
||||||
|
|
|
@ -124,7 +124,7 @@ class ParameterSet(
|
||||||
#
|
#
|
||||||
# @pytest.mark.parametrize(('x', 'y'), [1, 2])
|
# @pytest.mark.parametrize(('x', 'y'), [1, 2])
|
||||||
# def test_foo(x, y): pass
|
# def test_foo(x, y): pass
|
||||||
return cls(parameterset, marks=[], id=None) # type: ignore[arg-type] # noqa: F821
|
return cls(parameterset, marks=[], id=None) # type: ignore[arg-type]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_parametrize_args(
|
def _parse_parametrize_args(
|
||||||
|
@ -320,7 +320,7 @@ class MarkDecorator:
|
||||||
# return type. Not much we can do about that. Thankfully mypy picks
|
# return type. Not much we can do about that. Thankfully mypy picks
|
||||||
# the first match so it works out even if we break the rules.
|
# the first match so it works out even if we break the rules.
|
||||||
@overload
|
@overload
|
||||||
def __call__(self, arg: _Markable) -> _Markable: # type: ignore[misc] # noqa: F821
|
def __call__(self, arg: _Markable) -> _Markable: # type: ignore[misc]
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@overload # noqa: F811
|
@overload # noqa: F811
|
||||||
|
|
|
@ -457,7 +457,7 @@ class Collector(Node):
|
||||||
raise NotImplementedError("abstract")
|
raise NotImplementedError("abstract")
|
||||||
|
|
||||||
# TODO: This omits the style= parameter which breaks Liskov Substitution.
|
# TODO: This omits the style= parameter which breaks Liskov Substitution.
|
||||||
def repr_failure( # type: ignore[override] # noqa: F821
|
def repr_failure( # type: ignore[override]
|
||||||
self, excinfo: ExceptionInfo[BaseException]
|
self, excinfo: ExceptionInfo[BaseException]
|
||||||
) -> Union[str, TerminalRepr]:
|
) -> Union[str, TerminalRepr]:
|
||||||
"""
|
"""
|
||||||
|
@ -600,7 +600,7 @@ class FSCollector(Collector):
|
||||||
else:
|
else:
|
||||||
duplicate_paths.add(path)
|
duplicate_paths.add(path)
|
||||||
|
|
||||||
return ihook.pytest_collect_file(path=path, parent=self) # type: ignore[no-any-return] # noqa: F723
|
return ihook.pytest_collect_file(path=path, parent=self) # type: ignore[no-any-return]
|
||||||
|
|
||||||
|
|
||||||
class File(FSCollector):
|
class File(FSCollector):
|
||||||
|
|
|
@ -299,7 +299,7 @@ class PyobjMixin:
|
||||||
"""Gets the underlying Python object. May be overwritten by subclasses."""
|
"""Gets the underlying Python object. May be overwritten by subclasses."""
|
||||||
# TODO: Improve the type of `parent` such that assert/ignore aren't needed.
|
# TODO: Improve the type of `parent` such that assert/ignore aren't needed.
|
||||||
assert self.parent is not None
|
assert self.parent is not None
|
||||||
obj = self.parent.obj # type: ignore[attr-defined] # noqa: F821
|
obj = self.parent.obj # type: ignore[attr-defined]
|
||||||
return getattr(obj, self.name)
|
return getattr(obj, self.name)
|
||||||
|
|
||||||
def getmodpath(self, stopatmodule: bool = True, includemodule: bool = False) -> str:
|
def getmodpath(self, stopatmodule: bool = True, includemodule: bool = False) -> str:
|
||||||
|
@ -784,7 +784,7 @@ class Instance(PyCollector):
|
||||||
def _getobj(self):
|
def _getobj(self):
|
||||||
# TODO: Improve the type of `parent` such that assert/ignore aren't needed.
|
# TODO: Improve the type of `parent` such that assert/ignore aren't needed.
|
||||||
assert self.parent is not None
|
assert self.parent is not None
|
||||||
obj = self.parent.obj # type: ignore[attr-defined] # noqa: F821
|
obj = self.parent.obj # type: ignore[attr-defined]
|
||||||
return obj()
|
return obj()
|
||||||
|
|
||||||
def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
|
def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
|
||||||
|
@ -1593,7 +1593,7 @@ class Function(PyobjMixin, nodes.Item):
|
||||||
entry.set_repr_style("short")
|
entry.set_repr_style("short")
|
||||||
|
|
||||||
# TODO: Type ignored -- breaks Liskov Substitution.
|
# TODO: Type ignored -- breaks Liskov Substitution.
|
||||||
def repr_failure( # type: ignore[override] # noqa: F821
|
def repr_failure( # type: ignore[override]
|
||||||
self, excinfo: ExceptionInfo[BaseException],
|
self, excinfo: ExceptionInfo[BaseException],
|
||||||
) -> Union[str, TerminalRepr]:
|
) -> Union[str, TerminalRepr]:
|
||||||
style = self.config.getoption("tbstyle", "auto")
|
style = self.config.getoption("tbstyle", "auto")
|
||||||
|
|
|
@ -165,7 +165,7 @@ class WarningsRecorder(warnings.catch_warnings):
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
# Type ignored due to the way typeshed handles warnings.catch_warnings.
|
# Type ignored due to the way typeshed handles warnings.catch_warnings.
|
||||||
super().__init__(record=True) # type: ignore[call-arg] # noqa: F821
|
super().__init__(record=True) # type: ignore[call-arg]
|
||||||
self._entered = False
|
self._entered = False
|
||||||
self._list = [] # type: List[warnings.WarningMessage]
|
self._list = [] # type: List[warnings.WarningMessage]
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,8 @@ def runtestprotocol(
|
||||||
item: Item, log: bool = True, nextitem: Optional[Item] = None
|
item: Item, log: bool = True, nextitem: Optional[Item] = None
|
||||||
) -> List[TestReport]:
|
) -> List[TestReport]:
|
||||||
hasrequest = hasattr(item, "_request")
|
hasrequest = hasattr(item, "_request")
|
||||||
if hasrequest and not item._request: # type: ignore[attr-defined] # noqa: F821
|
if hasrequest and not item._request: # type: ignore[attr-defined]
|
||||||
item._initrequest() # type: ignore[attr-defined] # noqa: F821
|
item._initrequest() # type: ignore[attr-defined]
|
||||||
rep = call_and_report(item, "setup", log)
|
rep = call_and_report(item, "setup", log)
|
||||||
reports = [rep]
|
reports = [rep]
|
||||||
if rep.passed:
|
if rep.passed:
|
||||||
|
@ -119,8 +119,8 @@ def runtestprotocol(
|
||||||
# after all teardown hooks have been called
|
# after all teardown hooks have been called
|
||||||
# want funcargs and request info to go away
|
# want funcargs and request info to go away
|
||||||
if hasrequest:
|
if hasrequest:
|
||||||
item._request = False # type: ignore[attr-defined] # noqa: F821
|
item._request = False # type: ignore[attr-defined]
|
||||||
item.funcargs = None # type: ignore[attr-defined] # noqa: F821
|
item.funcargs = None # type: ignore[attr-defined]
|
||||||
return reports
|
return reports
|
||||||
|
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ class SetupState:
|
||||||
# check if the last collection node has raised an error
|
# check if the last collection node has raised an error
|
||||||
for col in self.stack:
|
for col in self.stack:
|
||||||
if hasattr(col, "_prepare_exc"):
|
if hasattr(col, "_prepare_exc"):
|
||||||
exc = col._prepare_exc # type: ignore[attr-defined] # noqa: F821
|
exc = col._prepare_exc # type: ignore[attr-defined]
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
needed_collectors = colitem.listchain()
|
needed_collectors = colitem.listchain()
|
||||||
|
@ -431,7 +431,7 @@ class SetupState:
|
||||||
try:
|
try:
|
||||||
col.setup()
|
col.setup()
|
||||||
except TEST_OUTCOME as e:
|
except TEST_OUTCOME as e:
|
||||||
col._prepare_exc = e # type: ignore[attr-defined] # noqa: F821
|
col._prepare_exc = e # type: ignore[attr-defined]
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ def pytest_fixture_setup(
|
||||||
param = fixturedef.ids[request.param_index]
|
param = fixturedef.ids[request.param_index]
|
||||||
else:
|
else:
|
||||||
param = request.param
|
param = request.param
|
||||||
fixturedef.cached_param = param # type: ignore[attr-defined] # noqa: F821
|
fixturedef.cached_param = param # type: ignore[attr-defined]
|
||||||
_show_fixture_action(fixturedef, "SETUP")
|
_show_fixture_action(fixturedef, "SETUP")
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ def pytest_fixture_post_finalizer(fixturedef: FixtureDef) -> None:
|
||||||
if config.option.setupshow:
|
if config.option.setupshow:
|
||||||
_show_fixture_action(fixturedef, "TEARDOWN")
|
_show_fixture_action(fixturedef, "TEARDOWN")
|
||||||
if hasattr(fixturedef, "cached_param"):
|
if hasattr(fixturedef, "cached_param"):
|
||||||
del fixturedef.cached_param # type: ignore[attr-defined] # noqa: F821
|
del fixturedef.cached_param # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
|
||||||
def _show_fixture_action(fixturedef: FixtureDef, msg: str) -> None:
|
def _show_fixture_action(fixturedef: FixtureDef, msg: str) -> None:
|
||||||
|
|
|
@ -56,7 +56,7 @@ def pytest_configure(config: Config) -> None:
|
||||||
def nop(*args, **kwargs):
|
def nop(*args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
nop.Exception = xfail.Exception # type: ignore[attr-defined] # noqa: F821
|
nop.Exception = xfail.Exception # type: ignore[attr-defined]
|
||||||
setattr(pytest, "xfail", nop)
|
setattr(pytest, "xfail", nop)
|
||||||
|
|
||||||
config.addinivalue_line(
|
config.addinivalue_line(
|
||||||
|
|
|
@ -1219,7 +1219,7 @@ def _get_line_with_reprcrash_message(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Type ignored intentionally -- possible AttributeError expected.
|
# Type ignored intentionally -- possible AttributeError expected.
|
||||||
msg = rep.longrepr.reprcrash.message # type: ignore[union-attr] # noqa: F821
|
msg = rep.longrepr.reprcrash.message # type: ignore[union-attr]
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -102,13 +102,13 @@ class UnitTestCase(Class):
|
||||||
cls, "setUpClass", "tearDownClass", scope="class", pass_self=False
|
cls, "setUpClass", "tearDownClass", scope="class", pass_self=False
|
||||||
)
|
)
|
||||||
if class_fixture:
|
if class_fixture:
|
||||||
cls.__pytest_class_setup = class_fixture # type: ignore[attr-defined] # noqa: F821
|
cls.__pytest_class_setup = class_fixture # type: ignore[attr-defined]
|
||||||
|
|
||||||
method_fixture = _make_xunit_fixture(
|
method_fixture = _make_xunit_fixture(
|
||||||
cls, "setup_method", "teardown_method", scope="function", pass_self=True
|
cls, "setup_method", "teardown_method", scope="function", pass_self=True
|
||||||
)
|
)
|
||||||
if method_fixture:
|
if method_fixture:
|
||||||
cls.__pytest_method_setup = method_fixture # type: ignore[attr-defined] # noqa: F821
|
cls.__pytest_method_setup = method_fixture # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
|
||||||
def _make_xunit_fixture(
|
def _make_xunit_fixture(
|
||||||
|
@ -148,7 +148,7 @@ class TestCaseFunction(Function):
|
||||||
# a bound method to be called during teardown() if set (see 'runtest()')
|
# a bound method to be called during teardown() if set (see 'runtest()')
|
||||||
self._explicit_tearDown = None # type: Optional[Callable[[], None]]
|
self._explicit_tearDown = None # type: Optional[Callable[[], None]]
|
||||||
assert self.parent is not None
|
assert self.parent is not None
|
||||||
self._testcase = self.parent.obj(self.name) # type: ignore[attr-defined] # noqa: F821
|
self._testcase = self.parent.obj(self.name) # type: ignore[attr-defined]
|
||||||
self._obj = getattr(self._testcase, self.name)
|
self._obj = getattr(self._testcase, self.name)
|
||||||
if hasattr(self, "_request"):
|
if hasattr(self, "_request"):
|
||||||
self._request._fillfixtures()
|
self._request._fillfixtures()
|
||||||
|
@ -167,7 +167,7 @@ class TestCaseFunction(Function):
|
||||||
# unwrap potential exception info (see twisted trial support below)
|
# unwrap potential exception info (see twisted trial support below)
|
||||||
rawexcinfo = getattr(rawexcinfo, "_rawexcinfo", rawexcinfo)
|
rawexcinfo = getattr(rawexcinfo, "_rawexcinfo", rawexcinfo)
|
||||||
try:
|
try:
|
||||||
excinfo = _pytest._code.ExceptionInfo(rawexcinfo) # type: ignore[arg-type] # noqa: F821
|
excinfo = _pytest._code.ExceptionInfo(rawexcinfo) # type: ignore[arg-type]
|
||||||
# invoke the attributes to trigger storing the traceback
|
# invoke the attributes to trigger storing the traceback
|
||||||
# trial causes some issue there
|
# trial causes some issue there
|
||||||
excinfo.value
|
excinfo.value
|
||||||
|
@ -259,7 +259,7 @@ class TestCaseFunction(Function):
|
||||||
# let the unittest framework handle async functions
|
# let the unittest framework handle async functions
|
||||||
if is_async_function(self.obj):
|
if is_async_function(self.obj):
|
||||||
# Type ignored because self acts as the TestResult, but is not actually one.
|
# Type ignored because self acts as the TestResult, but is not actually one.
|
||||||
self._testcase(result=self) # type: ignore[arg-type] # noqa: F821
|
self._testcase(result=self) # type: ignore[arg-type]
|
||||||
else:
|
else:
|
||||||
# when --pdb is given, we want to postpone calling tearDown() otherwise
|
# when --pdb is given, we want to postpone calling tearDown() otherwise
|
||||||
# when entering the pdb prompt, tearDown() would have probably cleaned up
|
# when entering the pdb prompt, tearDown() would have probably cleaned up
|
||||||
|
@ -275,7 +275,7 @@ class TestCaseFunction(Function):
|
||||||
# wrap_pytest_function_for_tracing replaces self.obj by a wrapper
|
# wrap_pytest_function_for_tracing replaces self.obj by a wrapper
|
||||||
setattr(self._testcase, self.name, self.obj)
|
setattr(self._testcase, self.name, self.obj)
|
||||||
try:
|
try:
|
||||||
self._testcase(result=self) # type: ignore[arg-type] # noqa: F821
|
self._testcase(result=self) # type: ignore[arg-type]
|
||||||
finally:
|
finally:
|
||||||
delattr(self._testcase, self.name)
|
delattr(self._testcase, self.name)
|
||||||
|
|
||||||
|
|
|
@ -752,7 +752,7 @@ raise ValueError()
|
||||||
from _pytest._code.code import Code
|
from _pytest._code.code import Code
|
||||||
|
|
||||||
monkeypatch.setattr(Code, "path", "bogus")
|
monkeypatch.setattr(Code, "path", "bogus")
|
||||||
excinfo.traceback[0].frame.code.path = "bogus" # type: ignore[misc] # noqa: F821
|
excinfo.traceback[0].frame.code.path = "bogus" # type: ignore[misc]
|
||||||
p = FormattedExcinfo(style="short")
|
p = FormattedExcinfo(style="short")
|
||||||
reprtb = p.repr_traceback_entry(excinfo.traceback[-2])
|
reprtb = p.repr_traceback_entry(excinfo.traceback[-2])
|
||||||
lines = reprtb.lines
|
lines = reprtb.lines
|
||||||
|
|
|
@ -16,4 +16,4 @@ def test_comparing_two_different_data_classes() -> None:
|
||||||
left = SimpleDataObjectOne(1, "b")
|
left = SimpleDataObjectOne(1, "b")
|
||||||
right = SimpleDataObjectTwo(1, "c")
|
right = SimpleDataObjectTwo(1, "c")
|
||||||
|
|
||||||
assert left != right # type: ignore[comparison-overlap] # noqa: F821
|
assert left != right # type: ignore[comparison-overlap]
|
||||||
|
|
|
@ -34,8 +34,8 @@ def test_exceptions() -> None:
|
||||||
raise self.ex
|
raise self.ex
|
||||||
|
|
||||||
class BrokenReprException(Exception):
|
class BrokenReprException(Exception):
|
||||||
__str__ = None # type: ignore[assignment] # noqa: F821
|
__str__ = None # type: ignore[assignment]
|
||||||
__repr__ = None # type: ignore[assignment] # noqa: F821
|
__repr__ = None # type: ignore[assignment]
|
||||||
|
|
||||||
assert "Exception" in saferepr(BrokenRepr(Exception("broken")))
|
assert "Exception" in saferepr(BrokenRepr(Exception("broken")))
|
||||||
s = saferepr(BrokenReprException("really broken"))
|
s = saferepr(BrokenReprException("really broken"))
|
||||||
|
@ -44,7 +44,7 @@ def test_exceptions() -> None:
|
||||||
|
|
||||||
none = None
|
none = None
|
||||||
try:
|
try:
|
||||||
none() # type: ignore[misc] # noqa: F821
|
none() # type: ignore[misc]
|
||||||
except BaseException as exc:
|
except BaseException as exc:
|
||||||
exp_exc = repr(exc)
|
exp_exc = repr(exc)
|
||||||
obj = BrokenRepr(BrokenReprException("omg even worse"))
|
obj = BrokenRepr(BrokenReprException("omg even worse"))
|
||||||
|
@ -139,7 +139,7 @@ def test_big_repr():
|
||||||
def test_repr_on_newstyle() -> None:
|
def test_repr_on_newstyle() -> None:
|
||||||
class Function:
|
class Function:
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<%s>" % (self.name) # type: ignore[attr-defined] # noqa: F821
|
return "<%s>" % (self.name) # type: ignore[attr-defined]
|
||||||
|
|
||||||
assert saferepr(Function())
|
assert saferepr(Function())
|
||||||
|
|
||||||
|
|
|
@ -724,10 +724,10 @@ class TestSorting:
|
||||||
assert fn1 != fn3
|
assert fn1 != fn3
|
||||||
|
|
||||||
for fn in fn1, fn2, fn3:
|
for fn in fn1, fn2, fn3:
|
||||||
assert fn != 3 # type: ignore[comparison-overlap] # noqa: F821
|
assert fn != 3 # type: ignore[comparison-overlap]
|
||||||
assert fn != modcol
|
assert fn != modcol
|
||||||
assert fn != [1, 2, 3] # type: ignore[comparison-overlap] # noqa: F821
|
assert fn != [1, 2, 3] # type: ignore[comparison-overlap]
|
||||||
assert [1, 2, 3] != fn # type: ignore[comparison-overlap] # noqa: F821
|
assert [1, 2, 3] != fn # type: ignore[comparison-overlap]
|
||||||
assert modcol != fn
|
assert modcol != fn
|
||||||
|
|
||||||
def test_allow_sane_sorting_for_decorators(self, testdir):
|
def test_allow_sane_sorting_for_decorators(self, testdir):
|
||||||
|
|
|
@ -3850,7 +3850,7 @@ class TestScopeOrdering:
|
||||||
)
|
)
|
||||||
testdir.runpytest()
|
testdir.runpytest()
|
||||||
# actual fixture execution differs: dependent fixtures must be created first ("my_tmpdir")
|
# actual fixture execution differs: dependent fixtures must be created first ("my_tmpdir")
|
||||||
FIXTURE_ORDER = pytest.FIXTURE_ORDER # type: ignore[attr-defined] # noqa: F821
|
FIXTURE_ORDER = pytest.FIXTURE_ORDER # type: ignore[attr-defined]
|
||||||
assert FIXTURE_ORDER == "s1 my_tmpdir_factory p1 m1 my_tmpdir f1 f2".split()
|
assert FIXTURE_ORDER == "s1 my_tmpdir_factory p1 m1 my_tmpdir f1 f2".split()
|
||||||
|
|
||||||
def test_func_closure_module(self, testdir):
|
def test_func_closure_module(self, testdir):
|
||||||
|
@ -4159,7 +4159,7 @@ def test_fixture_duplicated_arguments() -> None:
|
||||||
"""Raise error if there are positional and keyword arguments for the same parameter (#1682)."""
|
"""Raise error if there are positional and keyword arguments for the same parameter (#1682)."""
|
||||||
with pytest.raises(TypeError) as excinfo:
|
with pytest.raises(TypeError) as excinfo:
|
||||||
|
|
||||||
@pytest.fixture("session", scope="session") # type: ignore[call-overload] # noqa: F821
|
@pytest.fixture("session", scope="session") # type: ignore[call-overload]
|
||||||
def arg(arg):
|
def arg(arg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -4171,7 +4171,7 @@ def test_fixture_duplicated_arguments() -> None:
|
||||||
|
|
||||||
with pytest.raises(TypeError) as excinfo:
|
with pytest.raises(TypeError) as excinfo:
|
||||||
|
|
||||||
@pytest.fixture( # type: ignore[call-overload] # noqa: F821
|
@pytest.fixture( # type: ignore[call-overload]
|
||||||
"function",
|
"function",
|
||||||
["p1"],
|
["p1"],
|
||||||
True,
|
True,
|
||||||
|
@ -4199,7 +4199,7 @@ def test_fixture_with_positionals() -> None:
|
||||||
|
|
||||||
with pytest.warns(pytest.PytestDeprecationWarning) as warnings:
|
with pytest.warns(pytest.PytestDeprecationWarning) as warnings:
|
||||||
|
|
||||||
@pytest.fixture("function", [0], True) # type: ignore[call-overload] # noqa: F821
|
@pytest.fixture("function", [0], True) # type: ignore[call-overload]
|
||||||
def fixture_with_positionals():
|
def fixture_with_positionals():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -4213,7 +4213,7 @@ def test_fixture_with_positionals() -> None:
|
||||||
def test_fixture_with_too_many_positionals() -> None:
|
def test_fixture_with_too_many_positionals() -> None:
|
||||||
with pytest.raises(TypeError) as excinfo:
|
with pytest.raises(TypeError) as excinfo:
|
||||||
|
|
||||||
@pytest.fixture("function", [0], True, ["id"], "name", "extra") # type: ignore[call-overload] # noqa: F821
|
@pytest.fixture("function", [0], True, ["id"], "name", "extra") # type: ignore[call-overload]
|
||||||
def fixture_with_positionals():
|
def fixture_with_positionals():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ class TestMetafunc:
|
||||||
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
|
pytest.raises(ValueError, lambda: metafunc.parametrize("y", [5, 6]))
|
||||||
|
|
||||||
with pytest.raises(TypeError, match="^ids must be a callable or an iterable$"):
|
with pytest.raises(TypeError, match="^ids must be a callable or an iterable$"):
|
||||||
metafunc.parametrize("y", [5, 6], ids=42) # type: ignore[arg-type] # noqa: F821
|
metafunc.parametrize("y", [5, 6], ids=42) # type: ignore[arg-type]
|
||||||
|
|
||||||
def test_parametrize_error_iterator(self) -> None:
|
def test_parametrize_error_iterator(self) -> None:
|
||||||
def func(x):
|
def func(x):
|
||||||
|
@ -95,7 +95,7 @@ class TestMetafunc:
|
||||||
metafunc = self.Metafunc(func)
|
metafunc = self.Metafunc(func)
|
||||||
# When the input is an iterator, only len(args) are taken,
|
# When the input is an iterator, only len(args) are taken,
|
||||||
# so the bad Exc isn't reached.
|
# so the bad Exc isn't reached.
|
||||||
metafunc.parametrize("x", [1, 2], ids=gen()) # type: ignore[arg-type] # noqa: F821
|
metafunc.parametrize("x", [1, 2], ids=gen()) # type: ignore[arg-type]
|
||||||
assert [(x.funcargs, x.id) for x in metafunc._calls] == [
|
assert [(x.funcargs, x.id) for x in metafunc._calls] == [
|
||||||
({"x": 1}, "0"),
|
({"x": 1}, "0"),
|
||||||
({"x": 2}, "2"),
|
({"x": 2}, "2"),
|
||||||
|
@ -107,7 +107,7 @@ class TestMetafunc:
|
||||||
r" Exc\(from_gen\) \(type: <class .*Exc'>\) at index 2"
|
r" Exc\(from_gen\) \(type: <class .*Exc'>\) at index 2"
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
metafunc.parametrize("x", [1, 2, 3], ids=gen()) # type: ignore[arg-type] # noqa: F821
|
metafunc.parametrize("x", [1, 2, 3], ids=gen()) # type: ignore[arg-type]
|
||||||
|
|
||||||
def test_parametrize_bad_scope(self) -> None:
|
def test_parametrize_bad_scope(self) -> None:
|
||||||
def func(x):
|
def func(x):
|
||||||
|
@ -118,7 +118,7 @@ class TestMetafunc:
|
||||||
fail.Exception,
|
fail.Exception,
|
||||||
match=r"parametrize\(\) call in func got an unexpected scope value 'doggy'",
|
match=r"parametrize\(\) call in func got an unexpected scope value 'doggy'",
|
||||||
):
|
):
|
||||||
metafunc.parametrize("x", [1], scope="doggy") # type: ignore[arg-type] # noqa: F821
|
metafunc.parametrize("x", [1], scope="doggy") # type: ignore[arg-type]
|
||||||
|
|
||||||
def test_parametrize_request_name(self, testdir: Testdir) -> None:
|
def test_parametrize_request_name(self, testdir: Testdir) -> None:
|
||||||
"""Show proper error when 'request' is used as a parameter name in parametrize (#6183)"""
|
"""Show proper error when 'request' is used as a parameter name in parametrize (#6183)"""
|
||||||
|
@ -675,7 +675,7 @@ class TestMetafunc:
|
||||||
fail.Exception,
|
fail.Exception,
|
||||||
match="In func: expected Sequence or boolean for indirect, got dict",
|
match="In func: expected Sequence or boolean for indirect, got dict",
|
||||||
):
|
):
|
||||||
metafunc.parametrize("x, y", [("a", "b")], indirect={}) # type: ignore[arg-type] # noqa: F821
|
metafunc.parametrize("x, y", [("a", "b")], indirect={}) # type: ignore[arg-type]
|
||||||
|
|
||||||
def test_parametrize_indirect_list_functional(self, testdir: Testdir) -> None:
|
def test_parametrize_indirect_list_functional(self, testdir: Testdir) -> None:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -8,7 +8,7 @@ from _pytest.outcomes import Failed
|
||||||
class TestRaises:
|
class TestRaises:
|
||||||
def test_check_callable(self) -> None:
|
def test_check_callable(self) -> None:
|
||||||
with pytest.raises(TypeError, match=r".* must be callable"):
|
with pytest.raises(TypeError, match=r".* must be callable"):
|
||||||
pytest.raises(RuntimeError, "int('qwe')") # type: ignore[call-overload] # noqa: F821
|
pytest.raises(RuntimeError, "int('qwe')") # type: ignore[call-overload]
|
||||||
|
|
||||||
def test_raises(self):
|
def test_raises(self):
|
||||||
excinfo = pytest.raises(ValueError, int, "qwe")
|
excinfo = pytest.raises(ValueError, int, "qwe")
|
||||||
|
@ -30,7 +30,7 @@ class TestRaises:
|
||||||
|
|
||||||
def test_raises_falsey_type_error(self) -> None:
|
def test_raises_falsey_type_error(self) -> None:
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
with pytest.raises(AssertionError, match=0): # type: ignore[call-overload] # noqa: F821
|
with pytest.raises(AssertionError, match=0): # type: ignore[call-overload]
|
||||||
raise AssertionError("ohai")
|
raise AssertionError("ohai")
|
||||||
|
|
||||||
def test_raises_repr_inflight(self):
|
def test_raises_repr_inflight(self):
|
||||||
|
@ -128,11 +128,11 @@ class TestRaises:
|
||||||
|
|
||||||
def test_noclass(self) -> None:
|
def test_noclass(self) -> None:
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
pytest.raises("wrong", lambda: None) # type: ignore[call-overload] # noqa: F821
|
pytest.raises("wrong", lambda: None) # type: ignore[call-overload]
|
||||||
|
|
||||||
def test_invalid_arguments_to_raises(self) -> None:
|
def test_invalid_arguments_to_raises(self) -> None:
|
||||||
with pytest.raises(TypeError, match="unknown"):
|
with pytest.raises(TypeError, match="unknown"):
|
||||||
with pytest.raises(TypeError, unknown="bogus"): # type: ignore[call-overload] # noqa: F821
|
with pytest.raises(TypeError, unknown="bogus"): # type: ignore[call-overload]
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
|
||||||
def test_tuple(self):
|
def test_tuple(self):
|
||||||
|
@ -262,12 +262,12 @@ class TestRaises:
|
||||||
assert False, "via __class__"
|
assert False, "via __class__"
|
||||||
|
|
||||||
with pytest.raises(AssertionError) as excinfo:
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
with pytest.raises(CrappyClass()): # type: ignore[call-overload] # noqa: F821
|
with pytest.raises(CrappyClass()): # type: ignore[call-overload]
|
||||||
pass
|
pass
|
||||||
assert "via __class__" in excinfo.value.args[0]
|
assert "via __class__" in excinfo.value.args[0]
|
||||||
|
|
||||||
def test_raises_context_manager_with_kwargs(self):
|
def test_raises_context_manager_with_kwargs(self):
|
||||||
with pytest.raises(TypeError) as excinfo:
|
with pytest.raises(TypeError) as excinfo:
|
||||||
with pytest.raises(Exception, foo="bar"): # type: ignore[call-overload] # noqa: F821
|
with pytest.raises(Exception, foo="bar"): # type: ignore[call-overload]
|
||||||
pass
|
pass
|
||||||
assert "Unexpected keyword arguments" in str(excinfo.value)
|
assert "Unexpected keyword arguments" in str(excinfo.value)
|
||||||
|
|
|
@ -51,7 +51,7 @@ def getmsg(
|
||||||
exec(code, ns)
|
exec(code, ns)
|
||||||
func = ns[f.__name__]
|
func = ns[f.__name__]
|
||||||
try:
|
try:
|
||||||
func() # type: ignore[operator] # noqa: F821
|
func() # type: ignore[operator]
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if must_pass:
|
if must_pass:
|
||||||
pytest.fail("shouldn't have raised")
|
pytest.fail("shouldn't have raised")
|
||||||
|
@ -174,7 +174,7 @@ class TestAssertionRewrite:
|
||||||
assert getmsg(f3, {"a_global": False}) == "assert False"
|
assert getmsg(f3, {"a_global": False}) == "assert False"
|
||||||
|
|
||||||
def f4() -> None:
|
def f4() -> None:
|
||||||
assert sys == 42 # type: ignore[comparison-overlap] # noqa: F821
|
assert sys == 42 # type: ignore[comparison-overlap]
|
||||||
|
|
||||||
verbose = request.config.getoption("verbose")
|
verbose = request.config.getoption("verbose")
|
||||||
msg = getmsg(f4, {"sys": sys})
|
msg = getmsg(f4, {"sys": sys})
|
||||||
|
@ -684,7 +684,7 @@ class TestAssertionRewrite:
|
||||||
|
|
||||||
def test_formatchar(self) -> None:
|
def test_formatchar(self) -> None:
|
||||||
def f() -> None:
|
def f() -> None:
|
||||||
assert "%test" == "test" # type: ignore[comparison-overlap] # noqa: F821
|
assert "%test" == "test" # type: ignore[comparison-overlap]
|
||||||
|
|
||||||
msg = getmsg(f)
|
msg = getmsg(f)
|
||||||
assert msg is not None
|
assert msg is not None
|
||||||
|
@ -1264,7 +1264,7 @@ class TestEarlyRewriteBailout:
|
||||||
# use default patterns, otherwise we inherit pytest's testing config
|
# use default patterns, otherwise we inherit pytest's testing config
|
||||||
hook.fnpats[:] = ["test_*.py", "*_test.py"]
|
hook.fnpats[:] = ["test_*.py", "*_test.py"]
|
||||||
monkeypatch.setattr(hook, "_find_spec", spy_find_spec)
|
monkeypatch.setattr(hook, "_find_spec", spy_find_spec)
|
||||||
hook.set_session(StubSession()) # type: ignore[arg-type] # noqa: F821
|
hook.set_session(StubSession()) # type: ignore[arg-type]
|
||||||
testdir.syspathinsert()
|
testdir.syspathinsert()
|
||||||
return hook
|
return hook
|
||||||
|
|
||||||
|
|
|
@ -1537,7 +1537,7 @@ def test_encodedfile_writelines(tmpfile: BinaryIO) -> None:
|
||||||
ef = capture.EncodedFile(tmpfile, encoding="utf-8")
|
ef = capture.EncodedFile(tmpfile, encoding="utf-8")
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
ef.writelines([b"line1", b"line2"])
|
ef.writelines([b"line1", b"line2"])
|
||||||
assert ef.writelines(["line3", "line4"]) is None # type: ignore[func-returns-value] # noqa: F821
|
assert ef.writelines(["line3", "line4"]) is None # type: ignore[func-returns-value]
|
||||||
ef.flush()
|
ef.flush()
|
||||||
tmpfile.seek(0)
|
tmpfile.seek(0)
|
||||||
assert tmpfile.read() == b"line3line4"
|
assert tmpfile.read() == b"line3line4"
|
||||||
|
|
|
@ -41,10 +41,10 @@ class TestCollector:
|
||||||
|
|
||||||
for fn in fn1, fn2, fn3:
|
for fn in fn1, fn2, fn3:
|
||||||
assert isinstance(fn, pytest.Function)
|
assert isinstance(fn, pytest.Function)
|
||||||
assert fn != 3 # type: ignore[comparison-overlap] # noqa: F821
|
assert fn != 3 # type: ignore[comparison-overlap]
|
||||||
assert fn != modcol
|
assert fn != modcol
|
||||||
assert fn != [1, 2, 3] # type: ignore[comparison-overlap] # noqa: F821
|
assert fn != [1, 2, 3] # type: ignore[comparison-overlap]
|
||||||
assert [1, 2, 3] != fn # type: ignore[comparison-overlap] # noqa: F821
|
assert [1, 2, 3] != fn # type: ignore[comparison-overlap]
|
||||||
assert modcol != fn
|
assert modcol != fn
|
||||||
|
|
||||||
assert testdir.collect_by_name(modcol, "doesnotexist") is None
|
assert testdir.collect_by_name(modcol, "doesnotexist") is None
|
||||||
|
|
|
@ -1602,7 +1602,7 @@ def test_invocation_args(testdir):
|
||||||
|
|
||||||
# args cannot be None
|
# args cannot be None
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
Config.InvocationParams(args=None, plugins=None, dir=Path()) # type: ignore[arg-type] # noqa: F821
|
Config.InvocationParams(args=None, plugins=None, dir=Path()) # type: ignore[arg-type]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
|
@ -1490,7 +1490,7 @@ def test_warning_on_unwrap_of_broken_object(
|
||||||
pytest.PytestWarning, match="^Got KeyError.* when unwrapping"
|
pytest.PytestWarning, match="^Got KeyError.* when unwrapping"
|
||||||
):
|
):
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
inspect.unwrap(bad_instance, stop=stop) # type: ignore[arg-type] # noqa: F821
|
inspect.unwrap(bad_instance, stop=stop) # type: ignore[arg-type]
|
||||||
assert inspect.unwrap.__module__ == "inspect"
|
assert inspect.unwrap.__module__ == "inspect"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ def test_unicode_issue368(testdir) -> None:
|
||||||
node_reporter.append_skipped(test_report)
|
node_reporter.append_skipped(test_report)
|
||||||
test_report.longrepr = "filename", 1, "Skipped: 卡嘣嘣"
|
test_report.longrepr = "filename", 1, "Skipped: 卡嘣嘣"
|
||||||
node_reporter.append_skipped(test_report)
|
node_reporter.append_skipped(test_report)
|
||||||
test_report.wasxfail = ustr # type: ignore[attr-defined] # noqa: F821
|
test_report.wasxfail = ustr # type: ignore[attr-defined]
|
||||||
node_reporter.append_skipped(test_report)
|
node_reporter.append_skipped(test_report)
|
||||||
log.pytest_sessionfinish()
|
log.pytest_sessionfinish()
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class TestMark:
|
||||||
def test_pytest_mark_notcallable(self) -> None:
|
def test_pytest_mark_notcallable(self) -> None:
|
||||||
mark = Mark()
|
mark = Mark()
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
mark() # type: ignore[operator] # noqa: F821
|
mark() # type: ignore[operator]
|
||||||
|
|
||||||
def test_mark_with_param(self):
|
def test_mark_with_param(self):
|
||||||
def some_function(abc):
|
def some_function(abc):
|
||||||
|
@ -31,10 +31,10 @@ class TestMark:
|
||||||
|
|
||||||
assert pytest.mark.foo(some_function) is some_function
|
assert pytest.mark.foo(some_function) is some_function
|
||||||
marked_with_args = pytest.mark.foo.with_args(some_function)
|
marked_with_args = pytest.mark.foo.with_args(some_function)
|
||||||
assert marked_with_args is not some_function # type: ignore[comparison-overlap] # noqa: F821
|
assert marked_with_args is not some_function # type: ignore[comparison-overlap]
|
||||||
|
|
||||||
assert pytest.mark.foo(SomeClass) is SomeClass
|
assert pytest.mark.foo(SomeClass) is SomeClass
|
||||||
assert pytest.mark.foo.with_args(SomeClass) is not SomeClass # type: ignore[comparison-overlap] # noqa: F821
|
assert pytest.mark.foo.with_args(SomeClass) is not SomeClass # type: ignore[comparison-overlap]
|
||||||
|
|
||||||
def test_pytest_mark_name_starts_with_underscore(self):
|
def test_pytest_mark_name_starts_with_underscore(self):
|
||||||
mark = Mark()
|
mark = Mark()
|
||||||
|
@ -1077,7 +1077,7 @@ def test_markers_from_parametrize(testdir):
|
||||||
|
|
||||||
def test_pytest_param_id_requires_string() -> None:
|
def test_pytest_param_id_requires_string() -> None:
|
||||||
with pytest.raises(TypeError) as excinfo:
|
with pytest.raises(TypeError) as excinfo:
|
||||||
pytest.param(id=True) # type: ignore[arg-type] # noqa: F821
|
pytest.param(id=True) # type: ignore[arg-type]
|
||||||
(msg,) = excinfo.value.args
|
(msg,) = excinfo.value.args
|
||||||
assert msg == "Expected id to be a string, got <class 'bool'>: True"
|
assert msg == "Expected id to be a string, got <class 'bool'>: True"
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ def test_ischildnode(baseid: str, nodeid: str, expected: bool) -> None:
|
||||||
|
|
||||||
def test_node_from_parent_disallowed_arguments() -> None:
|
def test_node_from_parent_disallowed_arguments() -> None:
|
||||||
with pytest.raises(TypeError, match="session is"):
|
with pytest.raises(TypeError, match="session is"):
|
||||||
nodes.Node.from_parent(None, session=None) # type: ignore[arg-type] # noqa: F821
|
nodes.Node.from_parent(None, session=None) # type: ignore[arg-type]
|
||||||
with pytest.raises(TypeError, match="config is"):
|
with pytest.raises(TypeError, match="config is"):
|
||||||
nodes.Node.from_parent(None, config=None) # type: ignore[arg-type] # noqa: F821
|
nodes.Node.from_parent(None, config=None) # type: ignore[arg-type]
|
||||||
|
|
||||||
|
|
||||||
def test_std_warn_not_pytestwarning(testdir: Testdir) -> None:
|
def test_std_warn_not_pytestwarning(testdir: Testdir) -> None:
|
||||||
|
|
|
@ -484,20 +484,20 @@ def test_linematcher_with_nonlist() -> None:
|
||||||
|
|
||||||
lm = LineMatcher([])
|
lm = LineMatcher([])
|
||||||
with pytest.raises(TypeError, match="invalid type for lines2: set"):
|
with pytest.raises(TypeError, match="invalid type for lines2: set"):
|
||||||
lm.fnmatch_lines(set()) # type: ignore[arg-type] # noqa: F821
|
lm.fnmatch_lines(set()) # type: ignore[arg-type]
|
||||||
with pytest.raises(TypeError, match="invalid type for lines2: dict"):
|
with pytest.raises(TypeError, match="invalid type for lines2: dict"):
|
||||||
lm.fnmatch_lines({}) # type: ignore[arg-type] # noqa: F821
|
lm.fnmatch_lines({}) # type: ignore[arg-type]
|
||||||
with pytest.raises(TypeError, match="invalid type for lines2: set"):
|
with pytest.raises(TypeError, match="invalid type for lines2: set"):
|
||||||
lm.re_match_lines(set()) # type: ignore[arg-type] # noqa: F821
|
lm.re_match_lines(set()) # type: ignore[arg-type]
|
||||||
with pytest.raises(TypeError, match="invalid type for lines2: dict"):
|
with pytest.raises(TypeError, match="invalid type for lines2: dict"):
|
||||||
lm.re_match_lines({}) # type: ignore[arg-type] # noqa: F821
|
lm.re_match_lines({}) # type: ignore[arg-type]
|
||||||
with pytest.raises(TypeError, match="invalid type for lines2: Source"):
|
with pytest.raises(TypeError, match="invalid type for lines2: Source"):
|
||||||
lm.fnmatch_lines(Source()) # type: ignore[arg-type] # noqa: F821
|
lm.fnmatch_lines(Source()) # type: ignore[arg-type]
|
||||||
lm.fnmatch_lines([])
|
lm.fnmatch_lines([])
|
||||||
lm.fnmatch_lines(())
|
lm.fnmatch_lines(())
|
||||||
lm.fnmatch_lines("")
|
lm.fnmatch_lines("")
|
||||||
assert lm._getlines({}) == {} # type: ignore[arg-type,comparison-overlap] # noqa: F821
|
assert lm._getlines({}) == {} # type: ignore[arg-type,comparison-overlap]
|
||||||
assert lm._getlines(set()) == set() # type: ignore[arg-type,comparison-overlap] # noqa: F821
|
assert lm._getlines(set()) == set() # type: ignore[arg-type,comparison-overlap]
|
||||||
assert lm._getlines(Source()) == []
|
assert lm._getlines(Source()) == []
|
||||||
assert lm._getlines(Source("pass\npass")) == ["pass", "pass"]
|
assert lm._getlines(Source("pass\npass")) == ["pass", "pass"]
|
||||||
|
|
||||||
|
|
|
@ -884,7 +884,7 @@ def test_store_except_info_on_error() -> None:
|
||||||
raise IndexError("TEST")
|
raise IndexError("TEST")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
runner.pytest_runtest_call(ItemMightRaise()) # type: ignore[arg-type] # noqa: F821
|
runner.pytest_runtest_call(ItemMightRaise()) # type: ignore[arg-type]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
# Check that exception info is stored on sys
|
# Check that exception info is stored on sys
|
||||||
|
@ -895,7 +895,7 @@ def test_store_except_info_on_error() -> None:
|
||||||
|
|
||||||
# The next run should clear the exception info stored by the previous run
|
# The next run should clear the exception info stored by the previous run
|
||||||
ItemMightRaise.raise_error = False
|
ItemMightRaise.raise_error = False
|
||||||
runner.pytest_runtest_call(ItemMightRaise()) # type: ignore[arg-type] # noqa: F821
|
runner.pytest_runtest_call(ItemMightRaise()) # type: ignore[arg-type]
|
||||||
assert not hasattr(sys, "last_type")
|
assert not hasattr(sys, "last_type")
|
||||||
assert not hasattr(sys, "last_value")
|
assert not hasattr(sys, "last_value")
|
||||||
assert not hasattr(sys, "last_traceback")
|
assert not hasattr(sys, "last_traceback")
|
||||||
|
|
|
@ -47,7 +47,7 @@ def test_store() -> None:
|
||||||
|
|
||||||
# Can't accidentally add attributes to store object itself.
|
# Can't accidentally add attributes to store object itself.
|
||||||
with pytest.raises(AttributeError):
|
with pytest.raises(AttributeError):
|
||||||
store.foo = "nope" # type: ignore[attr-defined] # noqa: F821
|
store.foo = "nope" # type: ignore[attr-defined]
|
||||||
|
|
||||||
# No interaction with anoter store.
|
# No interaction with anoter store.
|
||||||
store2 = Store()
|
store2 = Store()
|
||||||
|
|
|
@ -1699,7 +1699,7 @@ def test_summary_stats(
|
||||||
class fake_session:
|
class fake_session:
|
||||||
testscollected = 0
|
testscollected = 0
|
||||||
|
|
||||||
tr._session = fake_session # type: ignore[assignment] # noqa: F821
|
tr._session = fake_session # type: ignore[assignment]
|
||||||
assert tr._is_last_item
|
assert tr._is_last_item
|
||||||
|
|
||||||
# Reset cache.
|
# Reset cache.
|
||||||
|
|
Loading…
Reference in New Issue