Rename code to _pytest.warnings and delete old files from the repository
This commit is contained in:
parent
9db32aea48
commit
1da1906483
|
@ -1,9 +0,0 @@
|
|||
/.cache/
|
||||
/.coverage
|
||||
/.tox/
|
||||
/bin/
|
||||
/dist/
|
||||
/htmlcov/
|
||||
/include/
|
||||
/lib/
|
||||
/pip-selfcheck.json
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
include README.rst
|
||||
include tox.ini
|
||||
include LICENSE
|
||||
include tests/*.py
|
|
@ -1,70 +0,0 @@
|
|||
pytest-warnings
|
||||
===============
|
||||
|
||||
py.test plugin to list Python warnings in pytest report
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
install via::
|
||||
|
||||
pip install pytest-warnings
|
||||
|
||||
if you then type::
|
||||
|
||||
py.test -rw
|
||||
|
||||
any warnings in your code are reported in the pytest report.
|
||||
You can use the ``-W`` option or ``--pythonwarnings`` exactly like for the ``python`` executable.
|
||||
|
||||
The following example ignores all warnings, but prints DeprecationWarnings once per occurrence::
|
||||
|
||||
py.test -rw -W ignore -W once::DeprecationWarning
|
||||
|
||||
You can also turn warnings into actual errors::
|
||||
|
||||
py.test -W error
|
||||
|
||||
|
||||
Advance usage
|
||||
=============
|
||||
|
||||
You can get more fine grained filtering of warnings by using the
|
||||
``filterwarnings`` configuration option.
|
||||
|
||||
``filterwarnings`` works like the python's ``-W`` flag except it will not
|
||||
escape special characters.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
.. code::
|
||||
|
||||
# pytest.ini
|
||||
[pytest]
|
||||
filterwarnings= default
|
||||
ignore:.*is deprecated.*:Warning
|
||||
error::DeprecationWarning:importlib.*
|
||||
|
||||
|
||||
Changes
|
||||
=======
|
||||
|
||||
0.3.0 - Unreleased
|
||||
------------------
|
||||
|
||||
|
||||
|
||||
0.2.0 - 2016-10-24
|
||||
------------------
|
||||
|
||||
- Add ``filterwarnings`` option.
|
||||
[Carreau (Matthias Bussonnier)]
|
||||
|
||||
|
||||
0.1.0 - 2016-06-27
|
||||
------------------
|
||||
|
||||
- Initial release.
|
||||
[fschulze (Florian Schulze)]
|
|
@ -1,17 +0,0 @@
|
|||
from setuptools import setup
|
||||
|
||||
|
||||
setup(
|
||||
name="pytest-warnings",
|
||||
description='pytest plugin to list Python warnings in pytest report',
|
||||
long_description=open("README.rst").read(),
|
||||
license="MIT license",
|
||||
version='0.3.0.dev0',
|
||||
author='Florian Schulze',
|
||||
author_email='florian.schulze@gmx.net',
|
||||
url='https://github.com/fschulze/pytest-warnings',
|
||||
packages=['pytest_warnings'],
|
||||
entry_points={'pytest11': ['pytest_warnings = pytest_warnings']},
|
||||
install_requires=['pytest'],
|
||||
classifiers=[
|
||||
"Framework :: Pytest"])
|
|
@ -1,10 +0,0 @@
|
|||
import warnings
|
||||
|
||||
|
||||
def deprecated_a():
|
||||
"""
|
||||
A warning triggered in __this__ module for testing.
|
||||
"""
|
||||
globals()['__warningregistry__'] = {}
|
||||
warnings.warn("This is deprecated message_a",
|
||||
DeprecationWarning, stacklevel=0)
|
|
@ -1,11 +0,0 @@
|
|||
import warnings
|
||||
|
||||
|
||||
def user_warning_b():
|
||||
"""
|
||||
A warning triggered in __this__ module for testing.
|
||||
"""
|
||||
# reset the "once" filters
|
||||
# globals()['__warningregistry__'] = {}
|
||||
warnings.warn("This is deprecated message_b different from a",
|
||||
UserWarning, stacklevel=1)
|
|
@ -1,95 +0,0 @@
|
|||
import pytest
|
||||
import warnings
|
||||
|
||||
from pytest_warnings import _setoption
|
||||
from helper_test_a import deprecated_a
|
||||
from helper_test_b import user_warning_b
|
||||
|
||||
|
||||
def test_warnings():
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
|
||||
|
||||
def test_warnings1():
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
|
||||
|
||||
def test_warn():
|
||||
with pytest.warns(DeprecationWarning):
|
||||
warnings.warn("Bar", DeprecationWarning)
|
||||
|
||||
|
||||
# This section test the ability to filter selectively warnings using regular
|
||||
# expressions on messages.
|
||||
|
||||
def test_filters_setoption():
|
||||
"A alone works"
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
deprecated_a()
|
||||
|
||||
|
||||
def test_filters_setoption_2():
|
||||
"B alone works"
|
||||
|
||||
with pytest.warns(UserWarning) as record:
|
||||
user_warning_b()
|
||||
|
||||
assert len(record) == 1
|
||||
|
||||
|
||||
def test_filters_setoption_3():
|
||||
"A and B works"
|
||||
|
||||
with pytest.warns(None) as record:
|
||||
user_warning_b()
|
||||
deprecated_a()
|
||||
assert len(record) == 2
|
||||
|
||||
|
||||
def test_filters_setoption_4():
|
||||
"A works, B is filtered"
|
||||
|
||||
with pytest.warns(None) as record:
|
||||
_setoption(warnings, 'ignore:.*message_a.*')
|
||||
deprecated_a()
|
||||
user_warning_b()
|
||||
|
||||
assert len(record) == 1, "Only `A` should be filtered out"
|
||||
|
||||
|
||||
def test_filters_setoption_4b():
|
||||
"A works, B is filtered"
|
||||
|
||||
with pytest.warns(None) as record:
|
||||
_setoption(warnings, 'ignore:.*message_b.*')
|
||||
_setoption(warnings, 'ignore:.*message_a.*')
|
||||
_setoption(warnings, 'always:::.*helper_test_a.*')
|
||||
deprecated_a()
|
||||
user_warning_b()
|
||||
|
||||
assert len(record) == 1, "`A` and `B` should be visible, second filter reenable A"
|
||||
|
||||
|
||||
def test_filters_setoption_5():
|
||||
"B works, A is filtered"
|
||||
|
||||
with pytest.warns(None) as records:
|
||||
_setoption(warnings, 'always:::.*helper_test_a.*')
|
||||
_setoption(warnings, 'ignore::UserWarning')
|
||||
deprecated_a()
|
||||
user_warning_b()
|
||||
|
||||
assert len(records) == 1, "Only `B` should be filtered out"
|
|
@ -1,20 +0,0 @@
|
|||
def test_warnings():
|
||||
import warnings
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
|
||||
|
||||
def test_warnings1():
|
||||
import warnings
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", RuntimeWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
||||
warnings.warn("Foo", DeprecationWarning)
|
|
@ -1,18 +0,0 @@
|
|||
[tox]
|
||||
envlist = py27,py33,py34,py35
|
||||
|
||||
[testenv]
|
||||
usedevelop = true
|
||||
deps =
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-flakes
|
||||
pytest-pep8
|
||||
coverage
|
||||
commands =
|
||||
{envbindir}/py.test --junitxml={envlogdir}/junit-{envname}.xml {posargs}
|
||||
|
||||
[pytest]
|
||||
addopts = --flakes --pep8 --cov pytest_warnings --cov tests --no-cov-on-fail
|
||||
pep8ignore = E501
|
||||
norecursedirs = bin lib include Scripts .*
|
Loading…
Reference in New Issue