test_ok2/testing
Ran Benita 0dc0360351 python: fix instance handling in static and class method tests
and also fixes a regression in pytest 8.0.0 where `setup_method` crashes
if the class has static or class method tests.

It is allowed to have a test class with static/class methods which
request non-static/class method fixtures (including `setup_method`
xunit-fixture). I take it as a given that we need to support this
somewhat odd scenario (stdlib unittest also supports it).

This raises a question -- when a staticmethod test requests a bound
fixture, what is that fixture's `self`?

stdlib unittest says - a fresh instance for the test.

Previously, pytest said - some instance that is shared by all
static/class methods. This is definitely broken since it breaks test
isolation.

Change pytest to behave like stdlib unittest here.

In practice, this means stopping to rely on `self.obj.__self__` to get
to the instance from the test function's binding. This doesn't work
because staticmethods are not bound to anything.

Instead, keep the instance explicitly and use that.

BTW, I think this will allow us to change `Class`'s fixture collection
(`parsefactories`) to happen on the class itself instead of a class
instance, allowing us to avoid one class instantiation. But needs more
work.

Fixes #12065.
2024-03-09 19:35:54 +02:00
..
_py [flake8-bugbear] Fix all the useless expressions that are justified 2024-02-04 19:27:23 +01:00
code Add consider_namespace_packages ini option 2024-03-02 16:13:48 -03:00
example_scripts Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
examples fix bug in test for issue 519 2021-03-07 15:01:39 +01:00
freeze [ruff] Fix all consider [*cats, garfield] instead of cats + [garfield] 2024-02-02 15:18:38 +01:00
io [ruff] Fix ambiguous characters found in string and comment 2024-02-02 15:18:38 +01:00
logging Add --log-file-mode option to the logging plugin, enabling appending to log-files (#11979) 2024-02-21 12:02:19 +00:00
plugins_integration build(deps): Bump twisted in /testing/plugins_integration 2024-03-04 03:25:34 +00:00
python python: fix instance handling in static and class method tests 2024-03-09 19:35:54 +02:00
acceptance_test.py Parse args from file (#12085) 2024-03-09 08:51:52 +02:00
conftest.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
deprecated_test.py Revert "Remove deprecated py.path hook arguments" 2024-03-07 19:50:33 -03:00
test_argcomplete.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_assertion.py Enable flake8-pie 2024-02-09 11:08:33 +02:00
test_assertrewrite.py [ruff] Add 'consider-using-in' from pylint 2024-02-10 15:47:44 +01:00
test_cacheprovider.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_capture.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_collection.py Do not collect symlinked tests under Windows (#12050) 2024-03-03 09:41:31 -03:00
test_compat.py [flake8-bugbear] Fixes a B017 we can actually fix and noqa the two others 2024-02-04 19:27:23 +01:00
test_config.py Consider pyproject.toml files for config if no other config files were found (#11962) 2024-02-14 16:08:45 -03:00
test_conftest.py Add consider_namespace_packages ini option 2024-03-02 16:13:48 -03:00
test_debugging.py monkeypatch.delenv PYTHONBREAKPOINT in two tests that previously failed/skipped 2024-03-03 13:48:29 +01:00
test_doctest.py testing/test_doctest: make `test_importmode` more realistic 2024-03-02 16:13:48 -03:00
test_entry_points.py mypy: disallow untyped defs by default (#11862) 2024-01-28 10:12:42 -03:00
test_error_diffs.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_faulthandler.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_findpaths.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_helpconfig.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_junitxml.py [ruff] Fix all consider [*cats, garfield] instead of cats + [garfield] 2024-02-02 15:18:38 +01:00
test_legacypath.py Revert "Remove deprecated py.path (`fspath`) node constructor arguments" 2024-03-07 19:50:33 -03:00
test_link_resolve.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_main.py main: add `module_name` to `CollectionArgument` 2024-03-02 20:26:02 +02:00
test_mark.py [flake8-bugbear] Fix all the useless expressions that are justified 2024-02-04 19:27:23 +01:00
test_mark_expression.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_meta.py Run pre-commit on all files 2024-01-30 16:35:46 -03:00
test_monkeypatch.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_nodes.py Revert "Remove deprecated py.path (`fspath`) node constructor arguments" 2024-03-07 19:50:33 -03:00
test_parseopt.py Parse args from file (#12085) 2024-03-09 08:51:52 +02:00
test_pastebin.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_pathlib.py Do not import duplicated modules with --importmode=importlib (#12074) 2024-03-04 12:44:56 -03:00
test_pluginmanager.py Add consider_namespace_packages ini option 2024-03-02 16:13:48 -03:00
test_pytester.py [ruff] Add ruff's check and autofix existing issues 2024-02-02 15:18:38 +01:00
test_python_path.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_recwarn.py recwarn: fix pytest.warns handling of Warnings with multiple arguments 2024-02-16 14:14:24 +02:00
test_reports.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_runner.py runner: add support for `sys.last_exc` for post-mortem debugging on Python>=3.12 2024-02-23 15:59:32 +02:00
test_runner_xunit.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_scope.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_session.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_setuponly.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_setupplan.py #7942 test_setupplan.py migrate from testdir to Pytester (#8004) 2020-11-07 09:29:45 -03:00
test_skipping.py Enable flake8-pie 2024-02-09 11:08:33 +02:00
test_stash.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_stepwise.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_terminal.py New verbosity_test_case ini option (#11653) 2024-02-24 16:27:54 -03:00
test_threadexception.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_tmpdir.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_unittest.py unittest: make `obj` work more like `Function`/`Class` 2024-03-08 14:03:26 +02:00
test_unraisableexception.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_warning_types.py Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff 2024-02-02 09:27:00 +01:00
test_warnings.py Enable lint PGH004 - Use specific rule codes when using noqa 2024-02-09 11:14:36 +02:00
typing_checks.py mypy: disallow untyped defs by default (#11862) 2024-01-28 10:12:42 -03:00