Skip to content

document test if style output of --collect-only output with -q #3284

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

Closed
fontealpina opened this issue Mar 6, 2018 · 20 comments
Closed

document test if style output of --collect-only output with -q #3284

fontealpina opened this issue Mar 6, 2018 · 20 comments
Labels
good first issue easy issue that is friendly to new contributor status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity type: docs documentation improvement, missing or needing clarification

Comments

@fontealpina
Copy link

Currently the --collect-only option shows the collected tests in a tree style presentation.
I was wondering if there is a way to show the collected tests list with the -v style, of course without the test result.
This would be useful to compare the output of --collect-only with the output of other runs of the tests.

@nicoddemus
Copy link
Member

It is not quite clear to me what you mean @fontealpina, would you mind add more details? Thanks!

@nicoddemus nicoddemus added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Mar 6, 2018
@fontealpina
Copy link
Author

Let's suppose to have a test:

class TestSuite():

    def test_case_01(self):
        assert True

    def test_case_02(self):
        assert True

Running the test with pytest -v the output is:

collected 2 items                                                                                                                                                                                                                       

test_path/test.py::TestSuite::test_case_01 PASSED
test_path/test.py::TestSuite::test_case_02 PASSED

====================== 2 passed in 0.01 seconds =======================

Running pytest with pytest --collect-only the output is:

collected 2 items                                                                                                                                                                                                                       
<Module 'test.py'>
  <Class 'TestSuite'>
    <Instance '()'>
      <Function 'test_case_01'>
      <Function 'test_case_02'>

==================== no tests ran in 0.00 seconds =====================

I was wondering how it would be possible instead to get with pytest --collect-only an output like:

collected 2 items                                                                                                                                                                                                                       

test_path/test.py::TestSuite::test_case_01 
test_path/test.py::TestSuite::test_case_02
==================== no tests ran in 0.00 seconds =====================

@The-Compiler
Copy link
Member

That seems useful to easily copy test IDs to select individual tests too.

@RonnyPfannschmidt
Copy link
Member

thats supported with -q for just test ids and -qq for just test filenames

@fontealpina
Copy link
Author

@RonnyPfannschmidt Thanks

@RonnyPfannschmidt RonnyPfannschmidt added type: question general question, might be closed after 2 weeks of inactivity and removed status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity labels Mar 6, 2018
@RonnyPfannschmidt
Copy link
Member

closing as it seems to be answered

@twmr
Copy link
Contributor

twmr commented Mar 6, 2018

Thx @fontealpina for creating this ticket! Is this documented in our docs? If not, we should change that.

@fontealpina
Copy link
Author

@Thisch I have just checked and actually seems it is missing.

@RonnyPfannschmidt RonnyPfannschmidt added the type: docs documentation improvement, missing or needing clarification label Mar 6, 2018
@RonnyPfannschmidt RonnyPfannschmidt changed the title show --collect-only output with -v style document test if style output of --collect-only output with -q Mar 6, 2018
@RonnyPfannschmidt
Copy link
Member

in that case it should be added, thanks for going and checking

@RonnyPfannschmidt RonnyPfannschmidt added good first issue easy issue that is friendly to new contributor and removed type: question general question, might be closed after 2 weeks of inactivity labels Mar 6, 2018
@twmr
Copy link
Contributor

twmr commented Mar 9, 2018

I would expect that the test items returned by pytest --collect-only -qq can be passed as arguments to pytest, but it turns out that this does not work (neither pytest "tests/test_a.py::TestXYZ::test_abc" nor pytest -k "tests/test_a.py::TestXYZ::test_abc" works)

Do you know if this is supported by using different cmd line flags?

@RonnyPfannschmidt
Copy link
Member

drop the -k and it should work, those are nto valid keywords, they are node ids

@RonnyPfannschmidt
Copy link
Member

oh, and if it doesn't ,thats a bug

@nicoddemus
Copy link
Member

nicoddemus commented Mar 9, 2018

@Thisch it works for me using -q:

λ pytest foo.py -q --collect-only
foo.py::test1[0]
foo.py::test1[1]
foo.py::test1[2]
foo.py::test1[3]
foo.py::test1[4]
foo.py::test1[5]
foo.py::test1[6]
foo.py::test1[7]
foo.py::test1[8]
foo.py::test1[9]
λ pytest foo.py::test1[4] -v
================================================= test session starts =================================================
platform win32 -- Python 2.7.12, pytest-3.4.0, py-1.5.2, pluggy-0.6.0 -- w:\ws\Souring\envs\souring20-py27\python.exe
cachedir: .pytest_cache
PyQt5 5.5.1 -- Qt runtime 5.5.1 -- Qt compiled 5.5.1
rootdir: w:\ws\Souring\Projects\souring\souring20, inifile: pytest.ini
plugins: xdist-1.22.0, timeout-1.2.1, replay-0.2.2, qt-2.1.0, mock-1.6.3, localserver-0.4.1, lazy-fixture-0.3.0, forked-0.2, cpp-0.4.5, cov-2.5.1, llvmpipe-gl-0.0.0
collected 1 item

foo.py::test1[4] PASSED                                                                                          [100%]

============================================== 1 passed in 0.15 seconds ===============================================

Or do you really mean -qq? If that's the case indeed it does not produce usable ids:

λ pytest foo.py -qq --collect-only
foo.py: 10

But I think supporting it through -q is enough.

@RonnyPfannschmidt RonnyPfannschmidt added the status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity label Mar 9, 2018
@twmr
Copy link
Contributor

twmr commented Mar 9, 2018

In projects using unittest-style classes you have to use -qq (with -q you still see the xml-like output)

@twmr
Copy link
Contributor

twmr commented Mar 9, 2018

oh, and if it doesn't ,thats a bug

@RonnyPfannschmidt, no it doesn't work with pytest "test.py::TestClass::test_method.

@RonnyPfannschmidt
Copy link
Member

ok, so we have a bug for interaction between collectonly and unittest classes

@nicoddemus
Copy link
Member

@Thisch can you please open a new issue with that, including a quick example? (I would but I'm short on time right now)

@twmr
Copy link
Contributor

twmr commented Mar 9, 2018

Sure, in a few hours.

@marekbruchaty
Copy link

@RonnyPfannschmidt Thank you!

@Zac-HD
Copy link
Member

Zac-HD commented Oct 20, 2018

In projects using unittest-style classes you have to use -qq (with -q you still see the xml-like output)

Also fixed as of pytest 3.9.1 (probably earlier 😜), so I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor status: needs information reporter needs to provide more information; can be closed after 2 or more weeks of inactivity type: docs documentation improvement, missing or needing clarification
Projects
None yet
Development

No branches or pull requests

7 participants