Python twisted.trial.unittest.main() Examples
The following are 5
code examples of twisted.trial.unittest.main().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.trial.unittest
, or try the search function
.
Example #1
Source File: test_unittest.py From pytest with MIT License | 6 votes |
def test_unittest_expected_failure_for_failing_test_is_xfail(testdir, runner): script = testdir.makepyfile( """ import unittest class MyTestCase(unittest.TestCase): @unittest.expectedFailure def test_failing_test_is_xfail(self): assert False if __name__ == '__main__': unittest.main() """ ) if runner == "pytest": result = testdir.runpytest("-rxX") result.stdout.fnmatch_lines( ["*XFAIL*MyTestCase*test_failing_test_is_xfail*", "*1 xfailed*"] ) else: result = testdir.runpython(script) result.stderr.fnmatch_lines(["*1 test in*", "*OK*(expected failures=1)*"]) assert result.ret == 0
Example #2
Source File: test_unittest.py From pytest with MIT License | 6 votes |
def test_unittest_expected_failure_for_passing_test_is_fail(testdir, runner): script = testdir.makepyfile( """ import unittest class MyTestCase(unittest.TestCase): @unittest.expectedFailure def test_passing_test_is_fail(self): assert True if __name__ == '__main__': unittest.main() """ ) if runner == "pytest": result = testdir.runpytest("-rxX") result.stdout.fnmatch_lines( ["*MyTestCase*test_passing_test_is_fail*", "*1 failed*"] ) else: result = testdir.runpython(script) result.stderr.fnmatch_lines(["*1 test in*", "*(unexpected successes=1)*"]) assert result.ret == 1
Example #3
Source File: test_manhole.py From python-for-android with Apache License 2.0 | 5 votes |
def test_importMain(self): """Trying to import __main__""" self.client.setZero() self.p.perspective_do("import __main__") if self.client.getMessages(): msg = self.client.getMessages()[0] if msg[0] in ("exception","stderr"): self.fail(msg[1]) #if __name__=='__main__': # unittest.main()
Example #4
Source File: test_manhole.py From BitTorrent with GNU General Public License v3.0 | 5 votes |
def test_importMain(self): """Trying to import __main__""" self.client.setZero() self.p.perspective_do("import __main__") if self.client.getMessages(): msg = self.client.getMessages()[0] if msg[0] in ("exception","stderr"): self.fail(msg[1]) #if __name__=='__main__': # unittest.main()
Example #5
Source File: test_unittest.py From pytest with MIT License | 4 votes |
def test_djangolike_testcase(testdir): # contributed from Morten Breekevold testdir.makepyfile( """ from unittest import TestCase, main class DjangoLikeTestCase(TestCase): def setUp(self): print("setUp()") def test_presetup_has_been_run(self): print("test_thing()") self.assertTrue(hasattr(self, 'was_presetup')) def tearDown(self): print("tearDown()") def __call__(self, result=None): try: self._pre_setup() except (KeyboardInterrupt, SystemExit): raise except Exception: import sys result.addError(self, sys.exc_info()) return super(DjangoLikeTestCase, self).__call__(result) try: self._post_teardown() except (KeyboardInterrupt, SystemExit): raise except Exception: import sys result.addError(self, sys.exc_info()) return def _pre_setup(self): print("_pre_setup()") self.was_presetup = True def _post_teardown(self): print("_post_teardown()") """ ) result = testdir.runpytest("-s") assert result.ret == 0 result.stdout.fnmatch_lines( [ "*_pre_setup()*", "*setUp()*", "*test_thing()*", "*tearDown()*", "*_post_teardown()*", ] )