Commit Graph

2213 Commits

Author SHA1 Message Date
Bruno Oliveira 6e4efccc38 Rename test_cache to test_cacheprovider for consistency with cacheprovider 2018-01-29 08:40:29 -02:00
Bruno Oliveira aff463a3c4 Merge remote-tracking branch 'upstream/master' into features 2018-01-27 12:28:43 -02:00
Bruno Oliveira b3247c1d03
Merge pull request #3044 from RonnyPfannschmidt/parameterset-empty-enable-xfail
empty parameterset - enable opt to xfail
2018-01-27 12:23:49 -02:00
Bruno Oliveira cd0b2ace67
Merge pull request #3150 from alanbato/pytest_cache
Change cache directory structure to include `pytest`
2018-01-27 10:08:56 -02:00
Ronny Pfannschmidt 17a1ed5edf use a constant to sort out repeated use of the EMPTY_PARAMETERSET_OPTION 2018-01-26 12:12:26 +01:00
Ronny Pfannschmidt a54cd4c2fd correct testing and usage of the empty_parameter_set_mark config option 2018-01-26 12:05:52 +01:00
Bruno Oliveira a58099022a
Merge pull request #3124 from nicoddemus/logging-3013
Changes in the logging plugin for 3.4
2018-01-26 08:52:43 -02:00
Ronny Pfannschmidt d4c11e58aa exted empty parameterset check with reason test 2018-01-26 11:18:50 +01:00
Ronny Pfannschmidt 7f83605c81 fix empty parameterset tests by mocking a config object 2018-01-26 11:10:00 +01:00
Ronny Pfannschmidt 37b41de779 fix #2527 - introduce a option to pic the empty parameterset action 2018-01-26 11:10:00 +01:00
Alan Velasco a24ca9872f Change cache directory name to include `pytest` 2018-01-25 07:50:08 -06:00
feuillemorte 0cfa975930 #1642 Fix tests 2018-01-25 15:57:04 +03:00
Bruno Oliveira b8be339632
Merge pull request #3148 from nicoddemus/deprecate-old-style-classes-2147
All classes now subclass object for better py3 compatibility
2018-01-25 10:41:28 -02:00
Bruno Oliveira 15cbd61159 Change caplog.get_handler(when) to caplog.get_records(when)
While updating the docs I noticed that caplog.get_handler() exposes
the underlying Handler object, which I think it is a bit too much
detail at this stage. Update to return the records directly instead.
2018-01-24 19:08:49 -02:00
Bruno Oliveira af37778b0d All classes now subclass object for better py3 compatibility
Fix #2147
2018-01-24 18:23:42 -02:00
Bruno Oliveira 3f5e9ea71e Fix -o behavior to no longer swallow all remaining options
The current behavior was too error-prone because a "-o" option would
swallow all the following non-option parameters:

  pytest -o foo=bar path/to/test.py

path/to/test.py would be captured by the -o option, and would fail
because "path/to/test.py" is not in the format "key=value".
2018-01-23 21:19:16 -02:00
Bruno Oliveira 8426c57a9e Ensure changes in the message in the future do not make the test pass by accident 2018-01-23 21:18:59 -02:00
Aron Coyle 203508d9f3 cleanup test cases 2018-01-23 21:18:37 -02:00
Andrew Toolan 2c7f94fdb9 Added basic fix and test 2018-01-23 21:18:10 -02:00
Bruno Oliveira 113bfb6be8 Report 'call' phase as 'live log call'
As commented in review, this makes it consistent with the headers shown
by stdout/stderr capturing ("Captured log call")
2018-01-22 21:43:35 -02:00
Bruno Oliveira 9f4688e549 Remove unnecessary -s from test_log_cli_enabled_disabled 2018-01-22 21:26:14 -02:00
Bruno Oliveira 3a9d0b26d5 Use pytest_runtest_logstart to signal the start of a new test
This also simplifies the code a bit because we don't need to keep
a set of ids anymore
2018-01-22 21:20:48 -02:00
Raphael Castaneda a5e60b6a2d implement #3130 - adding record_xml_attribute fixture
update incorrect expected attribute value in test_record_attribute

attr names must be strings

Update CHANGELOG formatting

update usage documentation

Fix versionadded for record_xml_attribute

Indent the xml schema properly inside the warning box in the docs
2018-01-22 15:14:53 -08:00
Bruno Oliveira 0df42b4426 Show a header for each testing phase during live logging
As suggested during review
2018-01-22 21:00:52 -02:00
feuillemorte 83034bbd48 #1642 Fix rootdir option 2018-01-20 22:30:01 +03:00
Bruno Oliveira 2e40a8b3ca Fix test_caplog_captures_for_all_stages by setting log level 2018-01-20 12:04:28 -02:00
Bruno Oliveira 18e053546c Use six.StringIO and __name__ in test_live_logging_suspends_capture 2018-01-20 12:02:55 -02:00
Bruno Oliveira 9dbcac9af3 Suspend stdout/stderr capturing when emitting live logging messages 2018-01-20 12:02:55 -02:00
Bruno Oliveira 4a436572a8 Simplify test assertions a bit 2018-01-20 12:02:55 -02:00
Bruno Oliveira 8f6a5928f7 Add newline before log messages and enable -v output when log_cli is enabled 2018-01-20 12:02:55 -02:00
Bruno Oliveira 5d89a93977 Small improvements to tests suggested during review 2018-01-20 12:02:54 -02:00
Bruno Oliveira 8d735f3e1d Live log option now writes to the terminal reporter
Ref: #3013
2018-01-20 12:01:42 -02:00
Bruno Oliveira aca1b06747 Undo log level set by caplog.set_level at the end of the test
Otherwise this leaks the log level information to other tests

Ref: #3013
2018-01-20 12:01:42 -02:00
Bruno Oliveira 8dcd2718aa No longer change the level of any logger unless requested explicitly
Ref: #3013
2018-01-20 12:01:42 -02:00
Bruno Oliveira 5ad1313b8a log_cli must now be enabled explicitly
Ref: #3013
2018-01-20 12:00:46 -02:00
Bruno Oliveira 3b3d237f07
Merge pull request #3117 from boxed/access_logs_in_teardown
Access captures logs in teardown
2018-01-20 11:21:17 -02:00
Anders Hovmöller 7ea5a22657 Access captures logs in teardown 2018-01-19 12:42:35 +01:00
feuillemorte 4a18d76160 #1642 remove print 2018-01-17 23:14:40 +03:00
feuillemorte d784155fd2 #1642 Add rootdir option 2018-01-17 23:02:31 +03:00
feuillemorte 8433e2ba04 #2953 fix comments: fix exception type 2018-01-16 23:35:57 +03:00
feuillemorte 076fb56f85 show a simple and easy error when keyword expressions trigger a syntax error 2018-01-16 21:30:44 +03:00
Brian Maissy 4a3863c2e2 use flush in order to avoid hanging on mac 2018-01-14 23:00:23 +02:00
Bruno Oliveira 5939b336cd Fix progress report when tests fail during teardown
Fix #3088
2018-01-11 20:42:05 -02:00
Bruno Oliveira b68b80aec9 Add new pytest_runtest_logfinish hook
Fix #3101
2018-01-09 22:17:39 -02:00
Anthony Sottile bd1d17e8de Replace py.std with stdlib imports 2018-01-09 12:44:10 -08:00
Bruno Oliveira 93306f6a5e Merge remote-tracking branch 'upstream/master' into features 2018-01-09 18:41:00 -02:00
Anthony Sottile 205e29d843 Remove unnecessary `# noqa` comments.
Commit automated with https://github.com/asottile/yesqa
2017-12-22 08:29:48 -08:00
Bruno Oliveira c70efaa0fb
Merge pull request #3047 from RonnyPfannschmidt/mark-newapi
move node base classes from main to nodes
2017-12-19 07:59:25 -02:00
Ronny Pfannschmidt afc607cfd8 move node base classes from main to nodes 2017-12-18 11:08:20 +01:00
Jurko Gospodnetić f3c9c6e8a8 fix restoring Python state after in-process pytest runs
Now each in-process pytest run saves a snapshot of important global Python
state and restores it after the test completes, including the list of loaded
modules & the Python path settings.

Previously only the loaded package data was getting restored, but that was
also reverting any loaded package changes done in the test triggering the
pytest runs, and not only those done by the pytest runs themselves.

Updated acceptance tests broken by this change, which were only passing before
by accident as they were making multiple pytest runs with later ones depending
on sys.path changes left behind by the initial one.
2017-12-17 12:47:50 +01:00
Bruno Oliveira 924b5e2e3d
Merge pull request #3031 from nicoddemus/symlink-privileges
Check if symlink does have privileges on Windows for test_cmdline_python_package_symlink
2017-12-16 12:36:11 -02:00
Bruno Oliveira d87279115d
Merge pull request #3041 from segevfiner/capture-no-disable-progress
Use classic console output when -s is used
2017-12-16 12:34:34 -02:00
Segev Finer 370daf0441 Use classic console output when -s is used
Fixes #3038
2017-12-16 15:00:23 +02:00
Bruno Oliveira 586ecea6f2 Check if symlink does not privileges on Windows for test_cmdline_python_package_symlink
os.symlink might fail on Windows because users require a special policy
to create symlinks (argh).

This is not a problem on AppVeyor because it is logged in as an admin,
but would be surprising for Windows users running pytest's test
suite on their computer.
2017-12-14 19:23:15 -02:00
Bruno Oliveira c3f63ac143 Fix memory leak caused by fixture values never been garbage collected
The leak was caused by the (unused) `FixtureRequest._fixture_values`
cache.

This was introduced because the `partial` object (created to call
FixtureDef.finish() bound with the Request) is kept alive
through the entire session when a function-scoped fixture depends
on a session-scoped (or higher) fixture because of the nested
`addfinalizer` calls.

FixtureDef.finish() started receiving a request object in order to
obtain the proper hook proxy object (#2127), but this does not seem
useful at all in practice because `pytest_fixture_post_finalizer`
will be called with the `request` object of the moment the fixture value
was *created*, not the request object active when the fixture value
is being destroyed. We should probably deprecate/remove the request
parameter from `pytest_fixture_post_finalizer`.

Fix #2981
2017-12-13 19:49:06 -02:00
Ronny Pfannschmidt 476d4df1b7
Merge pull request #3010 from cryvate/fix-issue-2985
Improve handling of pyargs
2017-12-13 13:56:42 +01:00
Antony Lee c8e7d1ae34 Respect PYTEST_DONT_REWRITE for plugins too. 2017-12-12 17:43:17 -08:00
Henk-Jaap Wagenaar dc19624248 Improve testing comments and code of issue 2985 (symlink in pyargs). 2017-12-12 08:26:40 +00:00
Bruno Oliveira f8f1a52ea0 Merge remote-tracking branch 'upstream/master' into features 2017-12-11 22:18:50 -02:00
Bruno Oliveira 5c6d7739bc
Merge pull request #3015 from jurko-gospodnetic/code-cleanup
Code cleanup
2017-12-11 22:15:50 -02:00
Srinivas Reddy Thatiparthy c2cd239d35 remove _ast reference from test cases as well 2017-12-11 23:24:47 +05:30
Jurko Gospodnetić 3b85e0c3a9 simplify test_conftest_found_with_double_dash() test code 2017-12-11 15:10:04 +01:00
Jurko Gospodnetić 8e8a953ac6 fix test name typo 2017-12-09 13:34:58 +01:00
Jurko Gospodnetić 852b96714e use spaces consistently instead of some of them being   2017-12-09 13:34:57 +01:00
Jurko Gospodnetić 41a6ec6f31 touch up test_cmdline_python_namespace_package() test code 2017-12-09 13:34:56 +01:00
Jurko Gospodnetić 7feab7391d simplify test_pdb_collection_failure_is_shown test data setup code 2017-12-09 13:34:56 +01:00
Jurko Gospodnetić f0bfe9de3d shorten some test code 2017-12-09 13:34:56 +01:00
Henk-Jaap Wagenaar b62fd79c0c Fix issue 2985. 2017-12-07 15:12:44 +00:00
Bruno Oliveira 655146e522 Merge remote-tracking branch 'upstream/master' into features 2017-12-05 22:30:35 -02:00
Florian Bruhin ce30896cd2 Also blacklist pytest-capturelog plugin
This is the older plugin before pytest-catchlog was around. Apparently there are
people still using it.

Fixes #3004
2017-12-05 20:02:56 +01:00
Ronny Pfannschmidt 2e8b0a83fe
Merge pull request #2989 from nicoddemus/bring-tr-writer-back-2984
Bring back TerminalReporter.writer as an alias to TerminalReporter._tw
2017-12-01 17:42:31 +01:00
Bruno Oliveira 369c711f14
Merge pull request #2971 from blueyed/fix-ZeroDivisionError
Fix ZeroDivisionError with 0 collected tests
2017-11-30 21:12:46 -02:00
Bruno Oliveira cf0cac3b73 Bring back TerminalReporter.writer as an alias to TerminalReporter._tw
Fix #2984
2017-11-30 19:56:47 -02:00
ST John 652936f47f make linter happier 2017-11-30 10:29:05 +00:00
ST John e66473853c add test 2017-11-30 10:19:29 +00:00
Florian Bruhin 88ed1ab648
Merge pull request #2964 from rpuntaie/master
fix issue #2920
2017-11-29 10:32:28 +01:00
Florian Bruhin 191e8c6d9b
Merge pull request #2969 from nicoddemus/null-bytes-2957
Always escape null bytes when setting PYTEST_CURRENT_TEST
2017-11-29 06:57:48 +01:00
Bruno Oliveira 6bbd741039 Add test for #2971 2017-11-28 22:42:52 -02:00
Bruno Oliveira 2a75ae46c3 Improve test that blocks setuptools plugins from being loaded
Make it a parametrized test to ensure all the mocked mechanisms in
the test actually work as expected when we *do not* use "-p no:"
2017-11-28 21:29:58 -02:00
Bruno Oliveira 89cf943e04 Always escape null bytes when setting PYTEST_CURRENT_TEST
Fix #2957
2017-11-28 19:45:13 -02:00
Roland Puntaier 833f33fa0c removed comments 2017-11-28 17:38:49 +01:00
Roland Puntaier 6843d45c51 added test for #2920 fix 2017-11-28 17:29:52 +01:00
Bruno Oliveira 796db80ca4 Only escape str-like arguments passed to warnings
Fix #2956
2017-11-27 23:17:15 -02:00
Bruno Oliveira 4678cbeb91 Merge remote-tracking branch 'upstream/features' 2017-11-27 19:37:58 -02:00
Bruno Oliveira c58715371c
Merge pull request #2954 from blueyed/rewritten
Fix spelling: s/re-writ/rewrit/g
2017-11-26 18:12:30 -02:00
Daniel Hahler d5f038e29a Fix spelling: s/re-writ/rewrit/g
This also fixes "can not" to "cannot" in the "Module already imported so
cannot be rewritten" assertion error.
2017-11-26 20:46:06 +01:00
Bruno Oliveira 95de11a44e Block pytest-catchlog and issue a warning
Trying to install pytest-3.3 and pytest-catchlog will result in an
option conflicts because both declare the same options.
2017-11-23 19:53:12 -02:00
Bruno Oliveira 05cfdcc8cb Revert making TerminalWriter public in TerminalReporter plugin
We eventually want to replace py.io.TerminalWriter (exposed as
"_tw" in TerminalReporter) by something else, so deprecating access
to "_tw" and making it public as "writer" is contrary to that.
2017-11-23 19:53:12 -02:00
Bruno Oliveira f50ace7c0a Merge remote-tracking branch 'upstream/master' into release-3.3.0 2017-11-23 20:20:40 +00:00
Bruno Oliveira dc574c60ef Use regex match-count syntax to improve test readability 2017-11-22 17:16:25 -02:00
Sviatoslav Abakumov 5e71ffab87 Handle marks without description 2017-11-22 15:47:15 +03:00
Bruno Oliveira f05333ab75 Fix rewrite to not write past the edge of the screen 2017-11-22 00:00:02 -02:00
Bruno Oliveira c8d52b633b Fix assertion rewrite to match module names correctly
Fix #2939
2017-11-21 23:06:47 -02:00
Bruno Oliveira 3a5dbabf60 Add tests for progress output and docs for ``console_output_style``
Fix #2657
2017-11-21 21:01:51 -02:00
Bruno Oliveira dab889304e Implement progress percentage reporting while running tests
Fix #2657
2017-11-21 21:01:41 -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
Bruno Oliveira 6161bcff6e
Merge pull request #2925 from asottile/capfdbinary
Add capfdbinary fixture
2017-11-17 08:00:10 -02:00
Bruno Oliveira 1f08d990d5 Deprecate metafunc.addcall
Fix #2876
2017-11-15 15:16:00 -02:00
Anthony Sottile 8f90812481 Add capfdbinary fixture
`capfdbinary` works like `capfd` but produces bytes for `readouterr()`.
2017-11-14 14:50:00 -08:00
Bruno Oliveira f074fd9ac6 Merge remote-tracking branch 'upstream/features' into malinoff/fix-2124 2017-11-12 11:16:08 -02:00
Bruno Oliveira 6550b9911b pytest_fixture_post_finalizer now receives a request argument 2017-11-12 11:14:55 -02:00
Bruno Oliveira 258031afe5 Merge remote-tracking branch 'upstream/master' into malinoff/fix-2124 2017-11-12 10:34:47 -02:00
Ronny Pfannschmidt f0f2d2b861
Merge branch 'master' into fix-missing-nodeid-with-pyargs 2017-11-11 14:33:55 +01:00
Bruno Oliveira 983a09a2d4 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2017-11-10 18:33:02 -02:00
Bruno Oliveira 3900879a5c Mark test_py2_unicode as xfail in PyPy2 on Windows
#2905
2017-11-09 19:17:17 -02:00
Bruno Oliveira b11640c1eb Fix linting E722: do not use bare except 2017-11-04 13:59:10 -02:00
Bruno Oliveira 03829fde8a Fix linting E741: ambiguous variable name 2017-11-04 13:59:10 -02:00
Ronny Pfannschmidt b18a9deb4c
Merge pull request #2892 from nicoddemus/merge-master-into-features
Merge upstream/master into features
2017-11-04 08:15:28 +01:00
Bruno Oliveira d7e8eeef56
Merge pull request #2878 from RonnyPfannschmidt/collector-makeitem-deprecate
deprecate the public internal PyCollector.makeitem method
2017-11-03 17:13:18 -02:00
Bruno Oliveira f3a119c06a Merge upstream/master into features 2017-11-03 16:37:18 -02:00
Ronny Pfannschmidt d1aa553f73 add mocked integrationtest for the deprecationwarning of makeitem 2017-10-30 19:49:14 +01:00
Ronny Pfannschmidt cd747c48a4
Merge pull request #2874 from nicoddemus/fix-py27-xdist-envs-2843
Change directory for py27 xdist-related envs
2017-10-30 17:09:34 +01:00
Thomas Hisch 2f993af54a Fix context output handling for doctests
Show full context of doctest source in the pytest output, if the lineno of
failed example in the docstring is < 9.
2017-10-29 20:06:10 +00: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 27cea340f3 Remove trailing whitespace 2017-10-26 21:55:28 -02:00
Bruno Oliveira 27bb2eceb4 Add comment about why we remove docstrings on test_assertrewrite
As explained in pytest-dev/pytest#2870
2017-10-26 20:15:05 -02:00
Sviatoslav Abakumov fd7bfa30d0 Put imports on the last line unless there are other exprs 2017-10-25 11:05:07 +03:00
Sviatoslav Abakumov 3427d27d5a Try to get docstring from module node 2017-10-25 10:54:43 +03:00
Ronny Pfannschmidt def471b975 Merge pull request #2869 from nicoddemus/merge-master-into-features
Merge master into features
2017-10-25 09:08:08 +02:00
Ronny Pfannschmidt f743e95cfc Merge pull request #2791 from OfirOshir/features
bugfix for issue #2491
2017-10-25 09:04:01 +02:00
Bruno Oliveira 6b86b0dbfe Fix additional linting issues 2017-10-24 21:01:00 -02:00
Bruno Oliveira bdab29fa3d Merge pull request #2867 from Perlence/ini-markers-whitespace
Strip whitespace from markers in INI config
2017-10-24 20:11:20 -02:00
Bruno Oliveira 6821d36ca5 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2017-10-24 19:57:14 -02:00
Sviatoslav Abakumov 52aadcd7c1 Strip whitespace from markers in INI config
Resolves #2856.
2017-10-24 14:18:39 +03:00
Tom Dalton 655ab0bf8b Address more review comments, fix massive bug I reintroduced in the node-splitting code :-/ 2017-10-23 17:49:49 +01:00
Tom Dalton 1e6dc6f8e5 Working (I think) fix for #2836 2017-10-23 13:26:42 +01:00
Tom Dalton c03612f729 Test now looks for real expected output 2017-10-23 12:40:32 +01:00
Tom Dalton 29fa9d5bff Add failing test 2017-10-23 12:28:54 +01:00
Ronny Pfannschmidt 083084fcbc Merge pull request #2842 from ceridwen/features
Use funcsigs and inspect.signature to do function argument analysis
2017-10-20 07:49:08 +02:00
Bruno Oliveira f7387e45ea Fix linting 2017-10-19 21:50:15 -02:00
Ceridwen 3da28067f3 Replace introspection in compat.getfuncargnames() with inspect/funcsigs.signature 2017-10-19 16:01:26 -07:00
Ronny Pfannschmidt 3f9f4be070 Merge pull request #2845 from jespino/fix/2832
Adding Failed exception to manage maxfail behavior
2017-10-19 09:12:11 +02:00
Bruno Oliveira 537fc3c315 Merge pull request #2824 from dirk-thomas/pytest_addopts_before_initini
get PYTEST_ADDOPTS before calling _initini
2017-10-18 18:35:12 -02:00
Jesús Espino 00d3abe6dc Adding Failed exception to manage maxfail behavior 2017-10-17 21:32:20 +02:00
je eaf38c7239 call path.read(), add tests, add news fragment 2017-10-14 00:49:54 +08:00
Ronny Pfannschmidt c750a5beec Merge pull request #2794 from thisch/catchlog
Merge pytest-catchlog plugin
2017-10-12 09:02:46 +02:00
Ronny Pfannschmidt df37cdf51f Merge pull request #2808 from georgeyk/allow-module-level-skip
Allow module level skip
2017-10-12 06:50:53 +02:00
Thomas Hisch 8aed5fecd9 Remove test_logging_initialized_in_test 2017-10-12 02:19:24 +02:00
Thomas Hisch 0e83511d6d Rename name of registered logging plugin 2017-10-12 02:19:24 +02:00
Thomas Hisch 815dd19fb4 Remove unicode literal compat code 2017-10-12 02:19:24 +02:00
Bruno Oliveira 10a3b9118b Use a relative cache_dir in test because of how arguments are parsed on Windows
We use shlex to parse command-line arguments and PYTEST_ADDOPTS, so passing
a full path with '\' arguments produces incorrect results on Windows

Anyway users are advised to use relative paths for portability
2017-10-11 19:37:17 -03:00
Dirk Thomas ce8c829945 add test for #2824 2017-10-11 09:41:18 -07:00
hugovk 7113c76f0d Remove unused import 2017-10-10 09:03:26 +03:00
hugovk ef732fc51d Remove code for unsupported Python versions 2017-10-10 08:54:56 +03:00
Ronny Pfannschmidt 9b0ce535c9 Merge pull request #2801 from nicoddemus/capture-fixture
Allow fixtures to use capsys and capfd
2017-10-09 15:26:50 +02:00
Leonard Lausen e86ba41a32 Add testcase for #2819 2017-10-09 01:06:25 +09:00
George Y. Kussumoto 03ce0adb79 Fix: handle CollectReport in folded_skips function 2017-10-04 19:18:55 -03:00
Bruno Oliveira e7a4d3d8cf Merge remote-tracking branch 'upstream/master' into features 2017-10-04 17:28:34 -03:00
Bruno Oliveira df6d5cd4e7 Use ascii_escaped to escape unicode warnings 2017-10-03 12:19:37 -03:00
Bruno Oliveira fbb9e9328b Fix warning about non-ascii warnings even when they are ascii
Fix #2809
2017-10-03 07:39:53 -03:00