How to use get_num_failures method in Slash

Best Python code snippet using slash

prow_test.py

Source:prow_test.py Github

copy

Full Screen

1import json2import unittest3import mock4from google.cloud import storage # pylint: disable=no-name-in-module5from py import prow6class TestProw(unittest.TestCase):7 @mock.patch("prow.time.time")8 def testCreateFinished(self, mock_time): # pylint: disable=no-self-use9 """Test create finished"""10 mock_time.return_value = 100011 gcs_client = mock.MagicMock(spec=storage.Client)12 blob = prow.create_finished(gcs_client, "gs://bucket/output", True)13 expected = {14 "timestamp": 1000,15 "result": "SUCCESS",16 "metadata": {},17 }18 blob.upload_from_string.assert_called_once_with(json.dumps(expected))19 @mock.patch("prow.time.time")20 def testCreateStartedPeriodic(self, mock_time): # pylint: disable=no-self-use21 """Test create started for periodic job."""22 mock_time.return_value = 100023 gcs_client = mock.MagicMock(spec=storage.Client)24 blob = prow.create_started(gcs_client, "gs://bucket/output", "abcd")25 expected = {26 "timestamp": 1000,27 "repos": {28 "kubeflow/tf-operator": "abcd",29 },30 }31 blob.upload_from_string.assert_called_once_with(json.dumps(expected))32 def testGetSymlinkOutput(self):33 location = prow.get_symlink_output("10", "mlkube-build-presubmit", "20")34 self.assertEqual(35 "gs://kubernetes-jenkins/pr-logs/directory/mlkube-build-presubmit/20.txt",36 location)37 def testCreateSymlinkOutput(self): # pylint: disable=no-self-use38 """Test create started for periodic job."""39 gcs_client = mock.MagicMock(spec=storage.Client)40 blob = prow.create_symlink(gcs_client, "gs://bucket/symlink",41 "gs://bucket/output")42 blob.upload_from_string.assert_called_once_with("gs://bucket/output")43 @mock.patch("py.prow.test_util.get_num_failures")44 @mock.patch("py.prow._get_actual_junit_files")45 def testCheckNoErrorsSuccess(self, mock_get_junit, mock_get_failures):46 # Verify that check no errors returns true when there are no errors47 gcs_client = mock.MagicMock(spec=storage.Client)48 artifacts_dir = "gs://some_dir"49 mock_get_junit.return_value = set(["junit_1.xml"])50 mock_get_failures.return_value = 051 junit_files = ["junit_1.xml"]52 self.assertTrue(53 prow.check_no_errors(gcs_client, artifacts_dir, junit_files))54 @mock.patch("py.prow.test_util.get_num_failures")55 @mock.patch("py.prow._get_actual_junit_files")56 def testCheckNoErrorsFailure(self, mock_get_junit, mock_get_failures):57 # Verify that check no errors returns false when a junit58 # file reports an error.59 gcs_client = mock.MagicMock(spec=storage.Client)60 artifacts_dir = "gs://some_dir"61 mock_get_junit.return_value = set(["junit_1.xml"])62 mock_get_failures.return_value = 163 junit_files = ["junit_1.xml"]64 self.assertFalse(65 prow.check_no_errors(gcs_client, artifacts_dir, junit_files))66 @mock.patch("py.prow.test_util.get_num_failures")67 @mock.patch("py.prow._get_actual_junit_files")68 def testCheckNoErrorsFailureExtraJunit(self, mock_get_junit,69 mock_get_failures):70 # Verify that check no errors returns false when there are extra71 # junit files72 gcs_client = mock.MagicMock(spec=storage.Client)73 artifacts_dir = "gs://some_dir"74 mock_get_junit.return_value = set(["junit_0.xml", "junit_1.xml"])75 mock_get_failures.return_value = 076 junit_files = ["junit_1.xml"]77 self.assertFalse(78 prow.check_no_errors(gcs_client, artifacts_dir, junit_files))79if __name__ == "__main__":...

Full Screen

Full Screen

test_results.py

Source:test_results.py Github

copy

Full Screen

...23 result = SummarizingResult()24 result.startTestRun()25 result.stopTestRun()26 self.assertEqual(0, result.testsRun)27 self.assertEqual(0, result.get_num_failures())28 self.assertIs(None, result.get_time_taken())29 def test_time_taken(self):30 result = SummarizingResult()31 now = datetime.now()32 result.startTestRun()33 result.status(timestamp=now)34 result.status(timestamp=now + timedelta(seconds=5))35 result.stopTestRun()36 self.assertEqual(5.0, result.get_time_taken())37 def test_num_failures(self):38 result = SummarizingResult()39 result.startTestRun()40 try:41 1/042 except ZeroDivisionError:43 error = sys.exc_info()44 result.status(test_id='foo', test_status='fail')45 result.status(test_id='foo', test_status='fail')46 result.stopTestRun()47 self.assertEqual(2, result.get_num_failures())48 def test_tests_run(self):49 result = SummarizingResult()50 result.startTestRun()51 for i in range(5):52 result.status(test_id='foo', test_status='success')53 result.stopTestRun()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful