Commit Graph

264 Commits

Author SHA1 Message Date
Bruno Oliveira c6b11b9f62 Refactor direct fixture call warning to avoid incompatibility with plugins
This refactors the code so we have the real function object right during
collection. This avoids having to unwrap it later and lose attached information
such as "async" functions.

Fix #3747
2018-08-01 16:38:43 -03:00
Kale Kundert b8255308d6
Make the infinite-recusrion fix more explicit.
So we remember what happened and don't accidentally regress in the
future.
2018-08-01 12:11:03 -07:00
Bruno Oliveira a5c0fb7f6b Rename recursive_map -> _recursive_list_map as requested in review 2018-08-01 15:17:58 -03:00
Bruno Oliveira 7d13599ba1 Fix recursion in pytest.approx() with arrays in numpy<1.13 2018-08-01 08:04:09 -03:00
Bruno Oliveira 2a2f888909 Move recursive_map from local to free function 2018-08-01 07:30:40 -03:00
Bruno Oliveira ad5ddaf55a Simplify is_numpy_array as suggested in review 2018-08-01 07:28:39 -03:00
Bruno Oliveira 5003bae0de Fix 'at' string for non-numeric messages in approx() 2018-08-01 07:07:37 -03:00
Bruno Oliveira 611d254ed5 Improve error checking messages: add position and use pprint 2018-08-01 07:01:00 -03:00
Ronny Pfannschmidt fcdc1d867e fix #3745 - display absolute cache_dir if necessary 2018-08-01 08:25:37 +02:00
Bruno Oliveira 098dca3a9f Use {!r} for a few other messages as well 2018-07-31 21:14:51 -03:00
Bruno Oliveira bf7c188cc0 Improve error message for invalid types passed to pytest.approx()
* Hide the internal traceback
* Use !r representation instead of !s (the default for {} formatting)
2018-07-31 21:08:24 -03:00
Bruno Oliveira 8c9efd8608 Only call _collectfile on package instances
As discussed in #3751, this feels like a hack, pushing it only so we can
see how it fares on CI and if there are better solutions out there
2018-07-31 19:06:30 -03:00
Kale Kundert d02491931a
Fix the unused import. 2018-07-31 11:33:46 -07:00
Kale Kundert 032db159c9
Let black reformat the code... 2018-07-31 11:23:23 -07:00
Kale Kundert cd2085ee71
approx(): Detect type errors earlier. 2018-07-31 00:26:35 -07:00
Kale Kundert ad305e71d7
Improve docstrings for Approx classes. 2018-07-30 23:26:57 -07:00
Kale Kundert 7d8688d54b
Reflect dimension in approx repr for numpy arrays. 2018-07-30 23:23:17 -07:00
Bruno Oliveira eada0b1fd7 Merge remote-tracking branch 'upstream/master' into release-3.7.0 2018-07-30 20:12:30 +00:00
Bruno Oliveira 8609f8d25a Move warning definition to deprecated module 2018-07-30 14:25:29 -03:00
Bruno Oliveira cf6d8e7e53 Fix test and update warning in pytest_namespace docs 2018-07-30 12:16:42 -03:00
Bruno Oliveira e3d412d1f4 Warn when implementations exist for pytest_namespace hook
This hook has been deprecated and will be removed in the future.

Fix #2639
2018-07-29 22:20:23 -03:00
Kale Kundert bf127a63b2
Need to iterate over the flattened array. 2018-07-27 11:24:42 -07:00
Bruno Oliveira d0ba242c46 Implement change suggested by @kalekundert in PR 2018-07-27 15:07:20 -03:00
Bruno Oliveira 57b0c60cb4 Remove Testdir.run_example as recommended 2018-07-26 20:10:40 -03:00
Bruno Oliveira 011f88f7e7 Deprecate calling fixture functions directly
This will now issue a RemovedInPytest4Warning when the user calls
a fixture function directly, instead of requesting it from test
functions as is expected

Fix #3661
2018-07-26 19:58:42 -03:00
abrammer f0db64ac2e drop the duplicate approx call
update test to include both np.array(actual) and np.array(expected)
2018-07-24 21:18:44 -04:00
Bruno Oliveira f5165064ee Make yield_fixture just call fixture to do its work
Since fixture and yield_fixture are identical, they should call
the same code; as it was, the code inside them was already starting
to deviate.
2018-07-22 09:41:03 -03:00
Bruno Oliveira c9a0881309 Isolate the code that resolves the fixturefunc to a separate function
pytest_fixture_setup was somewhat convoluted because it was trying
to do too many things.
2018-07-22 09:37:41 -03:00
Bruno Oliveira 5167933395 Move teardown code of yield fixtures to a partial to avoid leaks
As it were before, it was keeping a reference to fixturefunc and it
alive when an error occurred
2018-07-22 09:27:34 -03:00
Alan 7bff5866b1 bugfix in ApproxNumpy initialisation, use keywords for arguments now 2018-07-18 17:29:55 -04:00
Bruno Oliveira 0bb29d5649
Merge pull request #3685 from nicoddemus/merge-master-into-features
Merge master into features
2018-07-15 16:53:39 -03:00
Bruno Oliveira ac9ceaacd8 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2018-07-15 11:54:14 -03:00
Tadek Teleżyński d2fe619120 Fix truncated locals in verbose mode 2018-07-15 11:30:26 -03:00
Vlad Shcherbina 58e77f58bd Replace broken type annotations with type comments
Fixes #3635.
2018-07-15 16:58:39 +03:00
Bruno Oliveira f6ceedd15b
Merge pull request #3636 from RonnyPfannschmidt/fixturetest-examples
[RFC] Fixturetest examples - move test contents to use example scripts for contents
2018-07-11 23:29:33 -03:00
Bruno Oliveira 3e599dc149 Check that param sets match number of args during _for_parametrize
It makes sense to validate them during creation of the parameter set
2018-07-11 22:57:53 -03:00
Bruno Oliveira 54fbc6f6e1 Refactor parametrize() code for readability
Extract the parametrize() block of code into methods for better
readability
2018-07-11 21:29:21 -03:00
Anthony Sottile 61301d934e Remove some extraneous `# noqa` comments
This was partially automated with https://github.com/asottile/yesqa

_with a few caveats_:
- it was run under python2 (chosen arbitrarily, when run under python3 other
  things were changed)
- I used `git checkout -p` to revert the removal of `noqa` comments from
  `cmp()` lines.
2018-07-08 17:05:52 -07:00
Anthony Sottile 4ae93a7a07 Remove obsolete __future__ imports 2018-07-08 08:37:02 -07:00
Anthony Sottile 42bbb4fa8a Use -mpytest when invoking pytest in pytester 2018-07-07 17:18:44 -07:00
Bruno Oliveira 303133f013
Merge pull request #3647 from jeffreyrack/3610-add-trace-option
3610 add trace option
2018-07-07 10:05:34 -03:00
Bruno Oliveira 027d2336b8 Add minimal docs for package-scoped fixtures (experimental) 2018-07-05 21:56:31 -03:00
Bruno Oliveira 3c19370cec Merge remote-tracking branch 'upstream/features' into jonozzz/features 2018-07-05 18:15:17 -03:00
Bruno Oliveira 7696d5371a Merge remote-tracking branch 'upstream/master' into features 2018-07-04 18:49:35 -03:00
Jean-Paul Calderone 55ebf261ce Switch to new API 2018-07-03 13:37:03 -04:00
Jeffrey Rackauckas 4afb8c428b Fix python 2 issues 2018-07-02 20:20:42 -07:00
Jeffrey Rackauckas 10a8691eca Add support for yielded functions. 2018-07-02 19:46:26 -07:00
Jeffrey Rackauckas b75320ba95 Fix --trace option with yield tests. 2018-07-02 19:08:41 -07:00
T.E.A de Souza a43205b4bc
Fix monkeypatch doc
`delenv` is incorrectly documented.
2018-07-02 21:01:41 +08:00
Jeffrey Rackauckas 0b70477930 Fix linting issues. 2018-07-01 20:18:00 -07:00
Jeffrey Rackauckas 66fa6bb42e Fix flake8 issues. 2018-07-01 18:50:57 -07:00
Jeffrey Rackauckas a46b94950c Properly set immediately_break value 2018-06-30 21:32:25 -07:00
Jeffrey Rackauckas 54d3cd587d Adding the --trace option. 2018-06-30 18:09:06 -07:00
Bruno Oliveira 2b75a311a7
Merge pull request #3637 from RonnyPfannschmidt/fix-3631
fix #3631 - don't store legacy markinfo when its impossible
2018-06-30 17:48:46 -03:00
Victor 342f2cdc17 Fixes #3630 2018-06-29 16:09:39 +02:00
Ronny Pfannschmidt 5bd5b8c68a fix #3631 - don't store legacy markinfo when its impossible 2018-06-29 14:01:20 +02:00
Ronny Pfannschmidt 0fd86ec8a8 move some fill fixture acceptance tests contents to the examples script folder 2018-06-29 10:58:33 +02:00
Bruno Oliveira 8680dfc939
Merge pull request #3629 from egnartsms/issue-2220-param-breaks-dep
Make test parametrization override indirect fixtures
2018-06-28 21:43:21 -03:00
Ronny Pfannschmidt 3c73d6298a merge from master to features 2018-06-28 17:32:41 +02:00
Serhii Mozghovyi c220fb235a Minor fix (code improvement) 2018-06-28 14:53:06 +03:00
Serhii Mozghovyi 1dc5e97ac2 Make test parametrization override indirect fixtures 2018-06-28 14:32:29 +03:00
Bruno Oliveira e9371a58a0
Merge pull request #3622 from RonnyPfannschmidt/builtin-serialize
move report classes to own file to prepare for serialisazion
2018-06-27 15:17:09 -03:00
Ronny Pfannschmidt 17e01993d9 regendoc and invocation fixes 2018-06-27 08:28:21 +02:00
Ronny Pfannschmidt 581d49635e add docs and changelog 2018-06-27 06:52:36 +02:00
Ronny Pfannschmidt e860ff7299 port some acceptance tests over to copy_example 2018-06-26 22:59:40 +02:00
Ronny Pfannschmidt 0672bc633f enable pytester to run examples copied from the cwd 2018-06-26 22:48:33 +02:00
Ronny Pfannschmidt 2dfb52f7e0 fix rebase artifacts 2018-06-26 22:10:26 +02:00
Ronny Pfannschmidt cc6eb9f83c move test reports to own file 2018-06-26 22:09:15 +02:00
Ronny Pfannschmidt 643e5a9c44 fix docs 2018-06-26 21:57:31 +02:00
Ronny Pfannschmidt b8486037d3 fix #3605 - unpack markdecorators from parameterization 2018-06-26 21:57:31 +02:00
Ronny Pfannschmidt 89e0a3ec27 merge from master to features 2018-06-26 17:01:05 +02:00
Anthony Sottile cbaa7dd56a Upgrade pre-commit hooks except pyupgrade 2018-06-26 06:35:27 -07:00
Marcelo Duarte Trevisani 0030ceb11c Bug fix #3593 - approx method in a single element of numpy array
If the user pass as a expected value a numpy array created like
numpy.array(5); it will creates an array with one element without shape,
when used with approx it will raise an error
'TypeError: iteration over a 0-d array'
2018-06-25 22:55:16 +02:00
Anthony Sottile 1d55c49a9a Fix `ImportWarning` triggered by explicit relative imports 2018-06-23 07:55:49 -07:00
Ronny Pfannschmidt 95f00de0df use paths for config.cache.get key 2018-06-23 00:14:06 +02:00
Ronny Pfannschmidt c4c666cbc4 use Pathlib instead of path splitting 2018-06-23 00:07:57 +02:00
Ronny Pfannschmidt ee30bf45c9 rebase onto readme addition 2018-06-23 00:03:10 +02:00
Ronny Pfannschmidt 603df1ea1c whops, its supported starting with python 3.6, not python 3.5 2018-06-22 23:56:22 +02:00
Ronny Pfannschmidt abbf73ad1a use pathlib2 up to python3.4 - damn the stdlib 2018-06-22 23:56:22 +02:00
Ronny Pfannschmidt 1226cdab47 fix warnings and json dumping of cacheprovider 2018-06-22 23:56:22 +02:00
Ronny Pfannschmidt ab80e0fba0 sort compat flake8 mess correctly 2018-06-22 23:56:22 +02:00
Ronny Pfannschmidt fb992a0c81 reorder attr.ib specs 2018-06-22 23:56:22 +02:00
Ronny Pfannschmidt 23581d44bd add missed file 2018-06-22 23:56:22 +02:00
Ronny Pfannschmidt c7eb53317b port cache plugin internals to pathlib
warning logging got broken by detanglement from config
2018-06-22 23:56:22 +02:00
Bruno Oliveira 0d3914b626 Remove extra '\' left at the end of a line in cache's readme contents 2018-06-21 20:12:50 -03:00
Anthony Sottile 8b4c59e606 Silence usage of `reduce` warning in python 2 2018-06-21 13:27:00 -07:00
avirlrma c672bfa32e added changelog entry
moved cache readme tests to test_cacheprovider.py
2018-06-21 17:43:10 +05:30
avirlrma 8f1d8ac970 fixed linting errors
ran black
removed unused imports and variables
2018-06-21 15:15:55 +05:30
avirlrma 53d4710c62 added tests for .pytest_cache README
Helper class to check if readme exists in .pytest_cache directory
 Tests to check for readme when tests pass and when they fail
2018-06-21 14:25:00 +05:30
avirlrma 31f089db6a add reamde for .pytest_cache
method - `ensure_readme()`
2018-06-21 13:14:58 +05:30
Bruno Oliveira 93e55ad2fa Remove unused attribute and parameter in CallSpec2 2018-06-18 21:48:49 -03:00
Bruno Oliveira 2925f3057f
Merge pull request #3584 from jwodder/fix-3583
Fix encoding error with `print` statements in doctests
2018-06-18 08:03:07 -03:00
Hynek Schlawack acb8f23311 Fix 2 DeprecationWarnings about invalid escape seq 2018-06-16 10:37:33 +02:00
Anthony Sottile b285078db4
Merge pull request #3535 from RonnyPfannschmidt/config-split
begin to turn config into package
2018-06-15 10:28:06 -07:00
John T. Wodder II d382f3e77f [#3583] Fix encoding error with `print` statements in doctests
This fix was suggested by Stack Overflow user phd in
<https://stackoverflow.com/a/50863820/744178>.
2018-06-15 17:23:54 +00:00
Wil Cooley 3615977608 Add `messages` property to `caplog` fixture. 2018-06-14 12:22:33 -07:00
Ronny Pfannschmidt 8d072205e9 fix whitespace 2018-06-13 22:00:22 +02:00
Bruno Oliveira b5102d03a6
Fix add_marker docs 2018-06-13 14:57:10 -03:00
Ronny Pfannschmidt eb0c6a8287 fix addmarker - extract mark from markdecorator 2018-06-13 17:27:00 +02:00
Ronny Pfannschmidt b0ec442d24 rework Node.add_marker parameter list and docstring 2018-06-12 17:55:58 +02:00
Ronny Pfannschmidt 37793d4cdb fix addmarker - extract mark from markdecorator 2018-06-12 15:50:58 +02:00
Anthony Sottile ef88251573
Merge pull request #3570 from sangongs/fix_stack_finalizer
Continue to call finalizers in the stack when a finalizer raises an exception
2018-06-11 19:07:59 -07:00
Guoqiang Zhang a888bf182e Continue to call finalizers in the stack when a finalizer in a former scope raises an exception 2018-06-11 18:01:18 -04:00
Ronny Pfannschmidt 61471df8da
Merge pull request #3562 from nicoddemus/revert-callinfo-result
Revert change of Callinfo.result default value
2018-06-11 19:03:01 +02:00
Anthony Sottile 49f621de76 Print <undetermined location> instead of None for warnings 2018-06-10 10:51:36 -07:00
Bruno Oliveira 10b0b81346 Revert change of Callinfo.result default value
As discussed in #3560, this should not go to master because this breaks
the API.

Reverts commits:

1a7dcd73cf
198e993969
2018-06-10 11:47:58 -03:00
Alan Velasco 1a7dcd73cf Add a default value to CallInfo.result 2018-06-09 16:58:23 -07:00
Daniel Hahler c30c137a95 Improve display of hint about --fulltrace with KeyboardInterrupt
- display the location first
- display hint about --fulltrace in parenthesis
2018-06-07 23:50:24 +02:00
Ronny Pfannschmidt 1459cbe01f put config path finding and exceptions into own modules 2018-06-05 10:07:02 +02:00
Ronny Pfannschmidt c9df77cbd6 move argument parser to own file 2018-06-05 09:55:28 +02:00
Ronny Pfannschmidt 026cd36237 make builtin plugins a list 2018-06-05 09:40:50 +02:00
Ronny Pfannschmidt bc2247219f turn config into package
this prepares the splitting
2018-06-05 09:08:53 +02:00
Anthony Sottile 04f08b67a4 __code__ and __self__ are attributes in python2.6+ 2018-06-03 13:12:46 -07:00
Ronny Pfannschmidt eaa882f3d5 switch to src layout 2018-05-26 09:10:38 +02:00