MCPcopy Create free account
hub / github.com/cztomczak/cefpython / TestRunner

Class TestRunner

unittests/_test_runner.py:68–283  ·  view source on GitHub ↗

Customized test runner.

Source from the content-addressed store, hash-verified

66
67
68class TestRunner(object):
69 """Customized test runner."""
70
71 ran = 0
72 errors = 0
73 failures = 0
74 cefpython_version = "-unknown-"
75
76 _suites = None # type: unittest.TestSuite
77 _isolated_suites = None # type: unittest.TestSuite
78 _import_errors = None # type: unittest.TestSuite
79
80 def _reset_state(self):
81 # type: () -> None
82 """Reset TestRunner state before test discovery."""
83 self.ran = 0
84 self.errors = 0
85 self.failures = 0
86 self._suites = unittest.TestSuite()
87 self._isolated_suites = unittest.TestSuite()
88 self._import_errors = unittest.TestSuite()
89
90 # ---- Public methods
91
92 def run_testcase(self, testcase):
93 # type: (str) -> None
94 """Run single test case eg 'foo.BarTest'. This is needed to
95 run single testcase that is marked as IsolatedTest."""
96 self._discover("[!_]*.py", testcase)
97 assert not self._count_suites(self._isolated_suites)
98 if not self._count_suites(self._suites):
99 print("[_test_runner.py] ERROR: test case not found")
100 sys.exit(1)
101 # Import errors found during discovery are ignored
102 self._run_suites(self._suites)
103 self._exit()
104
105 def run_file(self, filename):
106 # type: (str) -> None
107 """Run test cases from a specific file. This is needed so that
108 you can use _runner.main() in isolated tests."""
109 self._discover(filename)
110 self._run_discovered_suites()
111
112 def run_all(self):
113 # type: () -> None
114 """Run all tests from current directory."""
115 self._discover("[!_]*.py")
116 self._run_discovered_suites()
117
118 # ---- Private methods
119
120 def _run_discovered_suites(self):
121 # type: () -> None
122 """Run both normal and isolated suites."""
123 suites = self._merge_suites(self._import_errors, self._suites)
124 self._run_suites(suites)
125 self._run_suites_in_isolation(self._isolated_suites)

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

mainFunction · 0.68