summaryrefslogtreecommitdiff
path: root/testing/test_recwarn.py
AgeCommit message (Collapse)Author
2020-12-05Merge pull request #8017 from bluetech/typing-public-fixturesRan Benita
Export types of builtin fixtures for type annotations
2020-11-16testing: convert test_{conftest,recwarn,tmpdir} to pytesterGarvit Shubham
2020-11-13Export types of builtin fixture for type annotationsRan Benita
In order to allow users to type annotate fixtures they request, the types need to be imported from the `pytest` namespace. They are/were always available to import from the `_pytest` namespace, but that is not guaranteed to be stable. These types are only exported for the purpose of typing. Specifically, the following are *not* public: - Construction (`__init__`) - Subclassing - staticmethods and classmethods We try to combat them being used anyway by: - Marking the classes as `@final` when possible (already done). - Not documenting private stuff in the API Reference. - Using `_`-prefixed names or marking as `:meta private:` for private stuff. - Adding a keyword-only `_ispytest=False` to private constructors, warning if False, and changing pytest itself to pass True. In the future it will (hopefully) become a hard error. Hopefully that will be enough.
2020-06-25recwarn: improve return type annotation of non-contextmanager pytest.warnsRan Benita
It returns the return value of the function.
2020-02-18Use a hack to make typing of pytest.fail.Exception & co workRan Benita
Mypy currently is unable to handle assigning attributes on function: https://github.com/python/mypy/issues/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.
2020-01-19Fix type of pytest.warns, and fix check_untyped_defs in test_recwarnRan Benita
The expected_warning is optional.
2019-07-14Revert "Let context-managers for raises and warns handle unknown keyword ↵Ran Benita
arguments" This reverts commit dfe54cd82f55f17f3c9e6e078325f306a046b93b. The idea in the commit was to simplify the code by removing the check and instead letting it TypeError which has the same effect. However this type error is caught by mypy, and rather than ignoring the error we think it's better and clearer to go back to the previous explicit check.
2019-06-30Remove support for 'code as string' from pytest.raises and pytest.warnsBruno Oliveira
2019-06-03pre-commit run pyupgrade --all-filesAnthony Sottile
2019-06-03pre-commit run reorder-python-imports --all-filesAnthony Sottile
2019-06-03pre-commit run fix-encoding-pragma --all-filesAnthony Sottile
2019-05-14Use fix-encoding-pragma pre-commit hookAnthony Sottile
2019-05-09Remove the 'issue' marker from test suiteBruno Oliveira
It doesn't seem to add much value (why would one execute tests based on that marker?), plus using the docstring for that encourages one to write a more descriptive message about the test
2018-11-29Deprecate `raises(..., 'code(as_a_string)')` / `warns(..., 'code(as_a_string)')Anthony Sottile
2018-10-26fix #4243 - support positional argument stacklevel on python2Ronny Pfannschmidt
2018-10-25Apply reorder-python-imports to all filesAnthony Sottile
2018-10-18[WIP] Update warning stacklevel when wrapping warnings.warnAnkit Goel
2018-10-10In python2, display previously warned warningsAnthony Sottile
2018-10-10Implement pytest.deprecated_call with pytest.warnsAnthony Sottile
2018-09-04Improve test_rewarn_functionalBruno Oliveira
2018-06-26Upgrade pre-commit hooks except pyupgradeAnthony Sottile
2018-05-23run blackRonny Pfannschmidt
2018-03-27Change pytest.raises to use match instead of matchesJeffrey Rackauckas
2018-01-30Fix test for py37Bruno Oliveira
In previous Python versions, the list of warnigns appears like: ... list of emitted warnings is: [UserWarning('user',)]. In Python 3.7 apparently the string representation has been improved to: ... list of emitted warnings is: [UserWarning('user')]. Fix #3011
2018-01-09Replace py.std with stdlib importsAnthony Sottile
2017-11-10Merge remote-tracking branch 'upstream/master' into merge-master-into-featuresBruno Oliveira
2017-11-04Fix linting E741: ambiguous variable nameBruno Oliveira
2017-09-07Add match_regex functionality to warnsJoan Massich
2017-09-04Add test to design warns signature in TDD mimicking raises signatureJoan Massich
2017-07-22Turn warnings into errors in pytest's own test suiteBruno Oliveira
Fix #2588
2017-07-17Fixed E701 flake8 errorsAndras Tim
multiple statements on one line (colon)
2017-07-17Fixed E303 flake8 errorsAndras Tim
too many blank lines (3)
2017-06-06deprecated_call context manager captures warnings already raisedBruno Oliveira
Fix #2469
2017-05-30Merge pull request #2445 from nicoddemus/warnings-remove-filterBruno Oliveira
No longer override existing warning filters during warnings capture
2017-05-30No longer override existing warning filters during warnings captureBruno Oliveira
Fix #2430
2017-05-30pytest.deprecated_call now captures PendingDeprecationWarning in context ↵Bruno Oliveira
manager form Fix #2441
2017-03-20Merge remote-tracking branch 'upstream/features' into integrate-pytest-warningsBruno Oliveira
2017-03-16Add __future__ imports to all pytest modulesBruno Oliveira
This prevents silly errors from creeping in Python 2 when testing in Python 3
2017-03-16Capture warnings around the entire runtestprotocolBruno Oliveira
This is necessary for the warnings plugin to play nice with the recwarn fixture
2017-03-13Fix test_recwarn in Python 3.6Bruno Oliveira
No longer test for implementation details of recwarn since warnings.catch_warnings has changed significantly in 3.6.
2017-03-13Refactor recwarn to use warnings.catch_warnings instead of custom codeBruno Oliveira
Since we dropped 2.5, we can now use warnings.catch_warnings to do the "catch warnings" magic for us, simplifying the code a bit.
2017-02-02allow error message matching in pytest.raisesThomas Kriechbaumer
2017-01-03Newline for flake8Loïc Estève
2017-01-03Add a test when multiple classes are specified in warnsLoïc Estève
2017-01-03pytest.warns checks for subclass relationshipLoïc Estève
rather than class equality. This makes it more similar to pytest.raises.
2016-12-27Merge branch 'master' into merge-master-into-featuresBruno Oliveira
2016-12-20Improve error message when pytest.warns failLoïc Estève
The error message contains the expected type of warnings and the warnings that were captured. Add tests.
2016-10-24turn RecordedWarning into a namedtupleRonny Pfannschmidt
fixes #2013
2015-12-10Merge remote-tracking branch 'upstream/master' into merge-master-into-featuresBruno Oliveira
2015-12-08Fix deprecated_call regression introduced in 2.8.4Bruno Oliveira
Fix #1238