Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced nodeids to include line numbers #5241

Closed
blueyed opened this issue May 10, 2019 · 3 comments
Closed

Enhanced nodeids to include line numbers #5241

blueyed opened this issue May 10, 2019 · 3 comments
Labels
topic: reporting related to terminal output and user-facing messages and errors type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@blueyed
Copy link
Contributor

blueyed commented May 10, 2019

Pytest should handle an extended nodeid format of fname:lnum::func, which is would then use with the short test summary (for easier selection of tests in an editor).

The format currently is fname::func, which is good in terms of being stable across file changes and when referring to tests themselves, but for errors / test failures it should be more specific (i.e. include the line number).

An alternative might be fname::func:lnum, but this is not that easy for editors to parse (but basically you would have to ignore the "::func" therin.

As for the short test summary, it could also just display fname:lineno there, but I think it is useful to have the test name there also.

Originally posted by @blueyed in #5002 (comment)

@blueyed
Copy link
Contributor Author

blueyed commented May 10, 2019

Actually for the short test summary we could just go with fname:lnum: test: …:

FAILED testing/test_pdb.py:1107: test_sticky_dunder_exception - assert False
FAILED testing/test_pdb.py:1141: test_sticky_dunder_exception_with_highlight - assert False

@blueyed
Copy link
Contributor Author

blueyed commented May 10, 2019

But that makes it difficult for pytest to pick it up then, since fname:lnum cannot be used for test selection still.
So going with fname::testname:lnum now, although that makes it more difficult for editors to pick it up then.

@Zac-HD Zac-HD added topic: reporting related to terminal output and user-facing messages and errors type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature labels Jun 5, 2019
blueyed added a commit to blueyed/pytest that referenced this issue Nov 1, 2019
blueyed added a commit to blueyed/pytest that referenced this issue Nov 1, 2019
Uses "%s:%d(%s)" % (path,)
Uses `"%s:%d(%s)" % (path, testloc.lineno, testname)` for locations in
tests, and `"%s (%s:%d)" % (nodeid, testloc_path, testloc.lineno)`
otherwise.

Fixes pytest-dev#5241.
Closes #38.
@blueyed
Copy link
Contributor Author

blueyed commented Nov 1, 2019

Done in my fork: blueyed@c947224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants