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

report results for ConcurrentStreamTestResults #292

Open
marqh opened this issue May 12, 2020 · 1 comment
Open

report results for ConcurrentStreamTestResults #292

marqh opened this issue May 12, 2020 · 1 comment

Comments

@marqh
Copy link

marqh commented May 12, 2020

Hello Testtools

I am attempting to migrate from in situ unittest.TestCase

I am struggling to understand from the documentation how to obtain parallelisation and still report test results to the terminal.

I would like to propose an update to the documentation to explain this facet, once I have understood it.

I used to have

import unittest

class TestContentsConsistency(unittest.TestCase):
    def test_true(self):
        self.assertTrue(True)
    def test_false(self):
        self.assertTrue(False)

if __name__ == '__main__':
    unittest.main()

which outputs

> python3 ut.py 
F.
======================================================================
FAIL: test_false (__main__.TestContentsConsistency)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "ut.py", line 6, in test_false
    self.assertTrue(False)
AssertionError: False is not true

----------------------------------------------------------------------
Ran 2 tests in 0.000s

FAILED (failures=1)

I have updated this to

import unittest
import testtools

class TestContentsConsistency(testtools.TestCase):
    def test_true(self):
        print('True')
        self.assertTrue(True)
    def test_false(self):
        print('False')
        self.assertTrue(False)

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestContentsConsistency)
    concurrent_suite = testtools.ConcurrentStreamTestSuite(lambda: ((case, None) for case in suite))
    concurrent_suite.run(testtools.StreamResult())

which outputs

> python3 tt.py 
False
True

so i can explicitly call a print statement, and see that the tests are running, but i do not get the unittest like summary output provided.

Questions:

  1. How can this example be adapted such that the test results are presented, similar to how unittest presents them?
  2. Is there value in turning this example with answers to question 1 into a tutorial within the documentation?

many thanks
marqh

@marqh
Copy link
Author

marqh commented Jun 16, 2020

Please may I request some feedback on this topic from the testtools community?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant