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

Keep consistency in the output #173

Open
azmeuk opened this issue Mar 26, 2019 · 11 comments
Open

Keep consistency in the output #173

azmeuk opened this issue Mar 26, 2019 · 11 comments
Labels

Comments

@azmeuk
Copy link

azmeuk commented Mar 26, 2019

Right now, when a test fails the output looks like this:

...
Results (2.34s):
       5 passed
       1 failed
         - path/to/your_test.py:666 test_something_wrong

The way the failing test (ie PATH:LINE TEST) is displayed is not the natural way pytest displays test paths (ie PATH::TEST), and I think it is unpractical for some reasons:

  • I frequently need to copy/paste this line to pass it as an argument of a new pytest invocation in your shell, for example, with new debugging options. Then I have to clean the line numbers, and add a colon, and delete a space. Once, it is not a big deal, but it is a bit annoying when you do this dozen times a day.
  • Using thing like kitty hints, the space in the report makes kitty only catch the filename, and not the whole test path, making the hint feature useless in that situation.

A more practical way to display the report would be to keep the test path the way pytest use them. For example what do you think of this output?

...
Results (2.34s):
       5 passed
       1 failed
         - path/to/your_test.py::test_something_wrong :666

If you agree, I am willing to make a pull request. What do you think?

Cheers

@blueyed
Copy link
Collaborator

blueyed commented Mar 26, 2019

Just for reference: pytest should also be able to run tests via file:lineno (WIP at pytest-dev/pytest#3282).

  • Using thing like kitty hints, the space in the report makes kitty only catch the filename, and not the whole test path, making the hint feature useless in that situation.

Do you mean a custom hint, which fails because it cannot include the space?

  • path/to/your_test.py::test_something_wrong :666

I'd prefer - path/to/your_test.py::test_something_wrong, line 666. This appears to be more common.

Would path/to/your_test.py::test_something_wrong:666 also work / make sense?

Anyway, in general this repo appears to be quite inactive currently, and CI would fail for your PR anyway, but feel free to give it a try already!

This is something that annoyed me also about pytest-sugar (I am not using it currently), and thought I had done some PR in this regard myself, but could not find it.

Check out #172 also.

@blueyed
Copy link
Collaborator

blueyed commented Mar 27, 2019

There is some discussion / brainstorming with regard to this in pytest itself: pytest-dev/pytest#5002 (comment).

@Teemu
Copy link
Owner

Teemu commented Feb 13, 2020

In my use cases I usually just want to jump into the file rather than running it again with pytest so the line number next to the filename is really handy (at least iTerm2 allows direct jump with the line number)

@blueyed
Copy link
Collaborator

blueyed commented Feb 13, 2020

Related: pytest-dev/pytest#5241
Unfortunately this got no traction in pytest itself, but I have it in my (more serious) fork (https://github.com/blueyed/pytest/), where it has the line numbers in the short test summary then also. This is very useful.
btw: https://github.com/wsdjeg/vim-fetch handles the nodeids also, but only goes to the function itself then.

@nicoddemus

This comment has been minimized.

@nicoddemus

This comment has been minimized.

1 similar comment
@nicoddemus

This comment has been minimized.

@blueyed

This comment has been minimized.

@nicoddemus

This comment has been minimized.

@blueyed

This comment has been minimized.

@nicoddemus
Copy link
Collaborator

OK, thanks for the clarification.

@Teemu Teemu added the question label Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants