Skip to content

Conversation

@bluetech
Copy link
Member

@bluetech bluetech commented Sep 29, 2020

Fixes #7814.

Regressed in 6.1.0 in 62e249a.

The x is an str but is expected to be a pathlib.Path. Not caught by mypy because config.getini() returns Any.

Fix by just removing the bestrelpath call:

  • testpaths are always relative to the rootdir, it thus would be very unusual to specify an absolute path there.

  • The code was wrong even before the regression: py.path.local's bestrelpath function expects a py.path.local, not an str. But it had some weird try ... except AttributeError fallback which just returns the argument, i.e. it was a no-op. So there is no behavior change.

  • It seems reasonable to me to just print the full path if that's what the ini specifies.

The two other commits are related improvements.

@bluetech bluetech added the needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch label Sep 29, 2020
@bluetech
Copy link
Member Author

Note: I only intend to backport the "terminal: fix crash in header reporting when absolute testpaths is used" commit.

@bluetech bluetech force-pushed the fix-testpaths-bestrelpath2 branch from ab73086 to bd47d3f Compare September 29, 2020 11:38
Regressed in 6.1.0 in 62e249a.
The `x` is an `str` but is expected to be a `pathlib.Path`. Not caught
by mypy because `config.getini()` returns `Any`.

Fix by just removing the `bestrelpath` call:

- testpaths are always relative to the rootdir, it thus would be very
  unusual to specify an absolute path there.

- The code was wrong even before the regression: `py.path.local`'s
  `bestrelpath` function expects a `py.path.local`, not an `str`. But it
  had some weird `try ... except AttributeError` fallback which just
  returns the argument, i.e. it was a no-op. So there is no behavior
  change.

- It seems reasonable to me to just print the full path if that's what
  the ini specifies.
Make it match better the condition on whether testpaths is used (found
in config/__init__.py).
@bluetech bluetech force-pushed the fix-testpaths-bestrelpath2 branch from bd47d3f to 3ecdad6 Compare September 29, 2020 12:24
@bluetech bluetech merged commit a6a7ba5 into pytest-dev:master Oct 3, 2020
@bluetech bluetech deleted the fix-testpaths-bestrelpath2 branch October 6, 2020 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] testpaths broken, captured as string

2 participants