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

Capture not working for unittest.TestCase subclasses #26

Open
nicoddemus opened this issue Jun 10, 2020 · 0 comments
Open

Capture not working for unittest.TestCase subclasses #26

nicoddemus opened this issue Jun 10, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@nicoddemus
Copy link
Member

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 ============================================================================

Originally posted by @dongwoo1005 in #18 (comment)

@nicoddemus nicoddemus added the bug Something isn't working label Jun 10, 2020
@nicoddemus nicoddemus mentioned this issue Jun 10, 2020
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

No branches or pull requests

1 participant