Commit Graph

1797 Commits

Author SHA1 Message Date
Bruno Oliveira 0baf5e1499 Fix test that expected "unknown hook" error on stderr 2017-04-11 21:55:12 -03:00
Bruno Oliveira 83c508eea3 Verify hooks after collection completes
Fix #1821
2017-04-11 21:55:12 -03:00
Bruno Oliveira 78ac1bf5d1 Merge pull request #2350 from nicoddemus/future-imports-rewrite
Ensure rewritten modules don't inherit __future__ flags from pytest
2017-04-11 20:59:05 -03:00
Bruno Oliveira 1125786e78 Improve --lf/--ff test as commented during review 2017-04-11 17:55:55 -03:00
Jonas Obrist 0ab85e7a9c Changed behavior if --lf and --ff are both used.
When using both --last-failed/--lf and --failed-first/--ff pytest would
run all tests with failed tests first (as if --lf was not provied). This
patch changes it so that when using both flags, only the last failed
tests are run. This makes it easier to set --ff as the default behavior
via the config file and then selectively use --lf to only run the last
failed tests.
2017-04-10 17:46:13 +09:00
Bruno Oliveira 1b5f898dc5 Ensure rewritten modules don't inherit __future__ flags from pytest
In a recent refactoring we enabled all __future__ features in pytest
modules, but that has the unwanted side effect of propagating those
features to compile()'d modules inside assertion rewriting, unless
we pass dont_inherit=False to compile().
2017-04-06 15:00:36 -03:00
reut 333ce9849d added acceptance test for unicode plugin names 2017-04-06 10:54:47 +00:00
Bruno Oliveira 74b54ac0ec Fix errors related to warnings raised on pypy test environment
For some reason pypy raises this warning in the line that the catch_warnings block was added:

______________________________ ERROR collecting  ______________________________
C:\ProgramData\chocolatey\lib\python.pypy\tools\pypy2-v5.4.1-win32\lib-python\2.7\pkgutil.py:476: in find_loader
    loader = importer.find_module(fullname)
c:\pytest\.tox\pypy\site-packages\_pytest\assertion\rewrite.py:75: in find_module
    fd, fn, desc = imp.find_module(lastname, path)
<builtin>/?:3: in anonymous
    ???
E   ImportWarning: Not importing directory 'c:\users\bruno\appdata\local\temp\pytest-of-Bruno\pytest-3192\testdir\test_cmdline_python_package0' missing __init__.py
2017-03-21 22:32:41 -03:00
Bruno Oliveira 916d272c44 Fix test on linux 2017-03-20 23:44:50 -03:00
Bruno Oliveira fa56114115 Clean up warnings generated by pytest's own suite 2017-03-20 22:13:17 -03:00
Bruno Oliveira 9f85584656 Merge remote-tracking branch 'upstream/features' into integrate-pytest-warnings 2017-03-20 19:59:05 -03:00
Ronny Pfannschmidt e368fb4b29 implement pytest.param
this allows a clear addition of parameterization parameters that carry along marks
instead of nesting multiple mark objects and destroying the possibility of creating
function valued parameters,
it just folders everything together into one object carrfying parameters, and the marks.
2017-03-17 16:53:43 +01:00
Bruno Oliveira 4d947077bb Fix test in py26 that expected a floor division error message 2017-03-16 23:07:03 -03:00
Bruno Oliveira e5021dc9dc Replace py.builtin.print_() calls by builtin print() function 2017-03-16 22:46:51 -03:00
Bruno Oliveira 42a5d6bdfa Add __future__ imports to all pytest modules
This prevents silly errors from creeping in Python 2 when testing in Python 3
2017-03-16 22:45:40 -03:00
Bruno Oliveira 78194093af Improve warning representation in terminal plugin and fix tests 2017-03-16 21:57:32 -03:00
Bruno Oliveira be5db6fa22 Capture warnings around the entire runtestprotocol
This is necessary for the warnings plugin to play nice with the
recwarn fixture
2017-03-16 21:54:41 -03:00
Bruno Oliveira 0baed781fe Merge remote-tracking branch 'upstream/features' into integrate-pytest-warnings 2017-03-16 20:02:06 -03:00
Bruno Oliveira 337f891d78 Fixed tests 2017-03-16 20:01:47 -03:00
Bruno Oliveira 3c07072bfd Fix test_recwarn in Python 3.6
No longer test for implementation details of recwarn since warnings.catch_warnings has changed
significantly in 3.6.
2017-03-13 19:52:35 -03:00
Bruno Oliveira 22864b75ee Refactor recwarn to use warnings.catch_warnings instead of custom code
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-03-13 19:28:36 -03:00
Bruno Oliveira 1e0cf5ce4d Merge remote-tracking branch 'upstream/master' into merge-master-into-features
# Conflicts:
#	AUTHORS
#	CHANGELOG.rst
#	_pytest/pytester.py
2017-03-10 15:54:05 -03:00
fbjorn cee578e327 Fix trailing whitespace in terminal output 2017-03-05 23:20:55 +03:00
Bruno Oliveira 272afa9422 Display node ids and the warnings generated by it
The rationale of using node ids is that users can copy/paste it to run a chosen test
2017-03-04 20:53:42 -03:00
Bruno Oliveira de09023e45 Also capture warnings during setup/teardown 2017-03-04 16:15:03 -03:00
Bruno Oliveira e24081bf76 Change warning output 2017-03-04 15:59:20 -03:00
Omer Hadari 6a52fe1650 fixed internal error on unprintable raised AssertionErrors 2017-03-04 10:26:46 +02:00
Katerina Koukiou 26e50f1162 junitxml: adjust junitxml output file to comply with JUnit xsd
Change XML file structure in the manner that failures in call and errors
in teardown in one test will appear under separate testcase elements in
the XML report.
2017-03-02 15:10:25 +01:00
Anthony Sottile 6ba3475448 Make capsys more like stdio streams in python3. Resolves #1407. 2017-02-23 17:46:27 -08:00
Katerina Koukiou d3a6be4130 junitxml: Fix double system-out tags per testcase
In the xml report we now have two occurences for the system-out tag if
the testcase writes to stdout both on call and teardown and fails in
teardown.
This behaviour is against the xsd.
This patch makes sure that the system-out section exists only
once per testcase.
2017-02-22 16:39:20 +01:00
Bruno Oliveira 82785fcd40 Use warnings.catch_warnings instead of WarningsRecorder
This has the benefical side-effect of not calling the original
warnings.showwarnings function, which in its original form
only writes the formatted warning to sys.stdout.

Calling the original warnings.showwarnings has the effect that nested WarningsRecorder all catch the warnings:

with WarningsRecorder() as rec1:
    with WarningsRecorder() as rec2:
        warnings.warn(UserWarning, 'some warning')

(both rec1 and rec2 sees the warning)

When running tests with `testdir`, the main pytest session would then see the warnings created by
the internal code being tested (if any), and the main pytest session would end up with warnings as well.
2017-02-18 13:08:14 -02:00
Bruno Oliveira a7643a5fbe Merge branch 'features' into integrate-pytest-warnings 2017-02-18 11:03:15 -02:00
Michal Wajszczuk fb0b90646e New-style classes implemented for python 2.7 - #2147 2017-02-16 20:28:17 +01:00
Bruno Oliveira 9c809f5ad0 Merge pull request #2255 from scop/spelling
Spelling fixes
2017-02-15 18:41:49 -02:00
Ville Skyttä ede4e9171f Spelling fixes 2017-02-15 17:00:58 +02:00
Bruno Oliveira 9eb1d73951 --override-ini now correctly overrides some fundamental options like "python_files"
#2238
2017-02-08 23:03:33 -02:00
Bruno Oliveira 6a097aa0f1 Merge branch 'master' into allow_skipping_unittests_with_pdb_active 2017-02-08 20:30:14 -02:00
Ran Benita 3a0a0c2df9 Ignore errors raised from descriptors when collecting fixtures
Descriptors (e.g. properties) such as in the added test case are
triggered during collection, executing arbitrary code which can raise.
Previously, such exceptions were propagated and failed the collection.
Now these exceptions are caught and the corresponding attributes are
silently ignored.

A better solution would be to completely skip access to all custom
descriptors, such that the offending code doesn't even trigger. However
I think this requires manually going through the instance and all of its
MRO for each and every attribute checking if it might be a proper
fixture before accessing it. So I took the easy route here.

In other words, putting something like this in your test class is still
a bad idea...:

    @property
    def innocent(self):
        os.system('rm -rf /')

Fixes #2234.
2017-02-07 14:27:34 +02:00
Vidar Tonaas Fauske 832c89dd5f Test for `pytest.mark.xfail` with non-Python Item 2017-02-03 17:13:05 +01:00
Bruno Oliveira abbff681ba Fix '{0}' format for py26 2017-02-02 18:01:44 -02:00
Thomas Kriechbaumer 43662ce789 allow error message matching in pytest.raises 2017-02-02 19:52:33 +01:00
mbyt ad56cd8027 extract a _handle_skip method, secure PY2 branch 2017-02-02 05:01:51 +01:00
mbyt d1c725078a Allow to skip unittests if --pdb active
closes #2137
2017-01-31 04:47:31 +01:00
Ronny Pfannschmidt 3b47cb45e6 Merge pull request #2222 from RonnyPfannschmidt/features
merge master into features
2017-01-26 13:48:10 +01:00
Ronny Pfannschmidt 713bdc1f9f merge master into features 2017-01-26 12:00:52 +01:00
Ravi Chandra 0e58c3fa80 updates for PR review #2198 2017-01-21 16:47:49 +13:00
Ravi Chandra c848d0a771 Pass parameter name to `make_parametrize_id` hook function 2017-01-21 16:46:45 +13:00
Ronny Pfannschmidt e0c48b4fe7 Merge pull request #2212 from nicoddemus/pytester-rewrite
Assert statements of the pytester plugin again benefit from assertion rewriting

fixes #1920
2017-01-20 10:04:12 +01:00
Bruno Oliveira 7b4368f3f4 Merge pull request #2184 from eli-b/parseoutcomes-explicit-failure
Fail assert_outcomes() on missing terminal report
2017-01-19 21:38:54 -02:00
Bruno Oliveira c477f09177 Assert statements of the pytester plugin again benefit from assertion rewriting
Fix #1920
2017-01-19 21:33:51 -02:00