diff options
author | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2019-08-06 10:52:55 -0400 |
---|---|---|
committer | Max Hirschhorn <max.hirschhorn@mongodb.com> | 2019-08-06 10:52:55 -0400 |
commit | 39e0f9648d012e556b24f3ee1728675bd9b197bb (patch) | |
tree | 9b0f556cbc5d1b3da418e8141ff0b11d4928ce77 /buildscripts | |
parent | 4dc5a1f3e41cd289023797c433884e52ce1f9bf8 (diff) | |
download | mongo-39e0f9648d012e556b24f3ee1728675bd9b197bb.tar.gz |
SERVER-42356 Remove special casing for NoOpFixture setup and teardown.
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/resmokelib/testing/job.py | 7 | ||||
-rw-r--r-- | buildscripts/tests/resmokelib/testing/test_job.py | 26 |
2 files changed, 28 insertions, 5 deletions
diff --git a/buildscripts/resmokelib/testing/job.py b/buildscripts/resmokelib/testing/job.py index 6fb3bd38246..6219acc1f17 100644 --- a/buildscripts/resmokelib/testing/job.py +++ b/buildscripts/resmokelib/testing/job.py @@ -7,7 +7,6 @@ from . import queue_element from . import testcases from .. import config from .. import errors -from ..testing.fixtures import interface as _fixtures from ..testing.hooks import stepdown from ..testing.testcases import fixture as _fixture from ..utils import queue as _queue @@ -42,14 +41,13 @@ class Job(object): # pylint: disable=too-many-instance-attributes Return True if the setup was successful, False otherwise. """ - if isinstance(self.fixture, _fixtures.NoOpFixture): - return True test_case = _fixture.FixtureSetupTestCase(self.test_queue_logger, self.fixture, "job{}".format(self.job_num)) test_case(self.report) if self.report.find_test_info(test_case).status != "pass": self.logger.error("The setup of %s failed.", self.fixture) return False + return True def teardown_fixture(self): @@ -57,14 +55,13 @@ class Job(object): # pylint: disable=too-many-instance-attributes Return True if the teardown was successful, False otherwise. """ - if isinstance(self.fixture, _fixtures.NoOpFixture): - return True test_case = _fixture.FixtureTeardownTestCase(self.test_queue_logger, self.fixture, "job{}".format(self.job_num)) test_case(self.report) if self.report.find_test_info(test_case).status != "pass": self.logger.error("The teardown of %s failed.", self.fixture) return False + return True @staticmethod diff --git a/buildscripts/tests/resmokelib/testing/test_job.py b/buildscripts/tests/resmokelib/testing/test_job.py index ca204548214..cac4930475e 100644 --- a/buildscripts/tests/resmokelib/testing/test_job.py +++ b/buildscripts/tests/resmokelib/testing/test_job.py @@ -9,6 +9,7 @@ import mock from buildscripts.resmokelib import errors from buildscripts.resmokelib.testing import job from buildscripts.resmokelib.testing import queue_element +from buildscripts.resmokelib.testing.fixtures import interface as _fixtures from buildscripts.resmokelib.utils import queue as _queue # pylint: disable=missing-docstring,protected-access @@ -264,3 +265,28 @@ class TestFixtureSetupAndTeardown(unittest.TestCase): self.__job_object.teardown_fixture.side_effect = Exception( "Generic error intentionally raised in unit test") self.__assert_when_run_tests(teardown_succeeded=False) + + +class TestNoOpFixtureSetupAndTeardown(unittest.TestCase): + """Test cases for NoOpFixture handling in setup_fixture() and teardown_fixture().""" + + def setUp(self): + logger = logging.getLogger("job_unittest") + self.__noop_fixture = _fixtures.NoOpFixture(logger=logger, job_num=0) + self.__noop_fixture.setup = mock.Mock() + self.__noop_fixture.teardown = mock.Mock() + + test_report = mock.Mock() + test_report.find_test_info().status = "pass" + + self.__job_object = job.Job(job_num=0, logger=logger, fixture=self.__noop_fixture, hooks=[], + report=test_report, archival=None, suite_options=None, + test_queue_logger=logger) + + def test_setup_called_for_noop_fixture(self): + self.assertTrue(self.__job_object.setup_fixture()) + self.__noop_fixture.setup.assert_called_once_with() + + def test_teardown_called_for_noop_fixture(self): + self.assertTrue(self.__job_object.teardown_fixture()) + self.__noop_fixture.teardown.assert_called_once_with(finished=True) |