Commit Graph

106 Commits

Author SHA1 Message Date
Bruno Oliveira af37778b0d All classes now subclass object for better py3 compatibility
Fix #2147
2018-01-24 18:23:42 -02:00
Anthony Sottile 219b758949 Add capsysbinary fixture
`capsysbinary` works like `capsys` but produces bytes for `readouterr()`.
2017-11-17 09:02:46 -08:00
Anthony Sottile 8f90812481 Add capfdbinary fixture
`capfdbinary` works like `capfd` but produces bytes for `readouterr()`.
2017-11-14 14:50:00 -08:00
Samuel Dion-Girardeau b27dde24d6 Use a nametuple for `readouterr()` results
This allows accessing `out` and `err` directly by attribute,
while preserving tuple unpacking.

Also added tests, one for the `capsys` fixture, and one for the
`MultiCapture` class itself.
2017-10-28 14:53:19 -04:00
Bruno Oliveira f9589f7b64 Resume output capturing after capsys/capfd.disabled() context manager
Fix #1993
2017-09-29 17:24:31 -03:00
Bruno Oliveira 22f338d74d Refactor some names for better understanding and consistency 2017-09-26 20:09:42 -03:00
Bruno Oliveira 9919269ed0 Allow to use capsys and capfd in other fixtures
Fix #2709
2017-09-26 20:09:36 -03:00
Bruno Oliveira f825b4979b Merge remote-tracking branch 'upstream/master' into features 2017-09-05 19:44:33 -03:00
Bruno Oliveira cc0f2473eb Fix windows console workaround error with non-standard io-streams
Fix #2666
2017-08-07 20:57:13 -03:00
Srinivas Reddy Thatiparthy dc563e4954 convert py module references to six module 2017-08-04 08:05:03 +05:30
Daniel Hahler 0603d1d500 capture: ensure name of EncodedFile being a string
Fixes https://github.com/pytest-dev/pytest/issues/2555.
2017-07-25 20:37:37 +02:00
Segev Finer d0ecfdf00f Delete trailing whitespace 2017-07-24 16:55:50 +03:00
Segev Finer 43544a431c Early import colorama so that it get's the correct terminal 2017-07-24 15:17:39 +03:00
Andras Tim b840622819 Fixed E302 flake8 errors
expected 2 blank lines, found 0
2017-07-17 01:44:23 +02:00
Andras Tim 17a21d540b Fixed E301 flake8 errors
expected 1 blank line, found 0
2017-07-17 01:44:23 +02:00
Andras Tim 195a816522 Fixed E265 flake8 errors
block comment should start with ‘# ‘
2017-07-17 01:44:22 +02:00
Andras Tim 8f3eb6dfc7 Fixed E261 flake8 errors
at least two spaces before inline comment
2017-07-17 01:44:22 +02:00
Andras Tim 617e510b6e Fixed E231 flake8 errors
missing whitespace after ‘,’, ‘;’, or ‘:’
2017-07-17 01:44:22 +02: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
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
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
Anthony Sottile 6ba3475448 Make capsys more like stdio streams in python3. Resolves #1407. 2017-02-23 17:46:27 -08:00
mandeep d4afa1554b Refactored old style classes to new style classes 2017-01-08 22:52:42 -06:00
Bruno Oliveira 5ce551e469 Merge pull request #2075 from pytest-dev/master
Merge master into features after fixing flake8 errors
2016-11-22 14:10:31 -02:00
Bruno Oliveira 1eb5a690d4 Fix flake8 E305 and E306 errors
These errors started to appear with flake8-3.1.1, while they don't appear with
version 3.1.0 (weird).
2016-11-20 18:59:15 -02:00
Vlad Dragos 3444796f3e Fix formating error. 2016-09-26 13:59:28 +03:00
Vlad Dragos 8985c0be3e Change exception raised by DontReadFromInput.fileno() from ValueError to io.UnsupportedOperation 2016-09-26 13:15:35 +03:00
Jordan Guymon a152ea2dbb Add buffer attribute to stdin stub 2016-08-24 16:26:34 -07:00
Bruno Oliveira c2864aba3d Merge branch 'master' into merge-master
# Conflicts:
#	AUTHORS
#	CHANGELOG.rst
#	_pytest/monkeypatch.py
#	_pytest/python.py
2016-07-25 19:06:29 -03:00
Javi Romero 7e37497d5a Uppercase first word in docstrings. Change to an imperative form. Add name to authors. 2016-07-22 12:39:06 +02:00
Bruno Oliveira 775100881a Implement invocation-scoped fixtures 2016-07-09 22:52:05 -03:00
Dave Hunt ef9dd14963 Introduce pytest command as recommended entry point
Fixes #1629
2016-06-21 16:16:57 +02:00
Bruno Oliveira 72bf11cbe9 Add disabled() method to capsys and capfd
Fix #1599
2016-06-19 19:14:36 +02:00
Bruno Oliveira 5afb61ad26 Fix trailing white-space 2015-12-25 17:51:55 -02:00
Bruno Oliveira 57bc14caa0 Apply readline workaround during initial conftest loading 2015-12-25 17:46:19 -02:00
Erik M. Bray 6e170a4a1c * Moved workaround to its own function, mostly for the sake of adding
a more descriptive docstring (the workaround itself is just to import
  readline earlier).  I removed the conditional on targetfd from the
  workaround since it doesn't really matter.

* Added # noqa marker.

* Added changelog entry, and self to authors.
2015-12-24 16:43:34 -05:00
Erik M. Bray 924a9667e1 Make sure readline has been imported before duping any stdio handles--otherwise pyreadline fails to connect to the correct handle for the console's stdout/in. 2015-12-24 14:56:57 -05:00
Florian Bruhin c10f483b9f Don't hardcode 'std' for captured stdout/stderr.
This will make Item.add_report_sect more usable for plugins.
See https://github.com/eisensheng/pytest-catchlog/pull/7
2015-09-22 20:29:16 +02:00
David Szotten 983d249680 reset capture even if readouterr throws
otherwise that exception (and all following output) end up in /dev/null
2015-07-26 01:15:51 +02:00
holger krekel bddc88f09e adapt to pluggy naming, rename pytest.hookspec_opts to pytest.hookspec,s ame with hookimpl_opts
--HG--
branch : pluggy1
2015-05-06 10:08:08 +02:00
holger krekel d2a5c7f99b add documented hookimpl_opts and hookspec_opts decorators
so that one doesn't have to use pytest.mark or function-attribute setting anymore

--HG--
branch : more_plugin
2015-04-25 11:29:11 +02:00
holger krekel 715a235b45 remove shutdown logic from PluginManager and add a add_cleanup() API
for the already existing cleanup logic of the config object.
This simplifies lifecycle management as we don't keep two
layers of shutdown functions and also simplifies the pluginmanager
interface.

also add some docstrings.

--HG--
branch : plugin_no_pytest
2015-04-22 16:33:20 +02:00
holger krekel 0253f7b8d5 remove all occurences of "__multicall__" on hook impls in pytest/*.
also simplify pytest_runtest_markereport hook in _pytest/skipping.py
while touching the code anyway.
2014-10-08 20:23:40 +02:00
David Szotten bc4eecbbac add `encoding` attr to DontReadFromInput
required by https://docs.python.org/2/library/stdtypes.html#file.encoding

and used e.g. by ipdb at _import_ time

--HG--
branch : dontreadfrominput-encoding
2014-09-22 12:19:27 +01:00
Floris Bruynooghe 7d9d502a01 Use py3k compatible .__getattr__() code
From the python-dev thread it seemed like using
object.__getattribute__(self, 'name') is the cleanest way of
implementing a class wich uses .__getattr__() and should be
pickelable.  That only works on new-style classes so this also turns
HookProxy into a new-style class on py2.

This also re-writes the test to not use cPickle so it runs on py3k.
2014-09-05 23:55:14 +01:00
uweschmitt 224b3a2eda hopefully final fix for strange infinite recursion bug 2014-08-11 12:57:47 +02:00
uweschmitt 5d024c7433 hopefully final fix for strange infinite recursion bug 2014-08-11 12:42:36 +02:00
uweschmitt c0d1f3f7ef even better fix as replacement for last commit which was wrong 2014-08-07 17:17:05 +02:00
uweschmitt 9597d3dafe better fix as replacement for last commit 2014-08-07 16:56:45 +02:00