def test_success_discover_dataprovided_test_by_name(self): stream = StringIO() tests = TestLoader(config=self.config).loadTestsFromName(self.tests_location + self.tested_test) result = LodeTestResult(stream, None, 0) tests.run(result) self.assertEqual(1, result.testsRun) self.assertEqual([], result.errors) self.assertTrue(result.wasSuccessful())
def test_success_discover_dataprovided_test_by_name(self): stream = StringIO() tests = TestLoader( config=self.config).loadTestsFromName(self.tests_location + self.tested_test) result = LodeTestResult(stream, None, 0) tests.run(result) self.assertEqual(1, result.testsRun) self.assertEqual([], result.errors) self.assertTrue(result.wasSuccessful())
def test_fail_discover_dataprovided_test_by_name(self): stream = StringIO() tests = TestLoader(config=self.config).loadTestsFromName(self.tests_location + self.tested_test) result = LodeTestResult(stream, None, 0) tests.run(result) self.assertEqual(1, result.testsRun) self.assertEqual(1, len(result.errors)) failure = result.errors[0][0] self.assertIsInstance(failure.test, Failure) self.assertEqual("Failure: ValueError (No such test TestCase.test_with_dataprovider_fixture_2)", str(failure)) self.assertFalse(result.wasSuccessful())
def test_discover_all_tests(self): stream = StringIO() tests = TestLoader(config=self.config).loadTestsFromName(self.tests_location) extracted_tests = list() for t in tests._tests: extracted_tests += t._precache result = LodeTestResult(stream, None, 0) tests.run(result) self.assertTrue(result) self.assertEqual(4, result.testsRun) self.assertEqual(4, len(extracted_tests)) self.assertTrue(result.wasSuccessful())
def test_discover_all_tests(self): stream = StringIO() tests = TestLoader(config=self.config).loadTestsFromName( self.tests_location) extracted_tests = list() for t in tests._tests: extracted_tests += t._precache result = LodeTestResult(stream, None, 0) tests.run(result) self.assertTrue(result) self.assertEqual(4, result.testsRun) self.assertEqual(4, len(extracted_tests)) self.assertTrue(result.wasSuccessful())
def test_loaded_names_with_failing_tests_in_idfile(self): stream = StringIO() tests = TestLoader(config=self.config).loadTestsFromName(self.tests_location) result = LodeTestResult(stream, None, 0) tests.run(result) # generate needed idfile self.config.plugins.finalize(result) names = self.x.loadTestsFromNames([self.tests_location]) loaded_tests = [(parse_test_name(name)[1], parse_test_name(name)[2]) for name in names[1]] self.assertEqual( [('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_1'), ('DataprovidedTestCase','test_with_dataprovider_failing_on_everything_except_2_3')], loaded_tests)
def test_fail_discover_dataprovided_test_by_name(self): stream = StringIO() tests = TestLoader( config=self.config).loadTestsFromName(self.tests_location + self.tested_test) result = LodeTestResult(stream, None, 0) tests.run(result) self.assertEqual(1, result.testsRun) self.assertEqual(1, len(result.errors)) failure = result.errors[0][0] self.assertIsInstance(failure.test, Failure) self.assertEqual( "Failure: ValueError (No such test TestCase.test_with_dataprovider_fixture_2)", str(failure)) self.assertFalse(result.wasSuccessful())
def test_loaded_names_with_failing_tests_in_idfile(self): stream = StringIO() tests = TestLoader(config=self.config).loadTestsFromName( self.tests_location) result = LodeTestResult(stream, None, 0) tests.run(result) # generate needed idfile self.config.plugins.finalize(result) names = self.x.loadTestsFromNames([self.tests_location]) loaded_tests = [(parse_test_name(name)[1], parse_test_name(name)[2]) for name in names[1]] self.assertEqual( [('DataprovidedTestCase', 'test_with_dataprovider_failing_on_everything_except_2_1'), ('DataprovidedTestCase', 'test_with_dataprovider_failing_on_everything_except_2_3')], loaded_tests)