Exemple #1
0
    def run(self):
        if not self.module:
            return 'No module found.'

        suite = TestSuite(self.module, self.class_name, self.method_name)
        result = TestResult()
        suite.run(result)
        return result.summary()
Exemple #2
0
 def test_suite(self):
     suite = TestSuite()
     suite.add(WasRun("testMethod"))
     suite.add(WasRun("brokenMethod"))
     result = suite.run()
     assert result.summary() == "2 run, 1 failed"
Exemple #3
0
        result.testStarted()
        result.testFailed()
        assert "1 run, 1 failed"

    def test_suite(self):
        suite = TestSuite()
        suite.add(WasRun("testMethod"))
        suite.add(WasRun("brokenMethod"))
        result = suite.run()
        assert result.summary() == "2 run, 1 failed"

    def test_add_result(self):
        result1 = TestResult()
        result2 = TestResult()
        result1.testStarted()
        result1.testFailed()
        result2.testStarted()
        combined_result = result1.add(result2)
        assert "2 run, 1 failed" == combined_result.summary()


suite = TestSuite()
suite.add(TestTestCase("test_run"))
suite.add(TestTestCase("test_result"))
suite.add(TestTestCase("test_failed"))
suite.add(TestTestCase("test_failed_result_formatting"))
suite.add(TestTestCase("test_suite"))
suite.add(TestTestCase("test_add_result"))
result = suite.run()
print(result.summary())
Exemple #4
0
 def test_suite(self):
     suite = TestSuite()
     suite.add(WasRun('test_method'))
     suite.add(WasRun('test_failed_method'))
     suite.run(self.result)
     assert "2 run, 1 failed" == self.result.summary()
Exemple #5
0
 def test_run_suite_with_specific_class_and_inexistent_method(self):
     suite = TestSuite(self.module, 'MockTestClass', 'inexistent_method')
     suite.run(self.result)
     assert "0 run, 0 failed" == self.result.summary()
Exemple #6
0
        test.run(self.result)
        assert any("Fake Error" in e for e in self.result.exceptions())

    def test_suite(self):
        suite = TestSuite()
        suite.add(WasRun('test_method'))
        suite.add(WasRun('test_failed_method'))
        suite.run(self.result)
        assert "2 run, 1 failed" == self.result.summary()


tests = [
    'test_template_method',
    'test_result',
    'test_failed_result_formatting',
    'test_result_failed',
    'test_result_failed_during_setup',
    'test_summary_includes_exceptions',
    'test_suite',
]

ts = TestSuite()
r = TestResult()
for t in tests:
    ts.add(TestCaseTest(t))
ts.run(r)
print(r.summary())
for e in r.exceptions():
    print(e)
    print()
Exemple #7
0
 def test_run_suite_with_specific_invalid_class(self):
     suite = TestSuite(self.module, 'TestInvalidClass')
     suite.run(self.result)
     assert "0 run, 0 failed" == self.result.summary()
Exemple #8
0
 def test_run_suite_with_specific_class_and_method(self):
     suite = TestSuite(self.module, 'MockTestClass', 'test_dummy_sum')
     suite.run(self.result)
     assert "1 run, 0 failed" == self.result.summary()
Exemple #9
0
 def test_run_suite_with_specific_class_test(self):
     suite = TestSuite(self.module, 'MockTestClass')
     suite.run(self.result)
     assert "2 run, 0 failed" == self.result.summary()
Exemple #10
0
 def test_run_suite_with_specific_inexistent_class(self):
     suite = TestSuite(self.module, 'Abc')
     suite.run(self.result)
     assert "0 run, 0 failed" == self.result.summary()
Exemple #11
0
 def test_if_test_methods_startswith_test(self):
     suite = TestSuite()
     methods = suite.get_class_methods(TestCaseTest)
     assert 'test_if_test_methods_startswith_test' in methods
     assert '__init__' not in methods
Exemple #12
0
 def test_get_methods_for_test_in_each_class(self):
     suite = TestSuite(self.module)
     methods = suite.get_class_methods(TestCaseTest)
     assert 'test_template_method' in methods
     assert 'test_get_methods_for_test_in_each_class' in methods
Exemple #13
0
 def test_if_classes_for_test_are_valid(self):
     suite = TestSuite(self.module)
     test_classes = suite.get_classes_for_test()
     assert 'TestInvalidClass' not in test_classes
     assert self.__class__.__name__ in test_classes
Exemple #14
0
 def test_get_classes_for_test(self):
     suite = TestSuite(self.module)
     test_classes = suite.get_classes_for_test()
     assert self.__class__.__name__ in test_classes.keys()
     assert isinstance(self, test_classes[self.__class__.__name__])
Exemple #15
0
	def testSuite(self):
		suite = TestSuite()
		suite.add(WasRun('testMethod'))
		suite.add(WasRun('testBrokenMethod'))
		suite.run(self.result)
		assert('2 run, 1 failed' == self.result.summary())