If you are not in a `poetry shell`, the venv detection does not work. This patch
prepends `poetry run` before `poetry env info -p`, which makes venv detection
work both inside and outside the poetry subshell.
If an error occurs outside of the test file, there is no frame to match
an error to. This can happen for example when required arguments are not
passed to the test.
This means that `neotest.run.run` when the cursor is on a test's
decorators will run the decorated test (instead of running the previous
test in the file, the current behaviour).
Fixes: #31
Given a test like:
```py
@pytest.mark.parametrize("a,b", [("b", "c"), ("c", "d")])
def test_a(a, b):
assert False
```
This modifies the diagnostic message from:
```
neotest: assert False
neotest: assert False
```
to:
```
neotest: [b-c] assert False
neotest: [c-d] assert False
```
This is the same internal value which `pytest` uses for parametrized
instances in its output, so it should be fully consistent.
Without this, the diagnostic messages aren't very useful for
parametrized tests: you can't identify _which_ of the multiple test
which execute the given line are failing.
Fixes: #30
* include type of unhandled pytest exc_repr in error message
This makes triage of such issues a little simpler.
* pytest: expect the more general ExceptionRepr class
This is the (abstract) supertype of the currently-used
ExceptionChainRepr, and defines all of the attributes currently used by
the code.
(This changes results in sensible output for `ReprExceptionInfo`
instances, which is what my pytest invocations were generating.)
* pytest: use pytest_runtest_makereport for consistent exception handling
The `report` passed to `pytest_runtest_logreport` has a different
internal exception representation depending on the `--tb` option with
which `pytest` is configured: some of these representations do not
include the traceback frames to allow us to calculate line numbers.
`pytest_runtest_makereport`, however, has access to the original
`ExceptionInfo` object when an exception is raised: this commit switches
to using a `pytest_runtest_makereport` hookwrapper, so we can access the
pytest-generated report as before, but get exception handling
independent of `--tb` setting.
Fixes: #28
When running neotest with the DAP strategy (nvim-dap), e.g.
require("neotest").run.run({ strategy = "dap" })
we make the pydebug debugger stop at "exception breakpoints"
where the exception is thrown out of a pytest method.
This will be very helpful for users to debug failing unit tests.
Having `NeotestResultCollector` (a pytest plugin) as a inner local
class would make the code a bit difficult to read due to quite much
indentation. This commit does refactoring on NeotestResultCollector
to make it a module-level class with a reference to NeotestAdapter.
This refactoring would make easier adding more pytest plugins
(e.g., debugger integration) in the future.
There should be no changes in behaviors.