-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: catch BaseException from instrumented code
Catch all exceptions thrown from instrumented code by catching BaseException, rather than Exception. This ensures that the appropriate event gets added to the recording. This problem was originally found when running instrumented tests in pytest-dev/pytest, so the changes include a test copied from there. pytest's OutcomeException (and its subclasses, like Skipped) inherits from BaseException. pytest raises an OutcomeException internally to indicate how a test case finished.
- Loading branch information
1 parent
e241d93
commit 910ea9b
Showing
8 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Simple | ||
packages: | ||
- path: simple | ||
- path: _pytest | ||
exclude: | ||
# - _py.path | ||
- compat.safe_getattr | ||
- config.PytestPluginManager | ||
- fixtures.getfixturemarker | ||
- config.argparsing | ||
- config.Config.rootpath | ||
- path: pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import appmap |
16 changes: 16 additions & 0 deletions
16
_appmap/test/data/pytest-instrumented/test_instrumented.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
# Copied from pytest-dev/pytest. When recorded, this test case will raise an OutcomeException | ||
# (specifically _pytest.outcomes.Skipped). | ||
def test_skipped(pytester): | ||
pytester.makeconftest( | ||
""" | ||
import pytest | ||
def pytest_ignore_collect(): | ||
pytest.skip("intentional") | ||
""" | ||
) | ||
pytester.makepyfile("def test_hello(): pass") | ||
result = pytester.runpytest_inprocess() | ||
assert result.ret == pytest.ExitCode.NO_TESTS_COLLECTED | ||
result.stdout.fnmatch_lines(["*1 skipped*"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters