Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: merge (#142) + revert (#143) #179

Open
wants to merge 210 commits into
base: my-master
Choose a base branch
from
Open

TEST: merge (#142) + revert (#143) #179

wants to merge 210 commits into from

Conversation

blueyed
Copy link
Owner

@blueyed blueyed commented Feb 1, 2020

Ref: #142
Ref: #143
Ref: pytest-dev#6645

NOTE: only for testing, needs to be rebased/cleaned up.

blueyed and others added 30 commits November 10, 2019 00:21
Fixes pytest-dev#5991
Fixes pytest-dev#3823

Ref: pytest-dev/pytest-django#772
Ref: pytest-dev#1890
Ref: pytest-dev/pytest-django#782

- inject wrapped testMethod

- adjust test_trial_error

- add test for `--trace` with unittests
- Isolate logic for getting expected exceptions
- Use original method name, as users see it when entering the debugger
Otherwise 'normal' failures won't call teardown explicitly
rename test_pdb to test_debugging
unittest: do not use TestCase.debug() with `--pdb`
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
Conflicts:
	src/_pytest/unittest.py
	testing/test_unittest.py
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
As discussed, sometimes we will need to introduce changes
which are not necessarily removals but might break existing
suites
Co-Authored-By: Anthony Sottile <asottile@umich.edu>
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
…-breakage

Deprecation policy - insert considerations for breaking changes
An improvement seems more adequate here.
Change 4639 from feature to improvement
…-matching-case-insensitive

Make keyword expression matching case-insensitive
As far as the output is concerned, they are both identical so it doesn't
make sense to have both.

setup, teardown, and collect failures are already reported as "errors", "E".
blueyed and others added 30 commits February 15, 2020 01:22
Allows for filtering of PytestCacheWarning.

Using `_issue_warning_captured` is not necessary here, and was probably
only used because the cacheprovider misses warnings during
`pytest_sessionfinish`, which is also fixed here.

I think the usage of `_issue_warning_captured` can be removed/reduced
further, but also that this is good enough for now.

Ref: pytest-dev#6681.
Would need to be adjusted anyway non-trivially, and we can just harden
`test_cache_failure_warns` instead.
Using getattr doesn't work with typing, and also breaks grep. It took me
a while to find where these hooks are called.
Every Item must implement this method (called on all items collected in
a session). Add a stub for typing and clarity.
Avoid getattr when dispatching pytest_runtest_* hooks
Conflicts:
	src/_pytest/terminal.py
	testing/test_debugging.py
	testing/test_terminal.py
…v#6748)

It was not previously checking for the line number also (02aa8ad), and this is
obviously wrong (affected by changes to the file).
Mypy currently is unable to handle assigning attributes on function:
python/mypy#2087.
pytest uses this for the outcome exceptions -- `pytest.fail.Exception`,
`pytest.exit.Exception` etc, and this is the canonical name by which they
are referred.

Initially we started working around this with type: ignores, and later
by switching e.g. `pytest.fail.Exception` with the direct exception
`Failed`. But this causes a lot of churn and is not as nice. And I also
found that some code relies on it, in skipping.py:

    def pytest_configure(config):
        if config.option.runxfail:
            # yay a hack
            import pytest

            old = pytest.xfail
            config._cleanup.append(lambda: setattr(pytest, "xfail", old))

            def nop(*args, **kwargs):
                pass

            nop.Exception = xfail.Exception
            setattr(pytest, "xfail", nop)
        ...

So it seems better to support it. Use a hack to make it work. The rest
of the commit rolls back all of the workarounds we added up to now.

`pytest.raises.Exception` also exists, but it's not used much so I kept
it as-is for now.

Hopefully in the future mypy supports this and this ugliness can be
removed.
Fixes using `pytest.xfail()` and `pytest.importorskip()` in doctests.

Ref: pytest-dev#310
…llable-2

Use a hack to make typing of pytest.fail.Exception & co work
)

Fixes pytest-dev#5301.

Refactor/steps:

- use var
- harden test_lastfailed_usecase
- harden test_failedfirst_order
- revisit last_failed_paths
- harden test_lastfailed_with_known_failures_not_being_selected
Conflicts:
	src/_pytest/assertion/util.py
	src/_pytest/main.py
	testing/test_assertion.py
	testing/test_terminal.py
Conflicts:
	src/_pytest/_code/code.py
	src/_pytest/doctest.py
	src/_pytest/nodes.py
	src/_pytest/terminal.py
	testing/python/metafunc.py
	testing/test_assertion.py
	testing/test_cacheprovider.py
	testing/test_warnings.py
Conflicts:
	src/_pytest/cacheprovider.py
Keep `NodeMeta._create` for compatibility.

Conflicts:
	testing/python/metafunc.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.