Commit Graph

1950 Commits

Author SHA1 Message Date
Bruno Oliveira 46d157fe07 Fix collection report when collecting a single test item 2017-06-03 20:39:53 -03:00
Bruno Oliveira 87e4a28351 Fix incorrect collected items report when specifying tests on the command-line
Fix #2464
2017-06-03 20:39:53 -03:00
Segev Finer 59b3693988 Fixed wrong if in the WindowsConsoleIO workaround 2017-06-02 12:34:26 +03:00
Segev Finer 05796be21a A workaround for Python 3.6 WindowsConsoleIO breaking with FDCapture
Python 3.6 implemented unicode console handling for Windows. This works
by reading/writing to the raw console handle using
``{Read,Write}ConsoleW``.

The problem is that we are going to ``dup2`` over the stdio file
descriptors when doing ``FDCapture`` and this will ``CloseHandle`` the
handles used by Python to write to the console. Though there is still some
weirdness and the console handle seems to only be closed randomly and not
on the first call to ``CloseHandle``, or maybe it gets reopened with the
same handle value when we suspend capturing.

The workaround in this case will reopen stdio with a different fd which
also means a different handle by replicating the logic in
"Py_lifecycle.c:initstdio/create_stdio".

See https://github.com/pytest-dev/py/issues/103
2017-06-02 11:19:03 +03:00
Segev Finer 9abff7f72f Add a docstring to HelpAction 2017-06-01 22:25:09 +03:00
Segev Finer f74f14f038 Fix --help with required options
This works by adding an argparse Action that will raise an exception in
order to skip the rest of the argument parsing. This prevents argparse
from quitting due to missing required arguments, similar to the way that
the builtin argparse --help option is implemented by raising SystemExit.

Fixes: #1999
2017-06-01 21:29:50 +03:00
Andreas Pelme 021e843427 Fixed #2121 Use `py.path`s fnmatch. This fixes an issue where
python_files handled properly when rewriting assertions.
2017-05-31 08:25:04 +02:00
Bruno Oliveira 1dee443c2b Merge pull request #2445 from nicoddemus/warnings-remove-filter
No longer override existing warning filters during warnings capture
2017-05-30 18:14:01 -03:00
Bruno Oliveira 32e2642233 No longer override existing warning filters during warnings capture
Fix #2430
2017-05-30 17:17:36 -03:00
Bruno Oliveira f96a1d89c5 pytest.deprecated_call now captures PendingDeprecationWarning in context manager form
Fix #2441
2017-05-30 12:52:18 -03:00
Bruno Oliveira 836dc451f4 Fix unicode issue while running doctests in Python 2
Fix #2434
2017-05-26 07:35:14 -03:00
wanghui d7a5c5716f
Add UnicodeWarning for unicode warnings in Python2 2017-05-26 13:12:02 +08:00
wanghui c39689da41
Correct warnings with unicode message. 2017-05-25 17:59:42 +08:00
Florian Bruhin d9b93674c3 Make --cache-show output deterministic
This makes sure things don't jump around in the regenerated docs.
2017-05-23 08:01:39 +02:00
Bruno Oliveira d343f9497c Merge branch 'release-3.1' 2017-05-22 19:10:06 -03:00
Jason R. Coombs c9c2c34b44 Remove unused parameter 2017-05-20 04:39:45 -04:00
Jason R. Coombs 9beeef970e Parse the filename in the generator expression 2017-05-20 04:38:30 -04:00
Jason R. Coombs 43aa037ebd Reindent 2017-05-20 04:38:30 -04:00
Jason R. Coombs 2abf2070f2 Collapse nested for loops into a generator expression 2017-05-20 04:38:30 -04:00
Jason R. Coombs ce0ff0040f Reindent and add docstring 2017-05-20 04:38:27 -04:00
Jason R. Coombs 6d2e11b7d1 Extract method for _mark_plugins_for_rewrite 2017-05-20 04:18:41 -04:00
Bruno Oliveira d86c89e193 Revert refactor of old-style to new-style classes
As discussed in the mailing list, unfortunately this might break APIs
due to the subtle differences between new and old-style classes (see #2398).

This reverts commit d4afa1554b from PR #2179.
2017-05-17 18:20:51 -03:00
Ronny Pfannschmidt 783670b84e Merge pull request #2274 from dmand/feat/junitxml/suite-name-option
Add `junit_suite_name` ini option
2017-05-13 19:10:29 +02:00
Dmitri Pribysh c9282f9e94 Transition to using ini option for suite name 2017-05-12 17:48:50 -03:00
Dmitri Pribysh fe7d89f033 Add '--junit-suite-name' CLI option 2017-05-12 17:48:50 -03:00
Ronny Pfannschmidt 8bcf88ec12 try to consider all modules after registration as plugin 2017-05-05 11:16:05 +02:00
Bruno Oliveira f3b359f5b8 Merge remote-tracking branch 'upstream/master' into merge-master-into-features
# Conflicts:
#	_pytest/capture.py
#	_pytest/compat.py
#	_pytest/python.py
#	testing/python/collect.py
#	testing/test_mark.py
2017-05-03 19:04:53 -03:00
Bruno Oliveira 630cca2fba Fix py35-trial environment
After updating to twisted 17.1.0, again the trial tests started to fail; didn't investigate too deep, decided to just
no longer delete "zope" modules when cleaning up after pytester because it seems more zope modules keep
global state that shouldn't be discarded
2017-05-02 21:05:42 -03:00
Vitaly Lashmanov 60b8339166 Issue #2383 - Show the correct error message when collect "parametrize" func with wrong args and add test for this case. 2017-04-29 14:32:09 +03:00
Bruno Oliveira cccb2cc92b Merge pull request #1834 from RonnyPfannschmidt/setuptools-scm-take-2
second take at setuptools_scm
2017-04-27 09:10:23 -03:00
Ronny Pfannschmidt a280e43949 fix import error 2017-04-26 15:57:55 +02:00
Ronny Pfannschmidt e02cb6d7ce restore setuptools_scm write_to usage 2017-04-23 16:59:08 +02:00
Bruno Oliveira 25371ddbfd Merge pull request #2315 from RonnyPfannschmidt/namespace-hook
remove pytest internal usage of the namespace hook
2017-04-21 16:24:20 -03:00
Ronny Pfannschmidt 4242bf6262 use unknown to specify unknown versions 2017-04-20 21:46:58 +02:00
Kodi Arfer dcefb287fc Try not to assume a module's file extension is .py 2017-04-19 12:26:56 -07:00
Ronny Pfannschmidt 2cf422733c restore linting, drop _pytest._version for check-manifest 2017-04-19 20:25:53 +02:00
Ronny Pfannschmidt c3aee4b1e6 second take at setuptools_scm
since setuptools 18.6 fixes the issues with develop installs

https://github.com/pypa/setuptools/blob/master/CHANGES.rst#186

https://github.com/pypa/setuptools/issues/439
2017-04-19 19:40:42 +02:00
Bruno Oliveira cac82e71d8 Improve item.warn handling of fslocation parameter
Just pass fslocation forward and let the hook implementer decide what to do with the parameter
2017-04-13 19:01:14 -03:00
Bruno Oliveira d9a2e70155 Change LsofFdLeakChecker to emit a warning instead of failing when detecting leaked FDs
Related to #2366
2017-04-13 17:34:48 -03:00
Michael Howitz 7d4ac14a31 Fix #2343: Replace version checks by constants.
This way they do not have to be recomputed at runtime.
2017-04-12 08:18:09 +02:00
Bruno Oliveira 731776702d Fix hook name in LsofFdLeakChecker 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
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
Ben Lloyd 21f1c2b03f Update fixtures.py
Corrected "or or" typo in docstring (and made indentation consistent).
2017-04-07 16:48:38 +01: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 417b54abed added option to unicode plugin name 2017-04-05 13:03:11 +00:00
Bruno Oliveira a542ed48a2 Convert using utf-8 instead of ascii in safe_str()
This way we don't lose information and the returned string is
ascii-compatible anyway
2017-03-29 15:18:41 -03:00
Bruno Oliveira 58ac4faf0c Fix exception formatting while importing test modules
Fix #2336
2017-03-29 14:43:13 -03:00
Ronny Pfannschmidt afb1778294 put in a singular namespace hook to work around the strange issue 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt ebeba79be3 remove the namespace hook from mark after the param feature merge 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 6165939b0d fix rebase mistakes 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt efe03400d8 fixup nose/pytest plugins 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt c9ab421398 fix python2 only import loop failure 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 147bb8aea5 correct setting pytest.config 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 7cdefce656 fix up oversights 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 92f6ab1881 fix all singular internal module imports and add a test for them 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 23bc9815c4 remove pytest_namespace from _pytest.fixtures 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt ae234786ea remove pytest_namespace from _pytest.python 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 99c8f2d403 remove pytest_namespace from _pytest.main 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 61f418a267 hollow out pytest_namespace in _pytest.fixtures 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 9b58d6eaca prepare a own pytest.collect fake module in oder to remove the nested builtin namespaces 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 839c936153 _pytest.mark: fix unconfigure after bad configure, still potential bug 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 7d797b7dbf add a note about the deprecation of the pytest_namespace hook 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 9b755f6ec6 remove pytest_namespace from _pytest.skipping 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 90788defb2 remove pytest_namespace from _pytest.mark and fix latent pytest nesting bug 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 6a02cdbb35 remove pytest_namespace from _pytest/runner.py 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt c74103f395 remove pytest_namespace from recwarn and fixture decorators 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 794fd5658c remove pytest_namespace from _pytest/debugging.py 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt fab9b993f8 remove pytest_namespace from _pytest.freeze_support 2017-03-28 11:45:06 +02:00
Ronny Pfannschmidt 5818e65cf3 remove pytest_namespace from _pytest/assertion 2017-03-28 11:35:29 +02:00
Bruno Oliveira 2c730743f1 Fix errors related to warnings raised by xdist
- pytester was creating a 'pexpect' directory to serve as temporary dir, but due to the fact that
   xdist adds the current directory to sys.path, that directory was being considered as candidate
   for import as a package. The directory is empty and a warning was being raised about
   it missing __init__ file, which is now turned into an error by our filterwarnings config
   in pytest.ini.

- Decided to play it safe and ignore any warnings during `pytest.importorskip`.

- pytest-xdist and execnet raise two warnings which should be fixed upstream:
   pytest-dev/pytest-xdist/issues/133
2017-03-21 22:17:07 -03:00
Bruno Oliveira fa56114115 Clean up warnings generated by pytest's own suite 2017-03-20 22:13:17 -03:00
Bruno Oliveira d027f760c0 Avoid displaying the same warning multiple times for an item 2017-03-20 20:40:53 -03:00
Bruno Oliveira 3373e02eae Add __future__ imports to warnings module 2017-03-20 20:06:01 -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 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
Xander Johnson dc6890709e Change ValueError to io.UnsupportedOperation in capture.py. Resolves issue #2276 2017-03-14 18:55:58 -03:00
Bruno Oliveira fa15ae7545 Post 3.0.7 release handling 2017-03-14 18:07:44 -03:00
Bruno Oliveira b1ab2ca963 Bump to version 3.0.7 and update CHANGELOG 2017-03-13 18:37:49 -04: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 bddb922f7b Rename internal option to disable_warnings 2017-03-04 16:32:10 -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
Bruno Oliveira 3aac3d0a00 Merge branch 'master' into anydbmfix 2017-03-01 14:41:18 -03:00
Anthony Sottile 8b598f00e9 Make pytester use pytest's capture implementation 2017-02-23 17:46:28 -08: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