def test_should_run_discovered_and_loaded_tests(self, mock_discover_modules, mock_unittest, runner): mock_tests = Mock() mock_unittest.defaultTestLoader.loadTestsFromNames.return_value = mock_tests execute_tests(runner, self.mock_logger, '/path/to/test/sources', '_tests.py') runner.return_value.run.assert_called_with(mock_tests)
def test_should_discover_modules_by_suffix(self, mock_discover_modules_matching, mock_unittest, runner, tool): pipe = Mock() pipe.remote_close_cause.return_value = None tool.return_value = (Mock(), pipe) execute_tests(Mock(), [], runner, self.mock_logger, "/path/to/test/sources", "_tests.py", ["a", "b"]) mock_discover_modules_matching.assert_called_with("/path/to/test/sources", "*_tests.py")
def test_should_discover_modules_by_suffix(self, mock_discover_modules_matching, mock_unittest, runner): execute_tests(runner, self.mock_logger, '/path/to/test/sources', '_tests.py') mock_discover_modules_matching.assert_called_with( '/path/to/test/sources', '*_tests.py')
def test_should_load_tests_from_discovered_modules(self, mock_discover_modules, mock_unittest): mock_modules = Mock() mock_discover_modules.return_value = mock_modules execute_tests('/path/to/test/sources', '_tests.py') mock_unittest.defaultTestLoader.loadTestsFromNames.assert_called_with(mock_modules)
def test_should_set_test_method_prefix_when_given(self, mock_discover_modules, mock_unittest, runner): mock_tests = Mock() mock_unittest.defaultTestLoader.loadTestsFromNames.return_value = mock_tests runner.return_value.run.return_value = self.mock_result actual, _ = execute_tests("/path/to/test/sources", "_tests.py", test_method_prefix="should_") self.assertEqual("should_", mock_unittest.defaultTestLoader.testMethodPrefix)
def test_should_return_actual_test_results(self, mock_discover_modules, mock_unittest, runner): mock_tests = Mock() mock_unittest.defaultTestLoader.loadTestsFromNames.return_value = mock_tests runner.return_value.run.return_value = self.mock_result actual, _ = execute_tests(runner, self.mock_logger, '/path/to/test/sources', '_tests.py') self.assertEqual(self.mock_result, actual)
def test_should_set_test_method_prefix_when_given(self, mock_discover_modules, mock_unittest, runner): mock_tests = Mock() mock_unittest.defaultTestLoader.loadTestsFromNames.return_value = mock_tests runner.return_value.run.return_value = self.mock_result actual, _ = execute_tests(runner, self.mock_logger, '/path/to/test/sources', '_tests.py', test_method_prefix='should_') self.assertEqual('should_', mock_unittest.defaultTestLoader.testMethodPrefix)
def test_should_return_actual_test_results(self, mock_discover_modules, mock_unittest, runner, tool): pipe = Mock() pipe.remote_close_cause.return_value = None tool.return_value = (Mock(), pipe) mock_tests = Mock() mock_unittest.defaultTestLoader.loadTestsFromNames.return_value = mock_tests runner.return_value.run.return_value = self.mock_result actual, _ = execute_tests(Mock(), [], runner, self.mock_logger, "/path/to/test/sources", "_tests.py") self.assertEqual(self.mock_result, actual)
def test_should_return_actual_test_results(self, mock_discover_modules, mock_unittest): mock_tests = Mock() mock_unittest.defaultTestLoader.loadTestsFromNames.return_value = mock_tests mock_test_runner = Mock() mock_result = Mock() mock_test_runner.run.return_value = mock_result mock_unittest.TextTestRunner.return_value = mock_test_runner actual, _ = execute_tests('/path/to/test/sources', '_tests.py') self.assertEqual(mock_result, actual)
def test_should_set_test_method_prefix_when_given(self, mock_discover_modules, mock_unittest): mock_tests = Mock() mock_unittest.defaultTestLoader.loadTestsFromNames.return_value = mock_tests mock_test_runner = Mock() mock_result = Mock() mock_test_runner.run.return_value = mock_result mock_unittest.TextTestRunner.return_value = mock_test_runner actual, _ = execute_tests('/path/to/test/sources', '_tests.py', test_method_prefix='should_') self.assertEqual('should_', mock_unittest.defaultTestLoader.testMethodPrefix)
def test_should_discover_modules_by_suffix(self, mock_discover_modules_matching, mock_unittest, runner): execute_tests("/path/to/test/sources", "_tests.py") mock_discover_modules_matching.assert_called_with("/path/to/test/sources", "*_tests.py")
def test_should_discover_modules_by_suffix(self, mock_discover_modules_matching, mock_unittest, runner): execute_tests(runner, self.mock_logger, '/path/to/test/sources', '_tests.py') mock_discover_modules_matching.assert_called_with('/path/to/test/sources', '*_tests.py')
def test_should_discover_modules_in_given_path(self, mock_discover_modules, mock_unittest): execute_tests('/path/to/test/sources', '_tests.py') mock_discover_modules.assert_called_with('/path/to/test/sources', '_tests.py')