Commit Graph

12839 Commits

Author SHA1 Message Date
Gleb Nikonorov 04d052e306 fix mypy issue by using typing Match instead of re.Match 2020-07-02 15:32:23 -04:00
Ran Benita 74f20f9fba
Merge pull request #7434 from bluetech/distinct_log_handlers-rebased
logging: use unique handlers for caplog and reports
2020-07-01 20:54:55 +03:00
Ran Benita c8cfff6de5 testing: fix flaky tests due to "coroutine never awaited" warnings
They sometime leak into other test's warnings and cause them to fail.
2020-07-01 20:29:04 +03:00
Ran Benita f5c69f3eb2 code/source: inline getsource()
The recursive way in which Source and getsource interact is a bit
confusing, just inline it.
2020-07-01 20:20:13 +03:00
Ran Benita ef39115001 code/source: remove compiling functions
A lot of complex code that isn't used anymore outside of tests after
the previous commit.
2020-07-01 20:20:12 +03:00
Ran Benita 9640c9c9eb skipping: use plain compile() instead of _pytest._code.compile()
eval() is used for evaluating string conditions in skipif/xfail e.g.

    @pytest.mark.skipif("1 == 0")

This is the only code that uses `_pytest._code.compile()`, so removing
its last use enables us to remove it entirely.

In this case it doesn't add much. Plain compile() gives a good enough
error message.

For regular exceptions, the message is the same.

For SyntaxError exceptions, e.g. "1 ==", the previous code adds a little
bit of useful context:

```
invalid syntax (skipping.py:108>, line 1)

The above exception was the direct cause of the following exception:
1 ==
     ^
(code was compiled probably from here: <0-codegen /pytest/src/_pytest/skipping.py:108>) (line 1)

During handling of the above exception, another exception occurred:
Error evaluating 'skipif' condition
    1 ==
         ^
SyntaxError: invalid syntax
```

The new code loses it:

```
unexpected EOF while parsing (<skipif condition>, line 1)

During handling of the above exception, another exception occurred:
Error evaluating 'skipif' condition
    1 ==
        ^
SyntaxError: invalid syntax
```

Since the old message is a minor improvement to an unlikely error
condition in a deprecated feature, I think it is not worth all the code
that it requires.
2020-07-01 20:20:12 +03:00
Ran Benita 4a27d7d973 code/source: remove unused method Source.putaround() 2020-07-01 20:20:11 +03:00
Ran Benita a7303b52db code/source: remove unused method Source.isparseable() 2020-07-01 20:20:11 +03:00
Ran Benita a127a22d13 code/source: remove support for comparing Source with str
Cross-type comparisons like this are a bad idea. This isn't used.
2020-07-01 20:20:10 +03:00
Ran Benita 2b99bfbc60 code/source: remove support for passing multiple parts to Source
It isn't used, so keep it simple.
2020-07-01 20:20:09 +03:00
Ran Benita c83e16ab2e code/source: remove unneeded assert
inspect.getsource() definitely returns str.
2020-07-01 20:20:09 +03:00
Ran Benita c6083ab970 code/source: remove old IndentationError workaround in getsource()
This has been there since as far as the git history goes (2007), is not
covered by any test, and says "Buggy python version consider upgrading".
Hopefully everyone have upgraded...
2020-07-01 20:20:08 +03:00
Ran Benita 4108174777 code/source: remove Source(deindent: bool) parameter
Not used, except in tests.
2020-07-01 20:20:07 +03:00
Ran Benita 2fe178488a code/source: expose deindent kwarg in signature
Probably was done to avoid the shadowing issue, but work around it
instead.
2020-07-01 20:20:06 +03:00
Ran Benita 7b1ba7c0db pytester: slightly clean up LsofFdLeakChecker 2020-07-01 19:39:48 +03:00
Ruaridh Williamson 304f2916fc logging: use unique handlers for caplog and reports
Setting log_level via the CLI or .ini will control the log level of the
report that is dumped upon failure of a test.

If caplog modified the log level during the execution of that test, it
should not impact the level that is displayed upon failure in the
"captured log report" section.

[
ran:
- rebased
- reused handler
- changed store keys also to "caplog_handler_*"
- added changelog
all bugs are mine :)
]
2020-07-01 19:30:03 +03:00
Ran Benita ae83dbd4cf python: remove ancient Function.repr_failure(outerr) parameter
This has been asserted like this since 04e9197fd6
(i.e. 11 years, pytest 1.0), seems safe to simply remove at this point.
2020-06-30 13:14:03 +03:00
Ran Benita 40c355f8c3 python: pytest_pycollect_makeitem doesn't need to be a hookwrapper
A trylast is more appropriate for this usecase.

hookwrappers are more complicated and more expensive than regular
hookimpls, so better avoided.
2020-06-30 13:14:03 +03:00
Ran Benita e492b1d567 python: don't pass entire Item for generating ID
Just the nodeid is enough for the error messages.
This removes an import cycle.
2020-06-30 13:13:45 +03:00
Ran Benita e6e300e729
Merge pull request #7396 from gnikonorov/issue_7295
Refactor src/_pytest/config/__init__.py to use the warnings module instead of stderr for warnings
2020-06-28 18:02:07 +03:00
Gleb Nikonorov 49ec2aed0f change stacklevel in warnings from 2 to 3 2020-06-28 10:48:33 -04:00
Ran Benita 992a7a8d38
Merge pull request #7397 from lgeiger/reduce-ihook-calls
Reduce calls to item.ihook
2020-06-28 15:01:43 +03:00
Gleb Nikonorov c39655725a change if else structure of _warn_bout_missing_assertion 2020-06-27 19:49:19 -04:00
Gleb Nikonorov 72a39117a8 Merge remote-tracking branch 'origin' into issue_7295 2020-06-27 19:43:03 -04:00
Bruno Oliveira 289197ff22 Remove package scope experimental status
Close #7389
2020-06-27 11:16:50 -03:00
Ran Benita 7450b6dd95
Merge pull request #7418 from bluetech/typing-3
More typing work
2020-06-27 10:54:29 +03:00
Anthony Sottile 61014c5f94
Merge pull request #6934 from gdhameeja/Fix-6906
Fix-6906: Added code-highlight option to disable highlighting optionally
2020-06-26 13:41:40 -07:00
gdhameeja 03230b4002 Fix-6906: Added code-highlight option to disable highlighting optionally
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-26 13:24:56 -07:00
Bruno Oliveira d9546ff18f
Merge pull request #7421 from The-Compiler/webinar
Add webinar to open trainings
2020-06-26 12:30:14 -03:00
Florian Bruhin 103bfd20d4 Add webinar 2020-06-26 17:08:14 +02:00
Ran Benita 1ae4182e18
testing: fix flaky tests on pypy3 due to resource warnings in stderr (#7405) 2020-06-26 09:50:19 -03:00
Lukas Geiger 97d2c711e6 Reduce calls of Node.ihook 2020-06-26 14:46:37 +02:00
Bruno Oliveira e377c88495
Merge pull request #7419 from The-Compiler/workshoptage 2020-06-25 14:52:01 -03:00
Florian Bruhin ba50ef33d3 Add open training at Workshoptage 2020 2020-06-25 17:32:34 +02:00
Ran Benita f382a6bb20 hookspec: remove unused hookspec pytest_doctest_prepare_content()
It's been unused for 10 years at lest from bb50ec89a9.
2020-06-25 17:44:56 +03:00
Ran Benita 256a5d8b14 hookspec: improve typing of some remaining hooks 2020-06-25 17:33:21 +03:00
Ran Benita 97a11726e2 freeze_support: type annotate 2020-06-25 15:28:34 +03:00
Ran Benita 8f8f472379 python_api: type annotate some parts of pytest.approx() 2020-06-25 15:15:24 +03:00
Ran Benita 142d8963e6 recwarn: type annotate pytest.deprecated_call
Also improve its documentation.
2020-06-25 14:40:26 +03:00
Ran Benita 653c83e127 recwarn: type annotate recwarn fixture 2020-06-25 14:30:42 +03:00
Ran Benita 4d813fdf5e recwarn: improve return type annotation of non-contextmanager pytest.warns
It returns the return value of the function.
2020-06-25 14:30:42 +03:00
Ran Benita f00bec2a12 Replace yield_fixture -> fixture in internal code
`yield_fixture` is a deprecated alias to `fixture`.
2020-06-25 14:05:46 +03:00
Ran Benita d69e9e60d6
Merge pull request #7411 from bluetech/contributing-changelog
CONTRIBUTING: sync changelog types
2020-06-24 16:33:41 +03:00
Ran Benita 474973afa4 CONTRIBUTING: sync changelog types
The got out of date with the actual ones we use.
2020-06-24 16:11:27 +03:00
Ronny Pfannschmidt 37929030c9
Merge pull request #7406 from ffe4/patch-1
Fix typo in examples/markers.rst
2020-06-24 08:02:21 +02:00
Gleb Nikonorov 0dd77b3e39 Merge remote-tracking branch 'origin/master' into issue_7295 2020-06-23 23:21:36 -04:00
Daniel 6cbbd2d90b
Fix typo in examples/markers.rst 2020-06-23 22:38:11 +02:00
David Diaz Barquero 617bf8be5b
Add details to error message for junit (#7390)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-23 13:03:46 -03:00
Ran Benita 3624acb665
Merge pull request #7401 from bluetech/typing-config
config: improve typing
2020-06-23 18:58:21 +03:00
Ran Benita c6f4c2e5c6
Merge pull request #7402 from bluetech/fix-nodes-keywords-typo
nodes: fix string possibly stored in Node.keywords instead of MarkDecorator
2020-06-23 18:57:25 +03:00