Commit Graph

1223 Commits

Author SHA1 Message Date
Ronny Pfannschmidt 898028cb22 remove unused _get_xunit_setup_teardown 2019-07-12 17:45:23 +02:00
Ronny Pfannschmidt 4480d3e518 generate_tests: always use call_extra
- its a noop addition in the methods is empty list
2019-07-12 17:44:17 +02:00
Ronny Pfannschmidt 13d750db20 simplify the expression which transfers mark names to keywords 2019-07-12 06:16:06 +02:00
Ronny Pfannschmidt e98627223f remove the noop init of PyobjMixin 2019-07-12 06:14:36 +02:00
Albert Tugushev c89e379f49 Fix typos 2019-07-12 02:35:44 +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
Ran Benita f7747f5dd6 Remove references to old-style classes in a couple error messages
These don't exist in Python 3.
2019-07-10 20:25:45 +03: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 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 a43ba78d3b Include <testsuites> root tag in generated XML
Fix #5477
2019-07-05 11:29:35 -03:00
Bruno Oliveira 0371a3023a Fix comment in stepwise (follow up to #5555) [skip ci] 2019-07-05 09:57:10 -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
Bruno Oliveira 1db132290f Apply workaround for multiple short options for Python <= 3.8
Hopefully by Python 3.9 this will be fixed upstream, if not we will
need to bump the version again.

Fix #5523
2019-07-04 14:59:40 +02:00
Anthony Sottile caa08ebd45 Improve quoting in raises match failure message 2019-07-04 05:55:26 -07:00
Bruno Oliveira dfe54cd82f Let context-managers for raises and warns handle unknown keyword arguments
As suggested during review
2019-07-03 13:57:28 -03:00
Bruno Oliveira 0ed7aa2db6 Make 'request' a reserved name for fixtures 2019-06-30 13:31:39 -03:00
Bruno Oliveira 85cc12e328 Move FIXTURE_FUNCTION_CALL constant to the point of error
This is no longer a deprecation so it makes sense to move it
to the place where it is needed instead of leaving it in deprecated.py
2019-06-30 13:31:39 -03:00
Bruno Oliveira c470ade0a5 Remove 'RemovedInPytest4Warning' 2019-06-30 13:31:39 -03:00
Bruno Oliveira 3a17c1b30b Remove 'pytest_logwarning' hook 2019-06-30 13:18:07 -03:00
Bruno Oliveira 7b35405033 Remove YIELD_TESTS from deprecated module as it is now an error 2019-06-30 13:18:07 -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
Bruno Oliveira 9021194efd Apply workaround for multiple short options for Python <= 3.8
Hopefully by Python 3.9 this will be fixed upstream, if not we will
need to bump the version again.

Fix #5523
2019-06-29 11:15:28 -03:00
Bruno Oliveira e6ffa78e59
Refactoring doctests (#5518)
Refactoring doctests
2019-06-28 19:15:02 -03:00
Anthony Sottile 7ee244476a Remove astor and reproduce the original assertion expression 2019-06-28 13:38:52 -07:00
AmirElkess bf39e89946 Refactoring doctests 2019-06-28 21:16:17 +02: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 1be49e713a Remove py<35 compatibility code from rewrite.py 2019-06-26 21:44:10 -03: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 629eb3ec6a Move formatting variables under the "has impls" if
Small optimization, move the generation of the intermediate
formatting variables inside the 'if _check_if_assertion_pass_impl():'
block.
2019-06-26 19:26:12 -03:00
Bruno Oliveira 3afee36ebb Improve docs and reference 2019-06-26 19:15:00 -03:00
Bruno Oliveira fcbe66feba Restore proper handling of '%' in assertion messages 2019-06-26 18:51:27 -03:00
Bruno Oliveira eb90f3d1c8 Fix default value of 'enable_assertion_pass_hook' 2019-06-26 17:54:24 -03:00
Victor Maryama 6854ff2acc Fixed import order pep8. 2019-06-26 19:05:17 +02:00
Victor Maryama 53234bf613 Added config back to AssertionWriter and fixed typo in check_if_assertion_pass_impl function call. 2019-06-26 19:00:31 +02: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 9a34d88c8d Explanation variables only defined if failed or passed with plugins implementing the hook. 2019-06-26 18:10:16 +02:00
Victor Maryama d91a5d3cd7 Further reverting changes. 2019-06-26 18:10:16 +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
Victor Maryama 0fb52416b1 Reverted changes. 2019-06-26 18:10:15 +02:00
Bruno Oliveira 6a2d844c5d
Fix typo replace `circuting` with `circuiting`. (#5497)
Fix typo replace `circuting` with `circuiting`.
2019-06-26 11:09:22 -03:00
Anthony Sottile 6cf8e71dca
Merge pull request #5496 from pytest-dev/stray_comment
Delete stray comment
2019-06-26 05:59:38 -07:00
Tim Gates fdb6e35b1b
Fix typo replace `circuting` with `circuiting`. 2019-06-26 20:23:35 +10:00
Victor Maryama 7efdd5063b
Update src/_pytest/assertion/rewrite.py
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-06-26 10:50:27 +02:00
Anthony Sottile bfba33ec9e Delete stray comment 2019-06-25 20:24:13 -07: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 aaf40314d1
Do not attempt to rewrite non-source files (#5490)
Do not attempt to rewrite non-source files
2019-06-25 20:43:23 -03: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
Victor Maryama 80ac910a24 Added msg to docstring for cleaning pyc. 2019-06-25 19:49:57 +02:00
Victor Maryama 4db5488ed8 Now dependent on command line option. 2019-06-25 19:49:05 +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
Anthony Sottile b991810f32 Do not attempt to rewrite non-source files 2019-06-25 08:00:20 -07:00
Victor Maryama 2280f28596 Black formatting. 2019-06-25 10:36:01 +02:00
Victor Maryama f8c9a7b86d Formatting and removed py2 support. 2019-06-25 10:35:42 +02:00
Victor Maryama 98b212cbfb Added "experimental" note. 2019-06-25 10:35:09 +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
Bruno Oliveira 63c4802be0
minor: clarify help with reportchars (#5475)
minor: clarify help with reportchars
2019-06-24 19:59:15 -03:00
Anthony Sottile 380ca8f880 Use new raise syntax in one case 2019-06-24 11:24:03 -07:00
Anthony Sottile 4cd08f9b52 Switch from deprecated imp to importlib 2019-06-24 09:48:38 -07:00
Victor Maryama 52e695b329 Removed debug code. 2019-06-24 17:47:48 +02:00
Victor Maryama 9a89783fbb Assertion passed hook 2019-06-24 16:09:39 +02:00
Daniel Hahler 01a094cc43 minor: clarify help with reportchars
`-ra` / `-rA` will include "w" also.  This does not explicitly mention
it (allowing for change the behavior), but makes it a) clearer that "w"
is a recognized reportchar, and b) less confusing that `-ra
--disable-warnings` still displays them.
2019-06-24 06:07:52 +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
Ronny Pfannschmidt 0627d92df2 fix typos in the resolution of #5125 2019-06-17 20:35:23 +02: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
Bruno Oliveira ab6ed381ac Improve ExitCode docstring 2019-06-15 20:53:46 -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