pytest-instafail-0.3.0/0000755000076500000240000000000012400367353015233 5ustar jannestaff00000000000000pytest-instafail-0.3.0/CHANGES.rst0000644000076500000240000000137212400366305017034 0ustar jannestaff00000000000000Changelog --------- Here you can see the full list of changes between each pytest-instafail release. 0.3.0 (August 30, 2014) ^^^^^^^^^^^^^^^^^^^^^^^ - Added support for Python 3.4 - Added support for py.test 2.6 - Fixed failing tests on py.test 2.6 0.2.0 (March 6, 2014) ^^^^^^^^^^^^^^^^^^^^^ - Dropped support for Python 2.5. - Fixed stacktrace printed twice when using PDB. - Fixed internal error when a test marked as xfailing unexpectedly passes (David Szotten). 0.1.1 (November 9, 2013) ^^^^^^^^^^^^^^^^^^^^^^^^ - Made pytest-instafail compatible with `pytest-xdist`_'s test parallelization (Ronny Pfannschmidt). 0.1.0 (April 8, 2013) ^^^^^^^^^^^^^^^^^^^^^ - Initial public release .. _`pytest-xdist`: http://pypi.python.org/pypi/pytest-xdist pytest-instafail-0.3.0/LICENSE0000644000076500000240000000263612306164147016250 0ustar jannestaff00000000000000Copyright (c) 2013-2014, Janne Vanhala All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pytest-instafail-0.3.0/MANIFEST.in0000644000076500000240000000014212130362557016767 0ustar jannestaff00000000000000include CHANGES.rst include README.rst include setup.py include LICENSE include test_instafail.py pytest-instafail-0.3.0/PKG-INFO0000644000076500000240000000451312400367353016333 0ustar jannestaff00000000000000Metadata-Version: 1.1 Name: pytest-instafail Version: 0.3.0 Summary: py.test plugin to show failures instantly Home-page: https://github.com/jpvanhal/pytest-instafail Author: Janne Vanhala Author-email: janne.vanhala@gmail.com License: BSD Description: pytest-instafail ================ |build status|_ .. |build status| image:: https://secure.travis-ci.org/jpvanhal/pytest-instafail.png?branch=master :alt: Build Status .. _build status: http://travis-ci.org/jpvanhal/pytest-instafail pytest-instafail is a plugin for `py.test `_ that shows failures and errors instantly instead of waiting until the end of test session. Requirements ------------ You will need the following prerequisites in order to use pytest-instafail: - Python 2.6, 2.7, 3.2, 3.3, 3.4 or PyPy - pytest 2.3 or newer Installation ------------ To install pytest-instafail:: $ pip install pytest-instafail Then run your tests with:: $ py.test --instafail Resources --------- - `Issue Tracker `_ - `Code `_ - `Development Version `_ Platform: any Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: POSIX Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: MacOS :: MacOS X Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: Implementation :: PyPy pytest-instafail-0.3.0/pytest_instafail.egg-info/0000755000076500000240000000000012400367353022307 5ustar jannestaff00000000000000pytest-instafail-0.3.0/pytest_instafail.egg-info/dependency_links.txt0000644000076500000240000000000112400367353026355 0ustar jannestaff00000000000000 pytest-instafail-0.3.0/pytest_instafail.egg-info/entry_points.txt0000644000076500000240000000005112400367353025601 0ustar jannestaff00000000000000[pytest11] instafail = pytest_instafail pytest-instafail-0.3.0/pytest_instafail.egg-info/not-zip-safe0000644000076500000240000000000112130326314024525 0ustar jannestaff00000000000000 pytest-instafail-0.3.0/pytest_instafail.egg-info/PKG-INFO0000644000076500000240000000451312400367353023407 0ustar jannestaff00000000000000Metadata-Version: 1.1 Name: pytest-instafail Version: 0.3.0 Summary: py.test plugin to show failures instantly Home-page: https://github.com/jpvanhal/pytest-instafail Author: Janne Vanhala Author-email: janne.vanhala@gmail.com License: BSD Description: pytest-instafail ================ |build status|_ .. |build status| image:: https://secure.travis-ci.org/jpvanhal/pytest-instafail.png?branch=master :alt: Build Status .. _build status: http://travis-ci.org/jpvanhal/pytest-instafail pytest-instafail is a plugin for `py.test `_ that shows failures and errors instantly instead of waiting until the end of test session. Requirements ------------ You will need the following prerequisites in order to use pytest-instafail: - Python 2.6, 2.7, 3.2, 3.3, 3.4 or PyPy - pytest 2.3 or newer Installation ------------ To install pytest-instafail:: $ pip install pytest-instafail Then run your tests with:: $ py.test --instafail Resources --------- - `Issue Tracker `_ - `Code `_ - `Development Version `_ Platform: any Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: POSIX Classifier: Operating System :: Microsoft :: Windows Classifier: Operating System :: MacOS :: MacOS X Classifier: Topic :: Software Development :: Testing Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Utilities Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.2 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: Implementation :: PyPy pytest-instafail-0.3.0/pytest_instafail.egg-info/requires.txt0000644000076500000240000000001412400367353024702 0ustar jannestaff00000000000000pytest>=2.3 pytest-instafail-0.3.0/pytest_instafail.egg-info/SOURCES.txt0000644000076500000240000000056212400367353024176 0ustar jannestaff00000000000000CHANGES.rst LICENSE MANIFEST.in README.rst pytest_instafail.py setup.py test_instafail.py pytest_instafail.egg-info/PKG-INFO pytest_instafail.egg-info/SOURCES.txt pytest_instafail.egg-info/dependency_links.txt pytest_instafail.egg-info/entry_points.txt pytest_instafail.egg-info/not-zip-safe pytest_instafail.egg-info/requires.txt pytest_instafail.egg-info/top_level.txtpytest-instafail-0.3.0/pytest_instafail.egg-info/top_level.txt0000644000076500000240000000002112400367353025032 0ustar jannestaff00000000000000pytest_instafail pytest-instafail-0.3.0/pytest_instafail.py0000644000076500000240000000611112306164076021170 0ustar jannestaff00000000000000# -*- coding: utf-8 -*- """ pytest_instafail ~~~~~~~~~~~~~~~~ py.test plugin to show failures instantly. :copyright: (c) 2013-2014 by Janne Vanhala. :license: BSD, see LICENSE for more details. """ import pytest from _pytest.terminal import TerminalReporter def pytest_addoption(parser): group = parser.getgroup("terminal reporting", "reporting", after="general") group._addoption( '--instafail', action="store_true", dest="instafail", default=False, help=( "show failures and errors instantly as they occur (disabled by " "default)." ) ) @pytest.mark.trylast def pytest_configure(config): if hasattr(config, 'slaveinput'): return # xdist slave, we are already active on the master if config.option.instafail: # Get the standard terminal reporter plugin... standard_reporter = config.pluginmanager.getplugin('terminalreporter') instafail_reporter = InstafailingTerminalReporter(standard_reporter) # ...and replace it with our own instafailing reporter. config.pluginmanager.unregister(standard_reporter) config.pluginmanager.register(instafail_reporter, 'terminalreporter') class InstafailingTerminalReporter(TerminalReporter): def __init__(self, reporter): TerminalReporter.__init__(self, reporter.config) self._tw = reporter._tw def pytest_collectreport(self, report): # Show errors occurred during the collection instantly. TerminalReporter.pytest_collectreport(self, report) if report.failed: self.rewrite("") # erase the "collecting" message self.print_failure(report) def pytest_runtest_logreport(self, report): # Show failures and errors occuring during running a test # instantly. TerminalReporter.pytest_runtest_logreport(self, report) if report.failed and not hasattr(report, 'wasxfail'): if self.verbosity <= 0: self._tw.line() self.print_failure(report) def summary_failures(self): # Prevent failure summary from being shown since we already # show the failure instantly after failure has occured. pass def summary_errors(self): # Prevent error summary from being shown since we already # show the error instantly after error has occured. pass def print_failure(self, report): if self.config.option.tbstyle != "no": if self.config.option.tbstyle == "line": line = self._getcrashline(report) self.write_line(line) else: msg = self._getfailureheadline(report) if not hasattr(report, 'when'): msg = "ERROR collecting " + msg elif report.when == "setup": msg = "ERROR at setup of " + msg elif report.when == "teardown": msg = "ERROR at teardown of " + msg self.write_sep("_", msg) if not self.config.getvalue("usepdb"): self._outrep_summary(report) pytest-instafail-0.3.0/README.rst0000644000076500000240000000171712400366140016721 0ustar jannestaff00000000000000pytest-instafail ================ |build status|_ .. |build status| image:: https://secure.travis-ci.org/jpvanhal/pytest-instafail.png?branch=master :alt: Build Status .. _build status: http://travis-ci.org/jpvanhal/pytest-instafail pytest-instafail is a plugin for `py.test `_ that shows failures and errors instantly instead of waiting until the end of test session. Requirements ------------ You will need the following prerequisites in order to use pytest-instafail: - Python 2.6, 2.7, 3.2, 3.3, 3.4 or PyPy - pytest 2.3 or newer Installation ------------ To install pytest-instafail:: $ pip install pytest-instafail Then run your tests with:: $ py.test --instafail Resources --------- - `Issue Tracker `_ - `Code `_ - `Development Version `_ pytest-instafail-0.3.0/setup.cfg0000644000076500000240000000007312400367353017054 0ustar jannestaff00000000000000[egg_info] tag_build = tag_date = 0 tag_svn_revision = 0 pytest-instafail-0.3.0/setup.py0000644000076500000240000000256412400366455016756 0ustar jannestaff00000000000000from setuptools import setup setup( name='pytest-instafail', description='py.test plugin to show failures instantly', long_description=open("README.rst").read(), version='0.3.0', url='https://github.com/jpvanhal/pytest-instafail', license='BSD', author='Janne Vanhala', author_email='janne.vanhala@gmail.com', py_modules=['pytest_instafail'], entry_points={'pytest11': ['instafail = pytest_instafail']}, zip_safe=False, include_package_data=True, platforms='any', install_requires=['pytest>=2.3'], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: POSIX', 'Operating System :: Microsoft :: Windows', 'Operating System :: MacOS :: MacOS X', 'Topic :: Software Development :: Testing', 'Topic :: Software Development :: Libraries', 'Topic :: Utilities', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: Implementation :: PyPy', ] ) pytest-instafail-0.3.0/test_instafail.py0000644000076500000240000002166212400365002020612 0ustar jannestaff00000000000000# -*- coding: utf-8 -*- pytest_plugins = "pytester" import pytest class Option(object): def __init__(self, verbose=False, quiet=False, n=None): self.verbose = verbose self.quiet = quiet self.n = None @property def args(self): l = ['--instafail'] if self.verbose: l.append('-v') if self.quiet: l.append('-q') if self.n is not None: self.args.extend(['-n', str(self.n)]) return l @pytest.fixture(params=['normal', '1 slave', '2 slave']) def n(request): return { 'normal': None, '1 slave': 1, '2 slave': 2, }[request.param] @pytest.fixture(params=['default', 'verbose', 'quiet']) def option(request, n): return { "default": Option(verbose=False, n=n), "verbose": Option(verbose=True, n=n), "quiet": Option(quiet=True, n=n), }[request.param] class TestInstafailingTerminalReporter(object): def test_fail(self, testdir, option): testdir.makepyfile( """ import pytest def test_func(): assert 0 """ ) result = testdir.runpytest(*option.args) if option.verbose: result.stdout.fnmatch_lines([ "*test_fail.py:*:*test_func*FAIL*", "* test_func *", " def test_func():", "> assert 0", "E assert 0", ]) elif option.quiet: result.stdout.fnmatch_lines([ "F", "* test_func *", " def test_func():", "> assert 0", "E assert 0", ]) else: result.stdout.fnmatch_lines([ "*test_fail.py F", "* test_func *", " def test_func():", "> assert 0", "E assert 0", ]) def test_fail_fail(self, testdir, option): testdir.makepyfile( """ import pytest def test_func(): assert 0 def test_func2(): assert 0 """ ) result = testdir.runpytest(*option.args) if option.verbose: result.stdout.fnmatch_lines([ "*test_fail_fail.py:*:*test_func*FAIL*", "* test_func *", " def test_func():", "> assert 0", "E assert 0", "test_fail_fail.py:3: AssertionError", "", "*test_fail_fail.py:*:*test_func2*FAIL*", "* test_func2 *", " def test_func2():", "> assert 0", "E assert 0", ]) elif option.quiet: result.stdout.fnmatch_lines([ "F", "* test_func *", " def test_func():", "> assert 0", "E assert 0", "F", "* test_func2 *", " def test_func2():", "> assert 0", "E assert 0", ]) else: result.stdout.fnmatch_lines([ "*test_fail_fail.py F", "* test_func *", " def test_func():", "> assert 0", "E assert 0", "*test_fail_fail.py F", "* test_func2 *", " def test_func2():", "> assert 0", "E assert 0", ]) def test_error_in_setup_then_pass(self, testdir, option): testdir.makepyfile( """ def setup_function(function): print ("setup func") if function is test_nada: assert 0 def test_nada(): pass def test_zip(): pass """ ) result = testdir.runpytest(*option.args) if option.verbose: result.stdout.fnmatch_lines([ "*test_error_in_setup_then_pass.py:*:*test_nada*ERROR*", "*ERROR at setup of test_nada*", "*setup_function(function):*", "*setup func*", "*assert 0*", "test_error_in_setup_then_pass.py:4: AssertionError", "", "*test_error_in_setup_then_pass.py:*:*test_zip*PASSED*", "*1 error*", ]) elif option.quiet: result.stdout.fnmatch_lines([ "E", "*ERROR at setup of test_nada*", "*setup_function(function):*", "*setup func*", "*assert 0*", "test_error_in_setup_then_pass.py:4: AssertionError", ".", ]) else: result.stdout.fnmatch_lines([ "*test_error_in_setup_then_pass.py E", "*ERROR at setup of test_nada*", "*setup_function(function):*", "*setup func*", "*assert 0*", "test_error_in_setup_then_pass.py:4: AssertionError", "", "*test_error_in_setup_then_pass.py .", "*1 error*", ]) assert result.ret != 0 def test_error_in_teardown_then_pass(self, testdir, option): testdir.makepyfile( """ def teardown_function(function): print ("teardown func") if function is test_nada: assert 0 def test_nada(): pass def test_zip(): pass """ ) result = testdir.runpytest(*option.args) if option.verbose: result.stdout.fnmatch_lines([ "*test_error_in_teardown_then_pass.py:*:*test_nada*ERROR*", "*ERROR at teardown of test_nada*", "*teardown_function(function):*", "*teardown func*", "*assert 0*", "test_error_in_teardown_then_pass.py:4: AssertionError", "", "*test_error_in_teardown_then_pass.py:*:*test_zip*PASSED*", "*1 error*", ]) elif option.quiet: result.stdout.fnmatch_lines([ ".E", "*ERROR at teardown of test_nada*", "*teardown_function(function):*", "*teardown func*", "*assert 0*", "test_error_in_teardown_then_pass.py:4: AssertionError", ".", ]) else: result.stdout.fnmatch_lines([ "*test_error_in_teardown_then_pass.py .E", "*ERROR at teardown of test_nada*", "*teardown_function(function):*", "*teardown func*", "*assert 0*", "test_error_in_teardown_then_pass.py:4: AssertionError", "", "*test_error_in_teardown_then_pass.py .", "*1 error*", ]) assert result.ret != 0 def test_collect_error(self, testdir, option): testdir.makepyfile("""raise ValueError(0)""") result = testdir.runpytest(*option.args) result.stdout.fnmatch_lines([ "*ERROR collecting test_collect_error.py*", "test_collect_error.py:1: in ", "* raise ValueError(0)", "E ValueError: 0", ]) if not option.quiet: result.stdout.fnmatch_lines([ "collected 0 items / 1 errors", ]) def test_print_stacktrace_once_with_pdb(self, testdir, request, option): test_file = testdir.makepyfile( """ def test_func(): assert 0 """ ) args = option.args args.append(" --pdb %s" % test_file) child = testdir.spawn_pytest(' '.join(args)) child.expect('>+ traceback >+') assert 'E assert 0' not in child.before child.expect('(Pdb)') child.sendeof() if child.isalive(): child.wait() def test_xfail_unexpected_success(self, testdir, option): testdir.makepyfile( """ import pytest @pytest.mark.xfail def test_func(): pass """ ) result = testdir.runpytest(*option.args) if option.verbose: result.stdout.fnmatch_lines([ "test_xfail_unexpected_success.py:*:*test_func XPASS" ]) elif option.quiet: result.stdout.fnmatch_lines([ "X" ]) else: result.stdout.fnmatch_lines([ "test_xfail_unexpected_success.py X" ]) assert "INTERNALERROR" not in result.stdout.str()