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

No logs? #18

Closed
tzachshabtay opened this issue Jul 29, 2019 · 10 comments · Fixed by #19
Closed

No logs? #18

tzachshabtay opened this issue Jul 29, 2019 · 10 comments · Fixed by #19
Labels
bug Something isn't working

Comments

@tzachshabtay
Copy link

Thanks for the plugin, subtests are properly named now. However...

After installing the plugin the whole section in the output showing the logs is gone (i.e the "Captured stdout call" and "Captured log call" that appear in the bottom without this plugin).

It's very hard to debug failing tests without logs, making this plugin currently unusable for me.

@nicoddemus nicoddemus added the bug Something isn't working label Jul 31, 2019
@nicoddemus
Copy link
Member

Hi @tzachshabtay,

Thanks for the report, that's clearly a bug.

@icemac
Copy link

icemac commented Jan 16, 2020

Are there any news on this issue?

I like this plug-in and started using it in a project. My current trick to see the test output of the failures is to run the tests with -s. This helps but does not seem to be a long term solution.

@nicoddemus
Copy link
Member

Hi @icemac thanks for the ping!

I apologize, I have not allocated time to work on this plugin lately because of more important stuff happening in pytest/xdist/etc.

This plugin is not abandoned though, I will try harder to allocate more time for it in the next days. 👍

nicoddemus added a commit to nicoddemus/pytest-subtests that referenced this issue Jan 22, 2020
nicoddemus added a commit to nicoddemus/pytest-subtests that referenced this issue Jan 22, 2020
@nicoddemus
Copy link
Member

0.3.0 has been released with this fix. 🎉

@r-or
Copy link

r-or commented May 29, 2020

Hi,
for me this issue is still there.

└─ $ ▶ pip freeze | grep subtest
pytest-subtests==0.3.1

Without subtests installed it works just fine :)

@nicoddemus
Copy link
Member

Hi @r-or,

Can you show a test which reproduces the issue? Thanks!

@dongwoo1005
Copy link

dongwoo1005 commented Jun 10, 2020

@nicoddemus The issue still persist on my end on the version 0.3.1

platform linux -- Python 3.6.8, pytest-5.4.3, py-1.8.1, pluggy-0.13.1
rootdir: /opt/integration-test-service
plugins: subtests-0.3.1

I'll post a test to reproduce it shortly

@dongwoo1005
Copy link

dongwoo1005 commented Jun 10, 2020

Below is running from my local - different environment than above, but the behavior is exactly the same - not getting the Captured stdout call logs

Test:

# test_subtest.py
import unittest


class PytestSubtestTest(unittest.TestCase):
    def test_subtest_stdout(self):
        for i in range(2):
            with self.subTest(i=i):
                print(f"{i}: Print something to stdout")
                self.assertEqual(0, 1)

Output:

$ pytest -o log_cli=true test_subtest.py

================================================================================ test session starts ================================================================================
platform darwin -- Python 3.7.7, pytest-5.4.3, py-1.8.1, pluggy-0.13.1
rootdir: /Users/w.son/Projects/git.soma.salesforce.com/TESTS/presto-fit-tests/src/test/python
plugins: subtests-0.3.1
collected 1 item

test_subtest.py::PytestSubtestTest::test_subtest_stdout
test_subtest.py::PytestSubtestTest::test_subtest_stdout PASSED                                                                                                                [100%]

===================================================================================== FAILURES ======================================================================================
____________________________________________________________________ PytestSubtestTest.test_subtest_stdout (i=0) ____________________________________________________________________

self = <test_subtest.PytestSubtestTest testMethod=test_subtest_stdout>

    def test_subtest_stdout(self):
        for i in range(2):
            with self.subTest(i=i):
                print(f"{i}: Print something to stdout")
>               self.assertEqual(0, 1)
E               AssertionError: 0 != 1

test_subtest.py:9: AssertionError
____________________________________________________________________ PytestSubtestTest.test_subtest_stdout (i=1) ____________________________________________________________________

self = <test_subtest.PytestSubtestTest testMethod=test_subtest_stdout>

    def test_subtest_stdout(self):
        for i in range(2):
            with self.subTest(i=i):
                print(f"{i}: Print something to stdout")
>               self.assertEqual(0, 1)
E               AssertionError: 0 != 1

test_subtest.py:9: AssertionError
============================================================================== short test summary info ==============================================================================
FAILED test_subtest.py::PytestSubtestTest::test_subtest_stdout - AssertionError: 0 != 1
FAILED test_subtest.py::PytestSubtestTest::test_subtest_stdout - AssertionError: 0 != 1
============================================================================ 2 failed, 1 passed in 0.11s ============================================================================

@dongwoo1005
Copy link

Also, it's a different question, but why do I get 2 failed and 1 passed in the above instead of just 2 failures?

@nicoddemus
Copy link
Member

Thanks, created #26 as follow up, now the issue is clear! Sorry about the delay.

but why do I get 2 failed and 1 passed in the above instead of just 2 failures?

Because the test containing the subtests passed. This is to differentiate from the case where it also fails after the subTest call:

class PytestSubtestTest(unittest.TestCase):
    def test_subtest_stdout(self):
        for i in range(2):
            with self.subTest(i=i):
                print(f"{i}: Print something to stdout")
                self.assertEqual(0, 1)
        assert 0, "test failed" 

This will get you 3 failures: 2 from the subtests, and one from the failing assert after the subTest context-manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants