Daniel Hahler
554dba391c
Multiple colors with terminal summary_stats
...
Ref: https://github.com/pytest-dev/pytest/issues/5060
2019-10-21 04:35:45 +02:00
Daniil Galiev
9275012ef7
fix bug with nonskipped first test in package
2019-10-21 00:11:24 +02:00
Daniel Hahler
803cc1f294
Merge master into features
2019-10-21 00:08:03 +02:00
Daniel Hahler
d91ff0af8a
assertrepr_compare: use safeformat with -vv
2019-10-20 20:51:03 +02:00
Daniel Hahler
0123b29ed7
tests: remove unnecessary test, clarify
...
Follow-up to https://github.com/pytest-dev/pytest/pull/6009 .
2019-10-20 20:40:13 +02:00
Bruno Oliveira
16efa1bfef
Merge pull request #6009 from yoavcaspi/fix_keyboardInterrupt_on_setup_show
...
setuponly: remove printing out/err from capman
2019-10-20 14:00:06 -03:00
Daniel Hahler
fbb7f663be
Merge pull request #6005 from blueyed/harden-trial
...
tests: harden/fix test_trial_error
2019-10-20 17:35:15 +02:00
Yoav Caspi
5624e366c1
add more indications to the result of the tests
2019-10-20 09:54:23 +03:00
Anthony Sottile
3a402811de
Ensure .pytest_cache file has a newline at the end
2019-10-19 14:42:06 -07:00
Bruno Oliveira
b5579d2cf2
Make InvocationParams.args a tuple ( #6008 )
...
Make InvocationParams.args a tuple
2019-10-19 17:36:42 -03:00
Bruno Oliveira
d12cdd3127
Make InvocationParams.args a tuple
...
This avoids mutating the original list to reflect on InvocationParams,
which is supposed to be an immutable snapshot of the state of pytest.main()
at the moment of invocation (see pytest-dev/pytest-xdist#478 ).
2019-10-19 16:42:58 -03:00
Yoav Caspi
e05b33ed16
setuponly: remove printing out/err from capman
2019-10-19 22:33:19 +03:00
Daniel Hahler
15f9568694
Improve/revisit CallInfo.__repr__
2019-10-19 19:07:11 +02:00
Daniel Hahler
5b88612e5b
tests: harden/fix test_trial_error
2019-10-19 09:03:26 +02:00
Daniel Hahler
3173a26388
cache: NFPlugin: keep known nodeids
...
Caveat: does not forget about old nodeids
Fixes https://github.com/pytest-dev/pytest/issues/5206
2019-10-19 04:53:01 +02:00
Daniel Hahler
0976e2f50d
Merge master into features
2019-10-18 17:51:42 +02:00
Daniel Hahler
7ef44913a1
tests: debugging: disable pdb++ within inner tests
...
Ref: https://github.com/pytest-dev/pytest/pull/5306#issuecomment-495690643
2019-10-18 17:08:39 +02:00
Daniel Hahler
90dfee5da5
tests: keep numpy being optional
...
Ref: https://github.com/pytest-dev/pytest/pull/5950#discussion_r335254774
2019-10-16 23:50:23 +02:00
Bruno Oliveira
914a9465ab
tests: move tests for setuponly/setupplan ( #5961 )
...
tests: move tests for setuponly/setupplan
2019-10-15 19:49:26 -03:00
Daniel Hahler
c2ae0e0dc6
tests: move tests for setuponly/setupplan
...
Forgotten in 032ce8baf
.
2019-10-15 00:41:05 +02:00
Daniel Hahler
361f0e6ba7
minor: test_failure_function: use vars
2019-10-14 22:45:25 +02:00
Victor Maryama
63e3d89647
Fixed linting.
2019-10-12 15:08:47 +02:00
Victor Maryama
1f639e2c22
Casting fixture parameter to list at the beginning of parameter parsing.
2019-10-12 14:33:43 +02:00
Daniel Hahler
fb90259460
test_assertion: improve mock_config
2019-10-11 04:19:07 +02:00
Daniel Hahler
2a2fe7d3db
Improve ExceptionInfo.__repr__
2019-10-09 19:27:46 +02:00
Daniel Hahler
21c038f304
Merge master into features
2019-10-08 18:57:15 +02:00
Daniel Hahler
946434c610
Improve full diff output for lists
...
Massage text input for difflib when comparing pformat output of
different line lengths.
Also do not strip ndiff output on the left, which currently already
removes indenting for lines with no differences.
Before:
E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
E Right contains 3 more items, first extra item: ' '
E Full diff:
E - ['version', 'version_info', 'sys.version', 'sys.version_info']
E + ['version',
E + 'version_info',
E + 'sys.version',
E + 'sys.version_info',
E + ' ',
E + 'sys.version',
E + 'sys.version_info']
After:
E AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
E Right contains 3 more items, first extra item: ' '
E Full diff:
E [
E 'version',
E 'version_info',
E 'sys.version',
E 'sys.version_info',
E + ' ',
E + 'sys.version',
E + 'sys.version_info',
E ]
2019-10-08 15:27:51 +02:00
Anthony Sottile
3fada8c8ee
Merge pull request #5925 from asottile/fix_resource_warning_again_5088
...
Fix spurious ResourceWarning stderr in testsuite again
2019-10-07 16:26:38 -07:00
Anthony Sottile
19eb0590f1
Fix spurious ResourceWarning stderr in testsuite again
2019-10-06 19:11:33 -07:00
Bruno Oliveira
5186635387
Introduce no_fnmatch_line/no_re_match_line in pytester ( #5914 )
...
Introduce no_fnmatch_line/no_re_match_line in pytester
2019-10-06 20:27:20 -03:00
Anthony Sottile
eaa05531ed
Add test to ensure _pytest is warning-clean on import
2019-10-06 14:11:08 -07:00
Bruno Oliveira
47c2091ecd
Use new no-match functions to replace previous idiom
2019-10-06 18:05:24 -03:00
Bruno Oliveira
0c18e24433
Introduce no_fnmatch_line/no_re_match_line in pytester
...
The current idiom is to use:
assert re.match(pat, result.stdout.str())
Or
assert line in result.stdout.str()
But this does not really give good results when it fails.
Those new functions produce similar output to ther other match lines functions.
2019-10-06 18:05:24 -03:00
Daniel Hahler
07f20ccab6
Allow for "pdb" module to be rewritten
2019-10-06 23:02:24 +02:00
Anthony Sottile
c58b0fb4ac
Use ATTRS_EQ_FIELD for attrs 19.2 compat
2019-10-05 18:16:35 -07:00
Hynek Schlawack
a79acf279a
Fix warnings with attrs 19.2 and fix object assertions
...
attrs 19.2 deprecated cmp in favor of the dataclass-ish eq/order duo.
This causes deprecation warnings that in turn break some of the cool new deep
object comparisons. Since we at attrs expected this to be a problem, it shipped
with helpers to write backward and forward compatible code.
This PR uses that and avoids changed to minimal versions.
2019-10-01 20:47:59 +02:00
Bruno Oliveira
7bdfba3578
Fix --setup-only and --setup-show for custom pytest items
...
Fix #5884
2019-09-28 11:52:09 -03:00
Anthony Sottile
19c9e53604
Make sure to quote `sys.executable` as we're running a shell
2019-09-23 08:58:56 -07:00
Bruno Oliveira
c28b63135f
Merge master into features ( #5874 )
...
Merge master into features
2019-09-23 12:44:20 -03:00
Tomáš Chvátal
04c01fb606
test_argcomplete do not call python directly #5872
...
Use sys.executable to detect which python we should actually be testing.
2019-09-23 16:38:15 +02:00
Andrzej Klajnert
e2382e96ed
Minor cleanup in tests.
2019-09-19 11:13:22 +02:00
Bruno Oliveira
df46afc96d
Change fixture argument handling tests to unit-tests
2019-09-18 07:50:35 -03:00
Bruno Oliveira
6918d07560
Merge remote-tracking branch 'upstream/features' into aklajnert/1682-dynamic-scope
2019-09-18 07:44:18 -03:00
Daniel Hahler
450409d123
Merge master into features
...
Conflicts:
src/_pytest/reports.py
(via 7259c453d
, moved the type annotation; setting it to `None`
was removed in 3c82b1cb9
already)
2019-09-17 12:46:36 +02:00
Daniel Hahler
702acdba46
Merge pull request #5811 from blueyed/fulltrace-pytest-raises
...
Handle --fulltrace with pytest.raises
2019-09-14 02:09:36 +02:00
Daniel Hahler
f832ac3316
Handle --fulltrace with pytest.raises
...
This changes `_repr_failure_py` to use `tbfilter=False` always.
2019-09-14 01:41:43 +02:00
Bruno Oliveira
b48f51eb03
Use Path() objects to store conftest files
...
Using Path().resolve() is better than py.path.realpath because
it resolves to the correct path/drive in case-insensitive file systems (#5792 ):
>>> from py.path import local
>>> from pathlib import Path
>>>
>>> local('d:\\projects').realpath()
local('d:\\projects')
>>> Path('d:\\projects').resolve()
WindowsPath('D:/projects')
Fix #5819
2019-09-12 08:05:50 -03:00
Bruno Oliveira
cf5b544db3
Revert "Merge pull request #5792 from dynatrace-oss-contrib/bugfix/badcase"
...
This reverts commit 955e542210
, reversing
changes made to 0215bcd84e
.
Will attempt a simpler approach
2019-09-12 08:05:43 -03:00
Hugo
d049b35397
Fix for Python 4: replace unsafe PY3 with PY2
2019-09-05 18:06:47 +03:00
aklajnert
10bf6aac76
Implemented the dynamic scope feature.
2019-08-31 18:12:24 +02:00
Michael Goerz
f8dd6349c1
Fix "lexer" being used when uploading to bpaste.net
...
Closes #5806 .
2019-08-30 15:34:03 -04:00
Bruno Oliveira
bd57307a39
Merge pull request #5768 from robholt/fixture-class-instance
...
Fix self reference in function scoped fixtures
2019-08-30 12:31:16 -03:00
Bruno Oliveira
4e594552eb
Merge pull request #5798 from aklajnert/570-indirect-fixtures
...
Fix the scope behavior with indirect fixtures
2019-08-30 12:29:03 -03:00
Bruno Oliveira
955dc6d18a
Merge remote-tracking branch 'upstream/master' into robholt/fixture-class-instance
2019-08-30 11:21:33 -03:00
Bruno Oliveira
3ddbc7fb2a
Improve CHANGELOG and add some comments
...
Ref: #5768
2019-08-30 11:20:19 -03:00
Bruno Oliveira
35b3b1097f
Improve CHANGELOG and make test easier to understand for #570
2019-08-30 10:54:58 -03:00
Bruno Oliveira
01082fea12
Serialize/deserialize chained exceptions ( #5787 )
...
Serialize/deserialize chained exceptions
2019-08-30 07:29:48 -03:00
Bruno Oliveira
a511b98da9
Serialize/deserialize chained exceptions
...
Fix #5786
2019-08-29 20:23:44 -03:00
Andrzej Klajnert
487659d8b1
Fix the scope behavior with indirect fixtures.
2019-08-29 07:23:08 +02:00
Christian Neumüller
29bb0eda27
Move _uniquepath to pathlib as unique_path.
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2019-08-28 12:29:41 +02:00
Christian Neumüller
1aac64573f
black formatting.
2019-08-27 16:16:45 +02:00
Michael Goerz
d47b9d04d4
Gracefully handle HTTP errors from pastebin
...
We find that the --pastebin option to pytest sometimes fails with "HTTP
Error 400: Bad Request". We're still investigating the exact cause of
these errors, but in the meantime, a failure to upload to the pastebin
service should probably not crash pytest and cause a test failure in the
continuous-integration.
This patch catches exceptions like HTTPError that may be thrown while
trying to communicate with the pastebin service, and reports them as a
"bad response", without crashing with a backtrace or failing the entire
test suite.
2019-08-26 23:50:46 -04:00
Bruno Oliveira
c28e428249
Merge remote-tracking branch 'upstream/master' into mm
2019-08-26 20:00:30 -03:00
Christian Neumüller
505c3340bf
Fix pytest with mixed up filename casing.
2019-08-26 17:18:46 +02:00
Bruno Oliveira
7a69365486
Move TWMock class to a fixture
...
Using a relative import like before was not very nice
2019-08-26 11:32:57 -03:00
Bruno Oliveira
691c706fcc
Add test for #5782
2019-08-24 14:41:06 -03:00
Anthony Sottile
daff9066c0
Merge pull request #5752 from bluetech/typing-py350-fix
...
Fix TypeError when importing pytest on Python 3.5.0 and 3.5.1
2019-08-20 08:04:58 -07:00
Ran Benita
43eab917a1
Fix coverage
2019-08-20 15:41:32 +03:00
Ran Benita
a7c235732a
Pypy doesn't have sys.getrefcount(), so go back to gc
2019-08-20 11:47:22 +03:00
Ran Benita
cec2183aeb
Add workaround for test_raises_cyclic_reference in Python 3.5.{0,1}
2019-08-20 11:19:25 +03:00
Robert Holt
62381125e7
Fix self reference in function scoped fixtures
2019-08-19 15:57:39 -04:00
Daniel Hahler
e5f4c47cd5
test_assertion: minor cleanup
2019-08-17 21:38:52 +02:00
Daniel Hahler
05bfe73cf9
Fix wrong location of assertion error with coverage.py
...
Reverts using-constant part from 39ba99613
.
Fixes https://github.com/pytest-dev/pytest/issues/5754 .
2019-08-17 21:34:13 +02:00
Daniel Hahler
2a6a1ca07d
Inject width via pylib to argparse formatter
...
`argparse.HelpFormatter` looks at `$COLUMNS` only, falling back to a
default of 80.
`py.io.get_terminal_width()` is smarter there, and could even work
better with https://github.com/pytest-dev/py/pull/219 .
This ensures to use a consistent value for formatting the ini values etc.
2019-08-17 16:51:02 +02:00
Bruno Oliveira
8ccc0177c8
Release 5.1.0 ( #5748 )
...
Release 5.1.0
2019-08-15 22:35:59 -03:00
Daniel Hahler
6ead01aacd
testing/python/fixtures.py: use NotImplementedError pattern
2019-08-16 01:14:19 +02:00
Bruno Oliveira
d7f082519a
Merge remote-tracking branch 'upstream/master' into mm
...
Conflicts:
src/_pytest/outcomes.py
2019-08-15 10:03:52 -03:00
Bruno Oliveira
2d613a03b3
Async result warn ( #5742 )
...
Async result warn
2019-08-15 09:47:56 -03:00
Bruno Oliveira
28c6c5bb71
check that tests that are partial staticmethods are supported ( #5701 )
...
check that tests that are partial staticmethods are supported
2019-08-15 09:12:01 -03:00
Thomas Grainger
6b9d729ed3
also warn on awaitable or async iterable test results
2019-08-15 12:30:44 +01:00
Bruno Oliveira
0ba774a7c3
warn for async generator functions ( #5734 )
...
warn for async generator functions
2019-08-15 08:17:12 -03:00
Thomas Grainger
137255816e
Fix collection of staticmethods defined with functools.partial
...
Related to #5701
2019-08-15 08:04:05 -03:00
Thomas Grainger
2f1b192fe6
Issue a warning for async gen functions
...
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-08-15 07:54:10 -03:00
dmitry.dygalo
7183335e62
Capture warnings during ``pytest_configure``
...
Fix #5115
2019-08-15 07:50:27 -03:00
Daniel Hahler
cb481a354a
assertrepr_compare: prefer same maxsize
...
Previously it would say:
> assert '123456789012...901234567890A' == '1234567890123...901234567890B'"
This makes it look like the "3" might be different already.
This is clearer, and it is OK to have potentially one less char in the
right one:
> assert '123456789012...901234567890A' == '123456789012...901234567890B'"
2019-08-12 03:41:14 +02:00
Bruno Oliveira
300f78556f
Show session duration in human-readable format ( #5721 )
...
Show session duration in human-readable format
2019-08-10 23:05:34 -03:00
Daniel Hahler
0db9dade65
test_non_ascii_paste_text: mock call to urlopen
...
Likely to fix flaky coverage due to requests failing sometimes.
Ref: f7e81dab9a...83a1f4bd66
/changes
2019-08-10 23:30:49 +02:00
Bruno Oliveira
345df99db7
Show session duration in human-readable format
...
Fix #5707
2019-08-10 10:45:53 -03:00
Bruno Oliveira
2f065a555f
Merge remote-tracking branch 'upstream/master' into release-5.1.0
2019-08-09 12:36:19 -03:00
Bruno Oliveira
ba72b480b9
Remove xfail marker from test_runs_twice_xdist
...
Apperently it does not hang, let's see how it fares on CI
2019-08-09 10:55:06 -03:00
Bruno Oliveira
ba76080b59
Validate xunit2 files against the schema
...
Fix #5095
2019-08-09 10:55:06 -03:00
Thomas Grainger
ef0915e1db
fix grammar in test_collect_functools_partial docstr
2019-08-06 15:27:36 +01:00
Daniel Hahler
aa06e6c8f3
Merge master into features
2019-08-05 19:12:32 +02:00
Daniel Hahler
198fcd8a6f
Fix RuntimeError when trying to collect package with "__init__.py" only
...
Fixes https://github.com/pytest-dev/pytest/issues/4344 .
2019-08-05 17:52:21 +02:00
Anthony Sottile
82763a293a
Merge pull request #5684 from nicoddemus/errno-nomore
...
Use OSError subclasses instead of handling errno
2019-08-04 14:50:12 -07:00
Samuel Searles-Bryant
1ce45a6f67
Add hostname and timestamp to JUnit XML testsuite tag
...
Fix #5471
2019-08-03 15:54:39 +01:00
Bruno Oliveira
d3e1907899
Use OSError subclasses instead of handling errno
2019-08-02 14:17:46 -03:00
Daniel Hahler
b5b710b3ae
Merge master into features
...
Several conflicts, mostly due to 2c402f4bd
.
Conflicts:
.pre-commit-config.yaml
src/_pytest/outcomes.py
src/_pytest/python_api.py
tox.ini
2019-08-02 16:52:51 +02:00
Daniel Hahler
9064eea216
Improve rm_rf to handle only known functions
...
Warnings are emitted if we cannot safely remove
paths.
Fix #5626
2019-08-02 08:18:11 -03:00
Anthony Sottile
1076a7e61d
Merge pull request #5680 from ss18/ss18/pr0
...
Fix some typos
2019-08-01 08:18:48 -07:00
Semen Zhydenko
d19fe3c410
didnt -> didn't
2019-08-01 15:10:39 +02:00
Semen Zhydenko
2de145f372
wasnt -> wasn't
2019-08-01 15:10:06 +02:00
Semen Zhydenko
942fd91995
shouldnt -> shouldn't
2019-08-01 15:09:14 +02:00
Kaiqi
aa13c625da
Change the warning message
2019-07-27 21:06:29 +02:00
Miro Hrončok
ab39502c98
In test_xfail_handling, only remove __pycache__ if it exists
...
Previously, the test failed when the directory was not present,
which could have been caused for example by invoking the tests
with PYTHONDONTWRITEBYTECODE=1.
Fixes https://github.com/pytest-dev/pytest/issues/5664
2019-07-26 02:23:14 +02:00
Daniel Hahler
401c3d1109
tests: unittest: fix/harden "test_exit_outcome"
...
Ref: https://github.com/pytest-dev/pytest/pull/5634#pullrequestreview-265565917
2019-07-23 19:35:51 +02:00
Bruno Oliveira
a82dd2f064
Fix linting
2019-07-23 10:55:22 -03:00
Florian Bruhin
8c47db724c
Improve output when parsing an ini configuration fails
2019-07-23 15:27:27 +02:00
Bruno Oliveira
693e9d0733
Merge pull request #5634 from blueyed/fix-unittest-exit
...
unittest: handle outcomes.Exit
2019-07-23 10:08:43 -03:00
Bruno Oliveira
0824789459
Improve test for pytest.exit handling
2019-07-23 08:53:38 -03:00
Bruno Oliveira
ec4ca59bf0
Merge pull request #5631 from RonnyPfannschmidt/fix-5606
...
use identity checks for the mock sentinels
2019-07-23 08:48:58 -03:00
Daniel Hahler
3c7438969a
Replace internal config._origargs with invocation_params.args
...
Added in https://github.com/pytest-dev/pytest/pull/5564 .
2019-07-23 06:46:56 +02:00
Bruno Oliveira
240d314f36
copy test and changelog from #5607 by @niccodemus
2019-07-20 20:21:27 +02:00
Anthony Sottile
27c9d80a7e
Fix ordering of sys modules snapshot
2019-07-20 11:17:30 -07:00
Daniel Hahler
d35d09f82d
unittest: handle outcomes.Exit
...
This is required for pytest to stop when using "quit" in pdb, and should
get honored/handled in general.
2019-07-20 07:11:49 +02:00
Daniel Hahler
63d517645c
doctest: handle BdbQuit
...
Map `BdbQuit` exception to `outcomes.Exit`.
This is necessary since we are not wrapping `pdb.set_trace` there, and
therefore our `do_quit` is not called.
2019-07-19 02:57:25 +02:00
Ran Benita
faf222f8fb
Merge pull request #5593 from bluetech/type-annotations-1
...
Type-annotate pytest.{exit,skip,fail,xfail,importorskip,warns,raises}
2019-07-16 22:38:20 +03:00
Ran Benita
9258fd1296
Merge pull request #5603 from bluetech/saferepr-simplify
...
Simplify SafeRepr a bit
2019-07-16 22:37:02 +03:00
Bruno Oliveira
65c23017c7
Update test_getfuncargnames_patching to work with modern mock
2019-07-15 12:23:59 -03:00
Bruno Oliveira
8a3f40996a
Remove obsolete "importorskip('unittest.mock')" calls
2019-07-15 11:18:05 -03:00
Ran Benita
129600d698
saferepr: Avoid indirect function calls
...
The DRY savings they provide are rather small, while they make it harder
to type-check, and IMO harder to understand.
2019-07-15 17:07:58 +03:00
Bruno Oliveira
499fda2349
Various cleanups in src/_pytest/python.py ( #5599 )
...
Various cleanups in src/_pytest/python.py
2019-07-14 19:00:35 -03:00
Ran Benita
0394ebffee
saferepr: Use an __init__ instead of setting attributes after construction
...
This will be easier to type-check, and also somewhat clearer.
2019-07-14 22:50:14 +03:00
Ran Benita
11f1f79222
Allow creating ExceptionInfo from existing exc_info for better typing
...
This way the ExceptionInfo generic parameter can be inferred from the
passed-in exc_info. See for example the replaced cast().
2019-07-14 14:28:24 +03:00
Ran Benita
866904ab80
Revert "Let context-managers for raises and warns handle unknown keyword arguments"
...
This reverts commit dfe54cd82f
.
The idea in the commit was to simplify the code by removing the check
and instead letting it TypeError which has the same effect.
However this type error is caught by mypy, and rather than ignoring the
error we think it's better and clearer to go back to the previous
explicit check.
2019-07-14 14:28:21 +03:00
Ronny Pfannschmidt
2c071a060e
refactor resolve_arg_value_types
...
* more explicit type checks
* expand from list+tuple to sequence
2019-07-13 08:13:46 +02:00
Bruno Oliveira
0f8b462677
Include <testsuites> root tag in generated XML ( #5550 )
...
Include <testsuites> root tag in generated XML
2019-07-12 14:35:34 -03:00
Bruno Oliveira
24a66db8d3
Remove support code for unittest 2
...
Also moved a pytest_runtest_makereport hook implemented in
nose.py, but nowadays makes more sense to be implemented in
unittest.py
2019-07-11 20:11:06 -03:00
Bruno Oliveira
37c37963c4
Fix rmtree to remove directories with read-only files
...
Fix #5524
2019-07-11 18:24:53 -03:00
Bruno Oliveira
666acc9b7a
doctest: Add +NUMBER option to ignore irrelevant floating-point… ( #5576 )
...
doctest: Add +NUMBER option to ignore irrelevant floating-point differences
2019-07-11 07:25:37 -03:00
David Röthlisberger
a740ef2036
docs: Document doctest +NUMBER limitation with strings
...
Also added an "xfail" testcase for the same.
2019-07-11 10:06:57 +01:00
David Röthlisberger
4c590e002f
Fix test_doctest.test_number_non_matches
...
These doctests were expected to fail, but they were failing because of a
silly bug (I forgot to replace "{expression}" with the actual expression
to be tested), not because of the thing they were meant to be testing.
Then I had to fix one of the testcases because it was actually matching:
>>> 3.0 #doctest: +NUMBER
2.99
The doctest is saying that the actual output should match to 2 decimal
places, i.e. within 0.01 -- which it is, so it passes. I changed the
expected output to 2.98 and now it doesn't match (as we expect).
2019-07-11 09:57:44 +01:00
Bruno Oliveira
2c402f4bd9
[cherry-pick to master] Add rudimentary mypy type checking ( #5583 )
...
[cherry-pick to master] Add rudimentary mypy type checking
2019-07-10 07:52:32 -03:00
Bruno Oliveira
602cd5e21f
Introduce Config.invocation_params ( #5564 )
...
Introduce Config.invocation_params
2019-07-10 07:46:34 -03:00
Bruno Oliveira
57e5bd0664
Improve type-checking in OutcomeException ( #5580 )
...
Improve type-checking in OutcomeException
2019-07-09 19:12:05 -03:00
Bruno Oliveira
31738155b5
Remove deprecated features ( #5529 )
...
Remove deprecated features
2019-07-09 19:04:06 -03:00
Bruno Oliveira
9db1823707
Improve type-checking in OutcomeException
...
Fix #5578
2019-07-09 18:26:57 -03:00
Ran Benita
89dfde9535
Add rudimentary mypy type checking
...
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.
This enables:
- Progressively adding type annotations and enabling more strict
options, which will improve the codebase (IMO).
- Annotating the public API in-line, and eventually exposing it to
library users who use type checkers (with a py.typed file).
Though, none of this is done yet.
Refs https://github.com/pytest-dev/pytest/issues/3342 .
2019-07-09 12:12:07 -07:00
Anthony Sottile
39a43dbae1
Merge pull request #5575 from bluetech/mypy-initial
...
Add rudimentary mypy type checking
2019-07-09 08:05:14 -07:00
Ran Benita
c1167ac552
Add rudimentary mypy type checking
...
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.
This enables:
- Progressively adding type annotations and enabling more strict
options, which will improve the codebase (IMO).
- Annotating the public API in-line, and eventually exposing it to
library users who use type checkers (with a py.typed file).
Though, none of this is done yet.
Refs https://github.com/pytest-dev/pytest/issues/3342 .
2019-07-09 10:49:17 +03:00
David Röthlisberger
aaa7e837cc
doctest: Add +NUMBER option to ignore irrelevant floating-point differences
...
When enabled, floating-point numbers only need to match as far as the
precision you have written in the expected doctest output. This avoids
false positives caused by limited floating-point precision, like this:
Expected:
0.233
Got:
0.23300000000000001
This is inspired by Sébastien Boisgérault's [numtest] but the
implementation is a bit different:
* This implementation edits the literals that are in the "got"
string (the actual output from the expression being tested), and then
proceeds to compare the strings literally. This is similar to pytest's
existing ALLOW_UNICODE and ALLOW_BYTES implementation.
* This implementation only compares floats against floats, not ints
against floats. That is, the following doctest will fail with pytest
whereas it would pass with numtest:
>>> math.py # doctest: +NUMBER
3
This behaviour should be less surprising (less false negatives) when
you enable NUMBER globally in pytest.ini.
Advantages of this implementation compared to numtest:
* Doesn't require `import numtest` at the top level of the file.
* Works with pytest (if you try to use pytest & numtest together, pytest
raises "TypeError: unbound method check_output() must be called with
NumTestOutputChecker instance as first argument (got
LiteralsOutputChecker instance instead)").
* Works with Python 3.
[numtest]: https://github.com/boisgera/numtest
2019-07-08 17:07:58 +01:00
Bruno Oliveira
4cda7093f6
Add note about PYTEST_ADDOPTS
2019-07-06 17:27:54 -03:00
Bruno Oliveira
6a9bf2852a
Apply review suggestions: use a simple struct for invocation params
2019-07-06 12:22:19 -03:00
Bruno Oliveira
3e669a262a
Introduce Config.invocation_args and Config.invocation_plugins
...
These attributes can be used to access the unchanged arguments passed
to pytest.main().
The intention is to use these attributes to initialize workers in
the same manner as the master node is initialized in pytest-xdist.
2019-07-05 19:45:23 -03:00
Bruno Oliveira
f1b8431d99
Sort parametrize params to test_external_plugins_integrated
...
This might cause problems during collection with pytest-xdist; we
didn't see any so far mostly by luck I think.
Shame on me for letting that slip in.
2019-07-05 19:05:55 -03:00
Bruno Oliveira
a43ba78d3b
Include <testsuites> root tag in generated XML
...
Fix #5477
2019-07-05 11:29:35 -03:00
Bruno Oliveira
d7588b8d40
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
2019-07-05 08:14:18 -03:00
Bruno Oliveira
8651d880a0
Handle xfail(strict=True) properly in --step-wise mode
...
Fix #5547
2019-07-04 20:28:37 -03:00
Miro Hrončok
c54cbd63c8
Replace importlib_metadata with importlib.metadata on Python 3.8+
...
Fixes https://github.com/pytest-dev/pytest/issues/5537
2019-07-04 15:00:10 +02:00
Anthony Sottile
caa08ebd45
Improve quoting in raises match failure message
2019-07-04 05:55:26 -07:00
Bruno Oliveira
0ed7aa2db6
Make 'request' a reserved name for fixtures
2019-06-30 13:31:39 -03:00
Bruno Oliveira
c470ade0a5
Remove 'RemovedInPytest4Warning'
2019-06-30 13:31:39 -03:00
Bruno Oliveira
aa1955de72
Remove 'tmpdir_factory.ensuretemp'
2019-06-30 13:18:07 -03:00
Bruno Oliveira
7e58defc15
Remove 'pytest.config'
2019-06-30 13:18:07 -03:00
Bruno Oliveira
f2b7809d5d
Move setup.cfg error message and tests to an appropriate location
...
Those are not really deprecated anymore and are part of the normal
code for config
2019-06-30 13:18:07 -03:00
Bruno Oliveira
647d89c444
Move code about 'pytest_plugins' error to a more appropriate place
...
It is no longer deprecated, but part of the normal code for 'config'
2019-06-30 13:18:07 -03:00
Bruno Oliveira
683b2632b4
Remove explicit kwargs handling from raises, warns and ParameterSet.param
2019-06-30 13:18:06 -03:00
Bruno Oliveira
13f7f27fd2
Remove 'message' parameter from pytest.raises
2019-06-30 13:18:06 -03:00
Bruno Oliveira
279733a30b
Remove support for 'code as string' from pytest.raises and pytest.warns
2019-06-30 11:40:24 -03:00
Bruno Oliveira
be91c4d932
Remove Request.getfuncargvalue
2019-06-30 11:02:46 -03:00
Anthony Sottile
7ee244476a
Remove astor and reproduce the original assertion expression
2019-06-28 13:38:52 -07:00
Anthony Sottile
4e723d6750
Fix crash when discovery fails while using `-p no:terminal`
2019-06-27 10:24:29 -07:00
Anthony Sottile
3e0e31a364
Don't crash with --pyargs and a filename that looks like a module
2019-06-27 08:32:32 -07:00
Bruno Oliveira
37fb50a3ed
Features assertion pass hook ( #3479 )
...
Features assertion pass hook
2019-06-26 21:14:19 -03:00
Bruno Oliveira
790806e865
Merge pull request #5494 from Zac-HD/funcargnames-to-fixturenames
...
Deprecate funcargnames alias for fixturenames
2019-06-26 21:13:59 -03:00
Bruno Oliveira
2ea22218ff
Cover assertions with messages when enable_assertion_pass_hook is enabled
2019-06-26 20:46:31 -03:00
Bruno Oliveira
eb90f3d1c8
Fix default value of 'enable_assertion_pass_hook'
2019-06-26 17:54:24 -03:00
Victor Maryama
6f851e6cbb
Merge remote-tracking branch 'upstream/master' into features-assertion-pass-hook-master
...
# Conflicts:
# src/_pytest/assertion/rewrite.py
2019-06-26 18:12:56 +02:00
Victor Maryama
f755ff6af1
Black formatting.
2019-06-26 18:10:16 +02:00
Victor Maryama
d638da5821
Using ini-file option instead of cmd option.
2019-06-26 18:10:16 +02:00
Anthony Sottile
3f3f3e7a29
Merge pull request #5495 from nicoddemus/blueyed/cmp-bytes
...
Improve comparison of byte strings (supersedes #5267 )
2019-06-25 19:16:24 -07:00
Bruno Oliveira
3f2344e8f7
Show bytes ascii representation instead of numeric value
2019-06-25 20:40:25 -03:00
Daniel Hahler
8c7eb82363
Fix/improve comparison of byte strings
...
Fixes https://github.com/pytest-dev/pytest/issues/5260 .
2019-06-25 20:15:45 -03:00
Zac Hatfield-Dodds
ed85c83154
Deprecate funcargnames alias
2019-06-26 08:53:17 +10:00
Anthony Sottile
bd647fdd8b
Revert allow_abbrev=False in helper scripts
2019-06-25 14:50:07 -07:00
Victor Maryama
4db5488ed8
Now dependent on command line option.
2019-06-25 19:49:05 +02:00
Victor Maryama
cfbfa53f2b
Using pytester subprocess to avoid keeping references in the HookRecorder.
2019-06-25 17:46:56 +02:00
Victor Maryama
db50a975fd
Reverted leak fixture test.
2019-06-25 17:23:14 +02:00
Bruno Oliveira
019455298b
Merge remote-tracking branch 'upstream/features' into merge-features-into-master
2019-06-25 12:07:54 -03:00
Bruno Oliveira
64a6365227
Include pytest version in the cached pyc tags ( #5484 )
...
Include pytest version in the cached pyc tags
2019-06-25 12:07:01 -03:00
Victor Maryama
81e3f3cf95
Black formatting
2019-06-25 10:41:11 +02:00
Zac Hatfield-Dodds
d72fb73fa0
Do not allow abbreviated arguments
2019-06-25 13:51:33 +10:00
Bruno Oliveira
37fce6c6e5
Pickup addition positional args passed to _parse_parametrize_ar… ( #5483 )
...
Pickup addition positional args passed to _parse_parametrize_args
2019-06-24 22:05:19 -03:00
Kevin J. Foley
95714436a1
Pickup additional positional args passed to _parse_parametrize_args
2019-06-24 20:43:52 -04:00
Bruno Oliveira
f43fb13179
Include pytest version in the cached pyc tags
...
Fix #1671
2019-06-24 20:37:07 -03:00
Bruno Oliveira
3f5b078462
Merge pull request #5441 from nicoddemus/faulthandler-5440
...
Integrate pytest-faulthandler into the core
2019-06-24 20:01:15 -03:00
Anthony Sottile
4cd08f9b52
Switch from deprecated imp to importlib
2019-06-24 09:48:38 -07:00
Victor Maryama
9a89783fbb
Assertion passed hook
2019-06-24 16:09:39 +02:00
Bruno Oliveira
3ce31b6370
Change pytest-faulthandler for simplification
...
* The --no-faulthandler option is not necessary given that we can use
`-p no:faulthandler`.
* The `--faulthandler-timeout` command-line option has become an ini
option, for the reasons described in
https://github.com/pytest-dev/pytest-faulthandler/issues/34 and
users can still set it from the command-line.
Fix pytest-dev/pytest-faulthandler#34
2019-06-22 19:22:43 -03:00
Bruno Oliveira
a37b902afe
Integrate pytest-faulthandler into the core
...
* Add pytest-faulthandler files unchanged
* Adapt imports and tests
* Add code to skip registration of the external `pytest_faulthandler`
to avoid conflicts
Fix #5440
2019-06-21 21:02:24 -03:00
Bruno Oliveira
b38a4e8e11
Fix stepwise crash when first collected module fails ( #5446 )
...
Fix stepwise crash when first collected module fails
2019-06-16 10:43:18 -03:00
Bruno Oliveira
689ce112e7
Small cleanups on _pytest.compat ( #5451 )
...
Small cleanups on _pytest.compat
2019-06-16 10:42:07 -03:00
Bruno Oliveira
87fc5a5455
Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types' ( #5452 )
...
Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types'
2019-06-16 10:41:40 -03:00
Bruno Oliveira
bbfc8d1501
conversion of exit codes to enum + exposure ( #5420 )
...
conversion of exit codes to enum + exposure
2019-06-16 10:41:18 -03:00
Daniel Hahler
cf27af734e
Merge pull request #5404 from Zac-HD/helpful-mock-unwrapper
...
Emit warning for broken object
2019-06-15 18:54:03 +02:00
Bruno Oliveira
43e8576ca3
Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types'
...
When we configure warnings as errors, users see error messages like this:
def test():
> warnings.warn(pytest.PytestWarning("some warning"))
E _pytest.warning_types.PytestWarning: some warning
This is a problem because suggests the user should use `_pytest.warning_types.PytestWarning` to configure
their warning filters, which is not nice.
This commit changes the message to:
def test():
> warnings.warn(pytest.PytestWarning("some warning"))
E pytest.PytestWarning: some warning
2019-06-15 11:48:34 -03:00
Bruno Oliveira
177af032d2
Remove unused/unneeded code
2019-06-15 10:45:16 -03:00
Ronny Pfannschmidt
2b92fee1c3
initial conversion of exit codes to enum
2019-06-15 06:48:00 +02:00
Bruno Oliveira
c94e9b6145
Fix test docstring
2019-06-13 23:10:13 -03:00
Bruno Oliveira
bc345ac980
Remove handling of collection errors by --sw
...
Since then pytest itself adopted the behavior of interrupting
the test session on collection errors, so --sw no longer needs
to handle this.
The --sw behavior seems have been implemented when pytest
would continue execution even if there were collection errors.
2019-06-13 17:19:36 -03:00