From dc46c358dfb717e2695a8778b073ce6d380a4934 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:29 +0200 Subject: [PATCH 01/18] test: Tear down DirsMixin automatically --- master/buildbot/test/integration/test_configs.py | 3 --- .../buildbot/test/integration/test_telegram_bot.py | 1 - master/buildbot/test/unit/changes/test_mail.py | 1 - master/buildbot/test/unit/config/test_master.py | 6 ------ .../buildbot/test/unit/schedulers/test_trysched.py | 3 --- master/buildbot/test/unit/scripts/test_base.py | 6 ------ .../buildbot/test/unit/scripts/test_checkconfig.py | 3 --- master/buildbot/test/unit/scripts/test_cleanupdb.py | 2 -- master/buildbot/test/unit/scripts/test_copydb.py | 4 ---- .../test/unit/scripts/test_create_master.py | 1 - .../buildbot/test/unit/scripts/test_logwatcher.py | 1 - master/buildbot/test/unit/scripts/test_restart.py | 3 --- master/buildbot/test/unit/scripts/test_start.py | 3 --- master/buildbot/test/unit/scripts/test_stop.py | 3 --- .../test/unit/scripts/test_upgrade_master.py | 1 - master/buildbot/test/unit/test_master.py | 1 - master/buildbot/test/unit/util/test_maildir.py | 1 - master/buildbot/test/util/dirs.py | 13 +++++++------ master/buildbot/test/util/migration.py | 1 - 19 files changed, 7 insertions(+), 50 deletions(-) diff --git a/master/buildbot/test/integration/test_configs.py b/master/buildbot/test/integration/test_configs.py index ffc6621f505a..737a4e90d5ed 100644 --- a/master/buildbot/test/integration/test_configs.py +++ b/master/buildbot/test/integration/test_configs.py @@ -32,9 +32,6 @@ def setUp(self): self.basedir = os.path.abspath('basedir') self.filename = os.path.abspath("test.cfg") - def tearDown(self): - self.tearDownDirs() - def test_sample_config(self): filename = util.sibpath(runner.__file__, 'sample.cfg') with assertNotProducesWarnings(DeprecatedApiWarning): diff --git a/master/buildbot/test/integration/test_telegram_bot.py b/master/buildbot/test/integration/test_telegram_bot.py index 30c7bf2519c1..92f42e9ae867 100644 --- a/master/buildbot/test/integration/test_telegram_bot.py +++ b/master/buildbot/test/integration/test_telegram_bot.py @@ -156,7 +156,6 @@ def send_message(chat, message, **kwargs): @defer.inlineCallbacks def tearDown(self): - self.tearDownDirs() if self.master: yield self.master.www.stopService() yield self.master.mq.stopService() diff --git a/master/buildbot/test/unit/changes/test_mail.py b/master/buildbot/test/unit/changes/test_mail.py index ee8788795abd..bc334b2f40a4 100644 --- a/master/buildbot/test/unit/changes/test_mail.py +++ b/master/buildbot/test/unit/changes/test_mail.py @@ -54,7 +54,6 @@ def assertMailProcessed(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownDirs() yield self.tearDownChangeSource() yield self.tear_down_test_reactor() diff --git a/master/buildbot/test/unit/config/test_master.py b/master/buildbot/test/unit/config/test_master.py index 61d050b894a5..4657301d0e8d 100644 --- a/master/buildbot/test/unit/config/test_master.py +++ b/master/buildbot/test/unit/config/test_master.py @@ -113,9 +113,6 @@ def setUp(self): return self.setUpDirs('basedir') - def tearDown(self): - return self.tearDownDirs() - def install_config_file(self, config_file, other_files=None): if other_files is None: other_files = {} @@ -207,9 +204,6 @@ def setUp(self): self.filename = os.path.join(self.basedir, 'test.cfg') return self.setUpDirs('basedir') - def tearDown(self): - return self.tearDownDirs() - # utils def patch_load_helpers(self): diff --git a/master/buildbot/test/unit/schedulers/test_trysched.py b/master/buildbot/test/unit/schedulers/test_trysched.py index 614df8acd84a..8ba53d912fdd 100644 --- a/master/buildbot/test/unit/schedulers/test_trysched.py +++ b/master/buildbot/test/unit/schedulers/test_trysched.py @@ -101,9 +101,6 @@ def setUp(self): self.tmpdir = os.path.join(self.jobdir, 'tmp') self.setUpDirs(self.jobdir, self.newdir, self.curdir, self.tmpdir) - def tearDown(self): - self.tearDownDirs() - def test_messageReceived(self): # stub out svc.scheduler.handleJobFile and .jobdir scheduler = mock.Mock() diff --git a/master/buildbot/test/unit/scripts/test_base.py b/master/buildbot/test/unit/scripts/test_base.py index 03c019ea2535..9c8f6a72a568 100644 --- a/master/buildbot/test/unit/scripts/test_base.py +++ b/master/buildbot/test/unit/scripts/test_base.py @@ -187,9 +187,6 @@ def setUp(self): self.home = os.path.abspath('home') self.setUpStdoutAssertions() - def tearDown(self): - self.tearDownDirs() - def do_loadOptionsFile(self, _here, exp): # only patch these os.path functions briefly, to # avoid breaking other parts of the test system @@ -283,9 +280,6 @@ def setUp(self): self.setUpDirs('test') self.setUpStdoutAssertions() - def tearDown(self): - self.tearDownDirs() - def activeBasedir(self, extra_lines=()): with open(os.path.join('test', 'buildbot.tac'), "w", encoding='utf-8') as f: f.write("from twisted.application import service\n") diff --git a/master/buildbot/test/unit/scripts/test_checkconfig.py b/master/buildbot/test/unit/scripts/test_checkconfig.py index 727c75828a2e..47b2a4b5cdb9 100644 --- a/master/buildbot/test/unit/scripts/test_checkconfig.py +++ b/master/buildbot/test/unit/scripts/test_checkconfig.py @@ -33,9 +33,6 @@ def setUp(self): self.configdir = self.mktemp() return self.setUpDirs(self.configdir) - def tearDown(self): - return self.tearDownDirs() - # tests def do_test_load(self, config='', other_files=None, stdout_re=None, stderr_re=None): diff --git a/master/buildbot/test/unit/scripts/test_cleanupdb.py b/master/buildbot/test/unit/scripts/test_cleanupdb.py index caf25d748081..c96069b1b45b 100644 --- a/master/buildbot/test/unit/scripts/test_cleanupdb.py +++ b/master/buildbot/test/unit/scripts/test_cleanupdb.py @@ -94,7 +94,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownDirs() yield self.tear_down_test_reactor() def createMasterCfg(self, extraconfig=""): @@ -139,7 +138,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownDirs() yield self.tear_down_test_reactor() def createMasterCfg(self, db_url, extraconfig=""): diff --git a/master/buildbot/test/unit/scripts/test_copydb.py b/master/buildbot/test/unit/scripts/test_copydb.py index cb91ddf46253..2f680e722f39 100644 --- a/master/buildbot/test/unit/scripts/test_copydb.py +++ b/master/buildbot/test/unit/scripts/test_copydb.py @@ -64,7 +64,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownDirs() yield self.tear_down_test_reactor() def create_master_cfg(self, db_url='sqlite://', extraconfig=""): @@ -113,9 +112,6 @@ def setUp(self): self.setUpStdoutAssertions() # comment out to see stdout from script write_buildbot_tac(os.path.join('basedir', 'buildbot.tac')) - def tearDown(self): - self.tearDownDirs() - @defer.inlineCallbacks def create_master_config(self): f = BuildFactory() diff --git a/master/buildbot/test/unit/scripts/test_create_master.py b/master/buildbot/test/unit/scripts/test_create_master.py index b3171d419e76..3edf9831a396 100644 --- a/master/buildbot/test/unit/scripts/test_create_master.py +++ b/master/buildbot/test/unit/scripts/test_create_master.py @@ -98,7 +98,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownDirs() yield self.tear_down_test_reactor() def assertInTacFile(self, str): diff --git a/master/buildbot/test/unit/scripts/test_logwatcher.py b/master/buildbot/test/unit/scripts/test_logwatcher.py index e9fdd2d8704b..a4952bc08969 100644 --- a/master/buildbot/test/unit/scripts/test_logwatcher.py +++ b/master/buildbot/test/unit/scripts/test_logwatcher.py @@ -46,7 +46,6 @@ class TestLogWatcher(unittest.TestCase, dirs.DirsMixin, TestReactorMixin): def setUp(self): self.setUpDirs('workdir') - self.addCleanup(self.tearDownDirs) self.setup_test_reactor(auto_tear_down=False) self.spawned_process = mock.Mock() diff --git a/master/buildbot/test/unit/scripts/test_restart.py b/master/buildbot/test/unit/scripts/test_restart.py index 9150a9cbab5e..f8cdca18e3b3 100644 --- a/master/buildbot/test/unit/scripts/test_restart.py +++ b/master/buildbot/test/unit/scripts/test_restart.py @@ -37,9 +37,6 @@ def setUp(self): f.write("Application('buildmaster')") self.setUpStdoutAssertions() - def tearDown(self): - self.tearDownDirs() - # tests def test_restart_not_basedir(self): diff --git a/master/buildbot/test/unit/scripts/test_start.py b/master/buildbot/test/unit/scripts/test_start.py index 7414fb00d79b..63bda79c6231 100644 --- a/master/buildbot/test/unit/scripts/test_start.py +++ b/master/buildbot/test/unit/scripts/test_start.py @@ -65,9 +65,6 @@ def setUp(self): f.write(fake_master_tac) self.setUpStdoutAssertions() - def tearDown(self): - self.tearDownDirs() - # tests def test_start_not_basedir(self): diff --git a/master/buildbot/test/unit/scripts/test_stop.py b/master/buildbot/test/unit/scripts/test_stop.py index 63ae70cbb2ee..cd1198d6015f 100644 --- a/master/buildbot/test/unit/scripts/test_stop.py +++ b/master/buildbot/test/unit/scripts/test_stop.py @@ -37,9 +37,6 @@ def setUp(self): self.setUpDirs('basedir') self.setUpStdoutAssertions() - def tearDown(self): - self.tearDownDirs() - # tests def do_test_stop(self, config, kill_sequence, is_running=True, **kwargs): diff --git a/master/buildbot/test/unit/scripts/test_upgrade_master.py b/master/buildbot/test/unit/scripts/test_upgrade_master.py index 0f273e02ced4..692076289418 100644 --- a/master/buildbot/test/unit/scripts/test_upgrade_master.py +++ b/master/buildbot/test/unit/scripts/test_upgrade_master.py @@ -121,7 +121,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownDirs() yield self.tear_down_test_reactor() def writeFile(self, path, contents): diff --git a/master/buildbot/test/unit/test_master.py b/master/buildbot/test/unit/test_master.py index a4b7742d3396..b6f7d53963b0 100644 --- a/master/buildbot/test/unit/test_master.py +++ b/master/buildbot/test/unit/test_master.py @@ -111,7 +111,6 @@ def setUp(self): def tearDown(self): if self.db.pool is not None: yield self.db.pool.stop() - yield self.tearDownDirs() yield self.tear_down_test_reactor() # tests diff --git a/master/buildbot/test/unit/util/test_maildir.py b/master/buildbot/test/unit/util/test_maildir.py index 7c822d4eafb2..a6b7f763c1b9 100644 --- a/master/buildbot/test/unit/util/test_maildir.py +++ b/master/buildbot/test/unit/util/test_maildir.py @@ -36,7 +36,6 @@ def setUp(self): def tearDown(self): if self.svc and self.svc.running: self.svc.stopService() - self.tearDownDirs() # tests diff --git a/master/buildbot/test/util/dirs.py b/master/buildbot/test/util/dirs.py index cef84dd1cb37..115b7c0acc73 100644 --- a/master/buildbot/test/util/dirs.py +++ b/master/buildbot/test/util/dirs.py @@ -31,12 +31,13 @@ def setUpDirs(self, *dirs): if os.path.exists(dir): shutil.rmtree(dir) os.makedirs(dir) - # return a deferred to make chaining easier - return defer.succeed(None) - def tearDownDirs(self): - for dir in self._dirs: - if os.path.exists(dir): - shutil.rmtree(dir) + def cleanup(): + for dir in self._dirs: + if os.path.exists(dir): + shutil.rmtree(dir) + + self.addCleanup(cleanup) + # return a deferred to make chaining easier return defer.succeed(None) diff --git a/master/buildbot/test/util/migration.py b/master/buildbot/test/util/migration.py index 1f8d71438a9c..f3f8056b9fac 100644 --- a/master/buildbot/test/util/migration.py +++ b/master/buildbot/test/util/migration.py @@ -55,7 +55,6 @@ def setUpMigrateTest(self): @defer.inlineCallbacks def tearDownMigrateTest(self): - self.tearDownDirs() yield self.tear_down_test_reactor() @defer.inlineCallbacks From d4c9c6df31cf9a2392692202fd2eeddb38652698 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:30 +0200 Subject: [PATCH 02/18] test: Automatically tear down upgrade test --- master/buildbot/test/integration/test_upgrade.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/master/buildbot/test/integration/test_upgrade.py b/master/buildbot/test/integration/test_upgrade.py index 93752eee7932..d0645d3e1d72 100644 --- a/master/buildbot/test/integration/test_upgrade.py +++ b/master/buildbot/test/integration/test_upgrade.py @@ -90,9 +90,7 @@ def setUpUpgradeTest(self): ) self._sql_log_handler = querylog.start_log_queries() - - def tearDownUpgradeTest(self): - querylog.stop_log_queries(self._sql_log_handler) + self.addCleanup(lambda: querylog.stop_log_queries(self._sql_log_handler)) # save subclasses the trouble of calling our setUp and tearDown methods @@ -102,7 +100,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownUpgradeTest() yield self.tear_down_test_reactor() @defer.inlineCallbacks From ca7f20b8cdc8192388ba370d9193a88a45fa119a Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:31 +0200 Subject: [PATCH 03/18] test: Tear down ChangeSourceMixin automatically --- master/buildbot/test/unit/changes/test_base.py | 2 -- .../test/unit/changes/test_bitbucket.py | 1 - .../unit/changes/test_gerritchangesource.py | 14 +++++++++----- .../buildbot/test/unit/changes/test_github.py | 1 - .../test/unit/changes/test_gitpoller.py | 3 --- .../test/unit/changes/test_hgpoller.py | 4 ---- master/buildbot/test/unit/changes/test_mail.py | 1 - .../test/unit/changes/test_p4poller.py | 1 - master/buildbot/test/unit/changes/test_pb.py | 1 - .../test/unit/changes/test_svnpoller.py | 1 - master/buildbot/test/util/changesource.py | 18 +++++++++--------- 11 files changed, 18 insertions(+), 29 deletions(-) diff --git a/master/buildbot/test/unit/changes/test_base.py b/master/buildbot/test/unit/changes/test_base.py index e5d1b74ac9e0..91f30d8e403f 100644 --- a/master/buildbot/test/unit/changes/test_base.py +++ b/master/buildbot/test/unit/changes/test_base.py @@ -37,7 +37,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -92,7 +91,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/changes/test_bitbucket.py b/master/buildbot/test/unit/changes/test_bitbucket.py index 18c7f37ead4f..88143c33a913 100644 --- a/master/buildbot/test/unit/changes/test_bitbucket.py +++ b/master/buildbot/test/unit/changes/test_bitbucket.py @@ -306,7 +306,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() def _fakeGetPage(self, result): diff --git a/master/buildbot/test/unit/changes/test_gerritchangesource.py b/master/buildbot/test/unit/changes/test_gerritchangesource.py index d6ee18effd0a..54dd820d4405 100644 --- a/master/buildbot/test/unit/changes/test_gerritchangesource.py +++ b/master/buildbot/test/unit/changes/test_gerritchangesource.py @@ -97,17 +97,22 @@ class TestGerritChangeSource( TestReactorMixin, unittest.TestCase, ): + @defer.inlineCallbacks def setUp(self): self.setup_test_reactor(auto_tear_down=False) self.setup_master_run_process() self._got_events = [] - return self.setUpChangeSource() + yield self.setUpChangeSource() + + @defer.inlineCallbacks + def cleanup(): + if self.master.running: + yield self.stopChangeSource() + + self.addCleanup(cleanup) @defer.inlineCallbacks def tearDown(self): - if self.master.running: - yield self.stopChangeSource() - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1059,7 +1064,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): yield self.master.stopService() - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/changes/test_github.py b/master/buildbot/test/unit/changes/test_github.py index f1977376625b..d4fceed446d9 100644 --- a/master/buildbot/test/unit/changes/test_github.py +++ b/master/buildbot/test/unit/changes/test_github.py @@ -196,7 +196,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): yield self.master.stopService() - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/changes/test_gitpoller.py b/master/buildbot/test/unit/changes/test_gitpoller.py index 3c68c7cfa9aa..213e4e140741 100644 --- a/master/buildbot/test/unit/changes/test_gitpoller.py +++ b/master/buildbot/test/unit/changes/test_gitpoller.py @@ -73,7 +73,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): yield self.master.stopService() - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @async_to_deferred @@ -2428,7 +2427,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): yield self.master.stopService() - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -2601,7 +2599,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): yield self.master.stopService() - yield self.tearDownChangeSource() def _delete_repository(repo_path: Path): # on Win, git will mark objects as read-only diff --git a/master/buildbot/test/unit/changes/test_hgpoller.py b/master/buildbot/test/unit/changes/test_hgpoller.py index 2d1b6e55a02f..825de11d51d0 100644 --- a/master/buildbot/test/unit/changes/test_hgpoller.py +++ b/master/buildbot/test/unit/changes/test_hgpoller.py @@ -65,7 +65,6 @@ def _isRepositoryReady(): @defer.inlineCallbacks def tearDown(self): yield self.master.stopService() - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -271,9 +270,6 @@ def test_poll_regular(self): class TestHgPoller(TestHgPollerBase): - def tearDown(self): - return self.tearDownChangeSource() - def gpoFullcommandPattern(self, commandName, *expected_args): """Match if the command is commandName and arg list start as expected. diff --git a/master/buildbot/test/unit/changes/test_mail.py b/master/buildbot/test/unit/changes/test_mail.py index bc334b2f40a4..29225fdd394f 100644 --- a/master/buildbot/test/unit/changes/test_mail.py +++ b/master/buildbot/test/unit/changes/test_mail.py @@ -54,7 +54,6 @@ def assertMailProcessed(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() # tests diff --git a/master/buildbot/test/unit/changes/test_p4poller.py b/master/buildbot/test/unit/changes/test_p4poller.py index a75c5d2c9199..01fe6086b610 100644 --- a/master/buildbot/test/unit/changes/test_p4poller.py +++ b/master/buildbot/test/unit/changes/test_p4poller.py @@ -115,7 +115,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() def add_p4_describe_result(self, number, result): diff --git a/master/buildbot/test/unit/changes/test_pb.py b/master/buildbot/test/unit/changes/test_pb.py index 4d189442be05..c3895496c02c 100644 --- a/master/buildbot/test/unit/changes/test_pb.py +++ b/master/buildbot/test/unit/changes/test_pb.py @@ -48,7 +48,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() def test_registration_no_workerport(self): diff --git a/master/buildbot/test/unit/changes/test_svnpoller.py b/master/buildbot/test/unit/changes/test_svnpoller.py index cfab8c03a5ce..d3131cdbaba1 100644 --- a/master/buildbot/test/unit/changes/test_svnpoller.py +++ b/master/buildbot/test/unit/changes/test_svnpoller.py @@ -265,7 +265,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownChangeSource() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/util/changesource.py b/master/buildbot/test/util/changesource.py index 8b8cc667bbd5..e6e2c04ff68f 100644 --- a/master/buildbot/test/util/changesource.py +++ b/master/buildbot/test/util/changesource.py @@ -42,15 +42,15 @@ def setUpChangeSource(self, want_real_reactor: bool = False): ) assert not hasattr(self.master, 'addChange') # just checking.. - @defer.inlineCallbacks - def tearDownChangeSource(self): - "Tear down the mixin - returns a deferred." - if not self.started: - return - if self.changesource.running: - yield self.changesource.stopService() - yield self.changesource.disownServiceParent() - return + @defer.inlineCallbacks + def cleanup(): + if not self.started: + return + if self.changesource.running: + yield self.changesource.stopService() + yield self.changesource.disownServiceParent() + + self.addCleanup(cleanup) @defer.inlineCallbacks def attachChangeSource(self, cs): From 5195ce7af3a09c7f2d55eb11a731d541f6cfff30 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:32 +0200 Subject: [PATCH 04/18] test: Remove test code that never runs in Gerrit change source tests --- .../buildbot/test/unit/changes/test_gerritchangesource.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/master/buildbot/test/unit/changes/test_gerritchangesource.py b/master/buildbot/test/unit/changes/test_gerritchangesource.py index 54dd820d4405..7f5b8923da75 100644 --- a/master/buildbot/test/unit/changes/test_gerritchangesource.py +++ b/master/buildbot/test/unit/changes/test_gerritchangesource.py @@ -104,13 +104,6 @@ def setUp(self): self._got_events = [] yield self.setUpChangeSource() - @defer.inlineCallbacks - def cleanup(): - if self.master.running: - yield self.stopChangeSource() - - self.addCleanup(cleanup) - @defer.inlineCallbacks def tearDown(self): yield self.tear_down_test_reactor() From bb8dfbf2f9162dc0b58febf342246f2227cada63 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:33 +0200 Subject: [PATCH 05/18] test: Remove unused empty SchedulerMixin.tearDownScheduler() --- master/buildbot/test/unit/schedulers/test_base.py | 1 - master/buildbot/test/unit/schedulers/test_basic.py | 3 --- master/buildbot/test/unit/schedulers/test_dependent.py | 1 - master/buildbot/test/unit/schedulers/test_forcesched.py | 1 - master/buildbot/test/unit/schedulers/test_timed_Nightly.py | 1 - .../buildbot/test/unit/schedulers/test_timed_NightlyBase.py | 1 - .../test/unit/schedulers/test_timed_NightlyTriggerable.py | 1 - master/buildbot/test/unit/schedulers/test_timed_Periodic.py | 1 - master/buildbot/test/unit/schedulers/test_timed_Timed.py | 1 - master/buildbot/test/unit/schedulers/test_triggerable.py | 1 - master/buildbot/test/unit/schedulers/test_trysched.py | 4 ---- master/buildbot/test/util/scheduler.py | 3 --- 12 files changed, 19 deletions(-) diff --git a/master/buildbot/test/unit/schedulers/test_base.py b/master/buildbot/test/unit/schedulers/test_base.py index 628f3dc12070..57543190109f 100644 --- a/master/buildbot/test/unit/schedulers/test_base.py +++ b/master/buildbot/test/unit/schedulers/test_base.py @@ -42,7 +42,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/schedulers/test_basic.py b/master/buildbot/test/unit/schedulers/test_basic.py index 76a21f55bb8a..44460a6dee13 100644 --- a/master/buildbot/test/unit/schedulers/test_basic.py +++ b/master/buildbot/test/unit/schedulers/test_basic.py @@ -107,7 +107,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -385,7 +384,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -629,7 +627,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() def test_constructor_branch_forbidden(self): diff --git a/master/buildbot/test/unit/schedulers/test_dependent.py b/master/buildbot/test/unit/schedulers/test_dependent.py index 5334ab2ae9b1..ba61f7a4470b 100644 --- a/master/buildbot/test/unit/schedulers/test_dependent.py +++ b/master/buildbot/test/unit/schedulers/test_dependent.py @@ -43,7 +43,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/schedulers/test_forcesched.py b/master/buildbot/test/unit/schedulers/test_forcesched.py index edd37c77e3fe..5d78e7de696a 100644 --- a/master/buildbot/test/unit/schedulers/test_forcesched.py +++ b/master/buildbot/test/unit/schedulers/test_forcesched.py @@ -53,7 +53,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/schedulers/test_timed_Nightly.py b/master/buildbot/test/unit/schedulers/test_timed_Nightly.py index da75226b84bd..45c2369d62c1 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_Nightly.py +++ b/master/buildbot/test/unit/schedulers/test_timed_Nightly.py @@ -124,7 +124,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() def assertConsumingChanges(self, **kwargs): diff --git a/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py b/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py index 3fd200a30269..8e2b0502feac 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py +++ b/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py @@ -36,7 +36,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() def makeScheduler(self, firstBuildDuration=0, **kwargs): diff --git a/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py b/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py index 0f780873c77a..f7d953da5724 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py +++ b/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py @@ -53,7 +53,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() # utilities diff --git a/master/buildbot/test/unit/schedulers/test_timed_Periodic.py b/master/buildbot/test/unit/schedulers/test_timed_Periodic.py index 6a8b54e464ea..f8e79b16aa1b 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_Periodic.py +++ b/master/buildbot/test/unit/schedulers/test_timed_Periodic.py @@ -38,7 +38,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/schedulers/test_timed_Timed.py b/master/buildbot/test/unit/schedulers/test_timed_Timed.py index 6545faf4fff6..113dd5c18ae8 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_Timed.py +++ b/master/buildbot/test/unit/schedulers/test_timed_Timed.py @@ -32,7 +32,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() class Subclass(timed.Timed): diff --git a/master/buildbot/test/unit/schedulers/test_triggerable.py b/master/buildbot/test/unit/schedulers/test_triggerable.py index 6b2645dad2dc..e57c502b09df 100644 --- a/master/buildbot/test/unit/schedulers/test_triggerable.py +++ b/master/buildbot/test/unit/schedulers/test_triggerable.py @@ -47,7 +47,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/schedulers/test_trysched.py b/master/buildbot/test/unit/schedulers/test_trysched.py index 8ba53d912fdd..1a3c639efc2f 100644 --- a/master/buildbot/test/unit/schedulers/test_trysched.py +++ b/master/buildbot/test/unit/schedulers/test_trysched.py @@ -40,7 +40,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() def makeScheduler(self, **kwargs): @@ -135,7 +134,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() if self.jobdir: shutil.rmtree(self.jobdir) yield self.tear_down_test_reactor() @@ -883,7 +881,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() def makeScheduler(self, **kwargs): @@ -1062,7 +1059,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownScheduler() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/util/scheduler.py b/master/buildbot/test/util/scheduler.py index 9b744177b6be..6e61963c7045 100644 --- a/master/buildbot/test/util/scheduler.py +++ b/master/buildbot/test/util/scheduler.py @@ -46,9 +46,6 @@ class SchedulerMixin(interfaces.InterfaceTests): def setUpScheduler(self): self.master = yield fakemaster.make_master(self, wantDb=True, wantMq=True, wantData=True) - def tearDownScheduler(self): - pass - @defer.inlineCallbacks def attachScheduler( self, scheduler, objectid, schedulerid, overrideBuildsetMethods=False, createBuilderDB=False From f437fbb2f1d3508dfb7bfc3cb1beee7bf5b1b4c2 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:34 +0200 Subject: [PATCH 06/18] test: Remove uses of TestBuildStepMixin.tear_down_test_build_step() --- master/buildbot/test/unit/process/test_buildstep.py | 3 --- master/buildbot/test/unit/steps/test_cmake.py | 1 - master/buildbot/test/unit/steps/test_cppcheck.py | 1 - master/buildbot/test/unit/steps/test_http.py | 1 - master/buildbot/test/unit/steps/test_master.py | 5 ----- master/buildbot/test/unit/steps/test_maxq.py | 1 - master/buildbot/test/unit/steps/test_mswin.py | 1 - .../test/unit/steps/test_package_deb_lintian.py | 1 - .../test/unit/steps/test_package_deb_pbuilder.py | 4 ---- .../test/unit/steps/test_package_rpm_mock.py | 5 ----- .../test/unit/steps/test_package_rpm_rpmbuild.py | 1 - .../test/unit/steps/test_package_rpm_rpmlint.py | 1 - master/buildbot/test/unit/steps/test_python.py | 4 ---- .../buildbot/test/unit/steps/test_python_twisted.py | 3 --- master/buildbot/test/unit/steps/test_renderable.py | 1 - master/buildbot/test/unit/steps/test_shell.py | 8 -------- .../buildbot/test/unit/steps/test_shellsequence.py | 5 +---- .../test/unit/steps/test_source_base_Source.py | 3 --- master/buildbot/test/unit/steps/test_source_git.py | 11 ++--------- master/buildbot/test/unit/steps/test_subunit.py | 1 - master/buildbot/test/unit/steps/test_transfer.py | 7 ------- master/buildbot/test/unit/steps/test_trigger.py | 1 - master/buildbot/test/unit/steps/test_vstudio.py | 12 ------------ master/buildbot/test/unit/steps/test_worker.py | 6 ------ .../test/unit/test_download_secret_to_worker.py | 3 --- .../buildbot/test/unit/test_janitor_configurator.py | 1 - master/buildbot/test/unit/test_steps_git_diffinfo.py | 1 - master/buildbot/test/unit/test_steps_mixin.py | 1 - master/buildbot/test/util/sourcesteps.py | 2 +- 29 files changed, 4 insertions(+), 91 deletions(-) diff --git a/master/buildbot/test/unit/process/test_buildstep.py b/master/buildbot/test/unit/process/test_buildstep.py index 7cf85e36bf28..95702457521c 100644 --- a/master/buildbot/test/unit/process/test_buildstep.py +++ b/master/buildbot/test/unit/process/test_buildstep.py @@ -120,7 +120,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() # support @@ -1125,7 +1124,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1243,7 +1241,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_setupShellMixin_bad_arg(self): diff --git a/master/buildbot/test/unit/steps/test_cmake.py b/master/buildbot/test/unit/steps/test_cmake.py index d40f760352e7..aba36c91a7ea 100644 --- a/master/buildbot/test/unit/steps/test_cmake.py +++ b/master/buildbot/test/unit/steps/test_cmake.py @@ -33,7 +33,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def expect_and_run_command(self, *params): diff --git a/master/buildbot/test/unit/steps/test_cppcheck.py b/master/buildbot/test/unit/steps/test_cppcheck.py index 3a8940633619..48f4c50dcd7d 100644 --- a/master/buildbot/test/unit/steps/test_cppcheck.py +++ b/master/buildbot/test/unit/steps/test_cppcheck.py @@ -33,7 +33,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_success(self): diff --git a/master/buildbot/test/unit/steps/test_http.py b/master/buildbot/test/unit/steps/test_http.py index fd139603089d..62e04522cb35 100644 --- a/master/buildbot/test/unit/steps/test_http.py +++ b/master/buildbot/test/unit/steps/test_http.py @@ -88,7 +88,6 @@ def tearDown(self): yield self.site.stopFactory() yield self.site.close_connections() finally: - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def get_connection_string(self): diff --git a/master/buildbot/test/unit/steps/test_master.py b/master/buildbot/test/unit/steps/test_master.py index 3e79ee2566f0..0b350750ead0 100644 --- a/master/buildbot/test/unit/steps/test_master.py +++ b/master/buildbot/test/unit/steps/test_master.py @@ -49,7 +49,6 @@ def tearDown(self): os.environ[_COMSPEC_ENV] = self.comspec else: del os.environ[_COMSPEC_ENV] - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_constr_args(self): @@ -175,7 +174,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_simple(self): @@ -199,7 +197,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_simple(self): @@ -222,7 +219,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def doOneTest(self, **kwargs): @@ -255,7 +251,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_eq_pass(self): diff --git a/master/buildbot/test/unit/steps/test_maxq.py b/master/buildbot/test/unit/steps/test_maxq.py index a548c422141e..7aaf40707c9c 100644 --- a/master/buildbot/test/unit/steps/test_maxq.py +++ b/master/buildbot/test/unit/steps/test_maxq.py @@ -32,7 +32,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_testdir_required(self): diff --git a/master/buildbot/test/unit/steps/test_mswin.py b/master/buildbot/test/unit/steps/test_mswin.py index 42314014f674..258092ff4c0a 100644 --- a/master/buildbot/test/unit/steps/test_mswin.py +++ b/master/buildbot/test/unit/steps/test_mswin.py @@ -40,7 +40,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def _run_simple_test( diff --git a/master/buildbot/test/unit/steps/test_package_deb_lintian.py b/master/buildbot/test/unit/steps/test_package_deb_lintian.py index 52910777aab2..c73c63463681 100644 --- a/master/buildbot/test/unit/steps/test_package_deb_lintian.py +++ b/master/buildbot/test/unit/steps/test_package_deb_lintian.py @@ -31,7 +31,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_no_fileloc(self): diff --git a/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py b/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py index 03f059dd71e3..46ad7edfd9fa 100644 --- a/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py +++ b/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py @@ -36,7 +36,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_new(self): @@ -496,7 +495,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_new(self): @@ -649,7 +647,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_no_distribution(self): @@ -703,7 +700,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_no_distribution(self): diff --git a/master/buildbot/test/unit/steps/test_package_rpm_mock.py b/master/buildbot/test/unit/steps/test_package_rpm_mock.py index 22a3022c2734..885d9ef428b7 100644 --- a/master/buildbot/test/unit/steps/test_package_rpm_mock.py +++ b/master/buildbot/test/unit/steps/test_package_rpm_mock.py @@ -31,9 +31,6 @@ def setUp(self): self.setup_test_reactor(auto_tear_down=False) return self.setup_test_build_step() - def tearDown(self): - return self.tear_down_test_build_step() - def test_no_root(self): with self.assertRaises(config.ConfigErrors): mock.Mock() @@ -114,7 +111,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_no_spec(self): @@ -157,7 +153,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_no_srpm(self): diff --git a/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py b/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py index fbca59aa42f3..7893841e9d51 100644 --- a/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py +++ b/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py @@ -35,7 +35,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_no_specfile(self): diff --git a/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py b/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py index d633b126a301..2ec0e82e337f 100644 --- a/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py +++ b/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py @@ -30,7 +30,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_success(self): diff --git a/master/buildbot/test/unit/steps/test_python.py b/master/buildbot/test/unit/steps/test_python.py index 437af94a89ca..8329a1fb0220 100644 --- a/master/buildbot/test/unit/steps/test_python.py +++ b/master/buildbot/test/unit/steps/test_python.py @@ -130,7 +130,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_sample(self): @@ -149,7 +148,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @parameterized.expand([('no_results', True), ('with_results', False)]) @@ -448,7 +446,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_success(self): @@ -536,7 +533,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_builddir_required(self): diff --git a/master/buildbot/test/unit/steps/test_python_twisted.py b/master/buildbot/test/unit/steps/test_python_twisted.py index 0c5366596d81..44475fd60b79 100644 --- a/master/buildbot/test/unit/steps/test_python_twisted.py +++ b/master/buildbot/test/unit/steps/test_python_twisted.py @@ -99,7 +99,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_run_env(self): @@ -405,7 +404,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_run_ok(self): @@ -476,7 +474,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_run_ok(self): diff --git a/master/buildbot/test/unit/steps/test_renderable.py b/master/buildbot/test/unit/steps/test_renderable.py index d24407cfb696..0ace8fd96a7f 100644 --- a/master/buildbot/test/unit/steps/test_renderable.py +++ b/master/buildbot/test/unit/steps/test_renderable.py @@ -38,7 +38,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_name_is_renderable(self): diff --git a/master/buildbot/test/unit/steps/test_shell.py b/master/buildbot/test/unit/steps/test_shell.py index f8cf6e7951d9..23a853f9762e 100644 --- a/master/buildbot/test/unit/steps/test_shell.py +++ b/master/buildbot/test/unit/steps/test_shell.py @@ -45,7 +45,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_doStepIf_False(self): @@ -187,7 +186,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_run_success(self): @@ -225,7 +223,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_constructor_conflict(self): @@ -360,7 +357,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_new_version_success(self): @@ -475,7 +471,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_class_attrs(self): @@ -499,7 +494,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_no_warnings(self): @@ -829,7 +823,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_class_args(self): @@ -851,7 +844,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_setTestResults(self): diff --git a/master/buildbot/test/unit/steps/test_shellsequence.py b/master/buildbot/test/unit/steps/test_shellsequence.py index e8b84b599f14..f4f046e1f1a2 100644 --- a/master/buildbot/test/unit/steps/test_shellsequence.py +++ b/master/buildbot/test/unit/steps/test_shellsequence.py @@ -38,12 +38,9 @@ class TestOneShellCommand( TestBuildStepMixin, configmixin.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor(auto_tear_down=True) return self.setup_test_build_step() - def tearDown(self): - return self.tear_down_test_build_step() - def testShellArgInput(self): with self.assertRaisesConfigError("the 'command' parameter of ShellArg must not be None"): shellsequence.ShellArg(command=None) diff --git a/master/buildbot/test/unit/steps/test_source_base_Source.py b/master/buildbot/test/unit/steps/test_source_base_Source.py index 6efd4e437b4e..cf6ba0bd830a 100644 --- a/master/buildbot/test/unit/steps/test_source_base_Source.py +++ b/master/buildbot/test/unit/steps/test_source_base_Source.py @@ -37,7 +37,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def setup_deferred_mock(self): @@ -175,7 +174,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_constructor_args_strings(self): @@ -213,7 +211,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_attrgroup_hasattr(self): diff --git a/master/buildbot/test/unit/steps/test_source_git.py b/master/buildbot/test/unit/steps/test_source_git.py index 76923e916433..825ea953915c 100644 --- a/master/buildbot/test/unit/steps/test_source_git.py +++ b/master/buildbot/test/unit/steps/test_source_git.py @@ -4183,12 +4183,9 @@ class TestGitPush( stepClass = git.GitPush def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor(auto_tear_down=True) return self.setup_test_build_step() - def tearDown(self): - return self.tear_down_test_build_step() - @parameterized.expand([ ('url', 'ssh://github.com/test/test.git', 'ssh://github.com/test/test.git'), ('host_path', 'host:path/to/git', 'ssh://host:22/path/to/git'), @@ -4664,12 +4661,9 @@ class TestGitTag(TestBuildStepMixin, config.ConfigErrorsMixin, TestReactorMixin, stepClass = git.GitTag def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor(auto_tear_down=True) return self.setup_test_build_step() - def tearDown(self): - return self.tear_down_test_build_step() - def test_tag_annotated(self): messages = ['msg1', 'msg2'] @@ -4768,7 +4762,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_add_fail(self): diff --git a/master/buildbot/test/unit/steps/test_subunit.py b/master/buildbot/test/unit/steps/test_subunit.py index 6ae22bbc245d..cf77c2bd4d08 100644 --- a/master/buildbot/test/unit/steps/test_subunit.py +++ b/master/buildbot/test/unit/steps/test_subunit.py @@ -61,7 +61,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_empty(self): diff --git a/master/buildbot/test/unit/steps/test_transfer.py b/master/buildbot/test/unit/steps/test_transfer.py index 85ee4843cefc..fe25e955dae8 100644 --- a/master/buildbot/test/unit/steps/test_transfer.py +++ b/master/buildbot/test/unit/steps/test_transfer.py @@ -53,7 +53,6 @@ def setUp(self): def tearDown(self): if os.path.exists(self.destfile): os.unlink(self.destfile) - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def testConstructorModeType(self): @@ -323,7 +322,6 @@ def tearDown(self): if os.path.exists(self.destdir): shutil.rmtree(self.destdir) - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def testBasic(self): @@ -509,7 +507,6 @@ def tearDown(self): if os.path.exists(self.destdir): shutil.rmtree(self.destdir) - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def testEmpty(self): @@ -953,7 +950,6 @@ def tearDown(self): if os.path.exists(self.destfile): os.unlink(self.destfile) - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_init_workerdest_keyword(self): @@ -1060,7 +1056,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() # check that ConfigErrors is raised on invalid 'mode' argument @@ -1170,7 +1165,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1273,7 +1267,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/steps/test_trigger.py b/master/buildbot/test/unit/steps/test_trigger.py index 84d1757f8dde..ef97df2bab02 100644 --- a/master/buildbot/test/unit/steps/test_trigger.py +++ b/master/buildbot/test/unit/steps/test_trigger.py @@ -105,7 +105,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/steps/test_vstudio.py b/master/buildbot/test/unit/steps/test_vstudio.py index 1fb64daa743c..f2bb9e814f3c 100644 --- a/master/buildbot/test/unit/steps/test_vstudio.py +++ b/master/buildbot/test/unit/steps/test_vstudio.py @@ -233,7 +233,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_default_config(self): @@ -356,7 +355,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def getExpectedEnv(self, installdir, LIB=None, p=None, i=None): @@ -456,7 +454,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def getExpectedEnv(self, installdir, LIB=None, p=None, i=None): @@ -593,7 +590,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_args(self): @@ -656,7 +652,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_args(self): @@ -715,7 +710,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_installdir(self): @@ -738,7 +732,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_installdir(self): @@ -761,7 +754,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_installdir(self): @@ -784,7 +776,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -888,7 +879,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1010,7 +1000,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_version_range_is_correct(self): @@ -1039,7 +1028,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_version_range_is_correct(self): diff --git a/master/buildbot/test/unit/steps/test_worker.py b/master/buildbot/test/unit/steps/test_worker.py index a5f24f985652..a73c4ba6246e 100644 --- a/master/buildbot/test/unit/steps/test_worker.py +++ b/master/buildbot/test/unit/steps/test_worker.py @@ -47,7 +47,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_simple(self): @@ -88,7 +87,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_found(self): @@ -132,7 +130,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_success(self): @@ -177,7 +174,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_success(self): @@ -207,7 +203,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_success(self): @@ -250,7 +245,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_runRemoteCommand(self): diff --git a/master/buildbot/test/unit/test_download_secret_to_worker.py b/master/buildbot/test/unit/test_download_secret_to_worker.py index 6d53bd9ec011..7cc8e13e17c3 100644 --- a/master/buildbot/test/unit/test_download_secret_to_worker.py +++ b/master/buildbot/test/unit/test_download_secret_to_worker.py @@ -46,7 +46,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def testBasic(self): @@ -90,7 +89,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def testBasic(self): @@ -132,7 +130,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def testBasic(self): diff --git a/master/buildbot/test/unit/test_janitor_configurator.py b/master/buildbot/test/unit/test_janitor_configurator.py index 8df1cf8f2168..a23d322dc971 100644 --- a/master/buildbot/test/unit/test_janitor_configurator.py +++ b/master/buildbot/test/unit/test_janitor_configurator.py @@ -74,7 +74,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/test_steps_git_diffinfo.py b/master/buildbot/test/unit/test_steps_git_diffinfo.py index 15940f90ef89..bd7082146197 100644 --- a/master/buildbot/test/unit/test_steps_git_diffinfo.py +++ b/master/buildbot/test/unit/test_steps_git_diffinfo.py @@ -38,7 +38,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() def test_merge_base_failure(self): diff --git a/master/buildbot/test/unit/test_steps_mixin.py b/master/buildbot/test/unit/test_steps_mixin.py index 97976a64c5d3..6d48ab9997ca 100644 --- a/master/buildbot/test/unit/test_steps_mixin.py +++ b/master/buildbot/test/unit/test_steps_mixin.py @@ -53,7 +53,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/util/sourcesteps.py b/master/buildbot/test/util/sourcesteps.py index 0cb3cace8b85..acedf8379b36 100644 --- a/master/buildbot/test/util/sourcesteps.py +++ b/master/buildbot/test/util/sourcesteps.py @@ -36,7 +36,7 @@ def setUpSourceStep(self): return super().setup_test_build_step() def tearDownSourceStep(self): - return super().tear_down_test_build_step() + return None # utilities From 7adcf9b8bf37f142b10173f6d5cd2a1022e62879 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:35 +0200 Subject: [PATCH 07/18] test: Deprecate TestBuildStepMixin.tear_down_test_reactor() --- master/buildbot/test/steps.py | 8 ++++++-- master/docs/manual/configuration/tests/steps.rst | 5 ----- newsfragments/tests_teardown.removal | 6 ++++++ 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 newsfragments/tests_teardown.removal diff --git a/master/buildbot/test/steps.py b/master/buildbot/test/steps.py index bf1d8542298f..fa89a364c878 100644 --- a/master/buildbot/test/steps.py +++ b/master/buildbot/test/steps.py @@ -704,8 +704,12 @@ def setup_test_build_step( self._exp_result_summaries: list[str] = [] self._exp_build_result_summaries: list[str] = [] - def tear_down_test_build_step(self): - pass + def tear_down_test_build_step(self): # pragma: no cover + warn_deprecated( + '4.2.0', + 'tear_down_test_build_step() no longer needs to be called, ' + + 'test tear down is run automatically', + ) def _setup_fake_build(self, worker_version, worker_env, build_files): if worker_version is None: diff --git a/master/docs/manual/configuration/tests/steps.rst b/master/docs/manual/configuration/tests/steps.rst index 74405982a886..e8ea94e16043 100644 --- a/master/docs/manual/configuration/tests/steps.rst +++ b/master/docs/manual/configuration/tests/steps.rst @@ -23,7 +23,6 @@ TestBuildStepMixin @defer.inlineCallbacks def tearDown(self): - yield self.tear_down_test_build_step() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -60,10 +59,6 @@ TestBuildStepMixin Call this function in the ``setUp()`` method of the test case to setup step testing machinery. - .. py:method:: tear_down_test_build_step() - - Call this function in the ``tearDown()`` of the test case to destroy step testing machinery. - .. py:method:: setup_build(worker_env=None, build_files=None) :param dict worker_env: An optional dictionary of environment variables on the mock worker. diff --git a/newsfragments/tests_teardown.removal b/newsfragments/tests_teardown.removal new file mode 100644 index 000000000000..3ca1cee404a5 --- /dev/null +++ b/newsfragments/tests_teardown.removal @@ -0,0 +1,6 @@ +The following test tear down functions have been deprecated: + + - ``TestBuildStepMixin.tear_down_test_build_step()`` + +The tear down is now run automatically. Any additional test tear down should be run using +``twisted.trial.TestCase.addCleanup`` to better control tear down ordering. From 4acd96bf0435576ab6b65fe6a87e5095d5eaa8cd Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:36 +0200 Subject: [PATCH 08/18] test: Remove empty SourceStepMixin.tearDownSourceStep() --- master/buildbot/test/unit/steps/test_source_bzr.py | 1 - master/buildbot/test/unit/steps/test_source_cvs.py | 1 - master/buildbot/test/unit/steps/test_source_darcs.py | 1 - master/buildbot/test/unit/steps/test_source_gerrit.py | 1 - master/buildbot/test/unit/steps/test_source_git.py | 1 - master/buildbot/test/unit/steps/test_source_gitlab.py | 1 - master/buildbot/test/unit/steps/test_source_mercurial.py | 1 - master/buildbot/test/unit/steps/test_source_mtn.py | 1 - master/buildbot/test/unit/steps/test_source_p4.py | 1 - master/buildbot/test/unit/steps/test_source_repo.py | 1 - master/buildbot/test/unit/steps/test_source_svn.py | 1 - master/buildbot/test/util/sourcesteps.py | 3 --- 12 files changed, 14 deletions(-) diff --git a/master/buildbot/test/unit/steps/test_source_bzr.py b/master/buildbot/test/unit/steps/test_source_bzr.py index ac5bbb9a0794..18255685aee9 100644 --- a/master/buildbot/test/unit/steps/test_source_bzr.py +++ b/master/buildbot/test/unit/steps/test_source_bzr.py @@ -43,7 +43,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def test_mode_full(self): diff --git a/master/buildbot/test/unit/steps/test_source_cvs.py b/master/buildbot/test/unit/steps/test_source_cvs.py index 199563f3ce64..4aab14969117 100644 --- a/master/buildbot/test/unit/steps/test_source_cvs.py +++ b/master/buildbot/test/unit/steps/test_source_cvs.py @@ -43,7 +43,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def setup_step(self, step, *args, **kwargs): diff --git a/master/buildbot/test/unit/steps/test_source_darcs.py b/master/buildbot/test/unit/steps/test_source_darcs.py index 393bd8c5ae10..36ff9e890f1f 100644 --- a/master/buildbot/test/unit/steps/test_source_darcs.py +++ b/master/buildbot/test/unit/steps/test_source_darcs.py @@ -39,7 +39,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def test_no_empty_step_config(self): diff --git a/master/buildbot/test/unit/steps/test_source_gerrit.py b/master/buildbot/test/unit/steps/test_source_gerrit.py index 211f9f50f79f..417431acb98c 100644 --- a/master/buildbot/test/unit/steps/test_source_gerrit.py +++ b/master/buildbot/test/unit/steps/test_source_gerrit.py @@ -35,7 +35,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def test_mode_full_clean(self): diff --git a/master/buildbot/test/unit/steps/test_source_git.py b/master/buildbot/test/unit/steps/test_source_git.py index 825ea953915c..8ecc4321ae0c 100644 --- a/master/buildbot/test/unit/steps/test_source_git.py +++ b/master/buildbot/test/unit/steps/test_source_git.py @@ -54,7 +54,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def test_mode_full_filters_2_26(self): diff --git a/master/buildbot/test/unit/steps/test_source_gitlab.py b/master/buildbot/test/unit/steps/test_source_gitlab.py index 3c6e1f0b0217..768a6fe0f80b 100644 --- a/master/buildbot/test/unit/steps/test_source_gitlab.py +++ b/master/buildbot/test/unit/steps/test_source_gitlab.py @@ -56,7 +56,6 @@ def setup_step(self, step, args, **kwargs): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def test_with_merge_branch(self): diff --git a/master/buildbot/test/unit/steps/test_source_mercurial.py b/master/buildbot/test/unit/steps/test_source_mercurial.py index 478e920d73a5..9b234784286b 100644 --- a/master/buildbot/test/unit/steps/test_source_mercurial.py +++ b/master/buildbot/test/unit/steps/test_source_mercurial.py @@ -40,7 +40,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def patch_workerVersionIsOlderThan(self, result): diff --git a/master/buildbot/test/unit/steps/test_source_mtn.py b/master/buildbot/test/unit/steps/test_source_mtn.py index b63780979362..bd3b795d74e3 100644 --- a/master/buildbot/test/unit/steps/test_source_mtn.py +++ b/master/buildbot/test/unit/steps/test_source_mtn.py @@ -47,7 +47,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def test_mode_full_clean(self): diff --git a/master/buildbot/test/unit/steps/test_source_p4.py b/master/buildbot/test/unit/steps/test_source_p4.py index e33b41a28435..93ad7852028a 100644 --- a/master/buildbot/test/unit/steps/test_source_p4.py +++ b/master/buildbot/test/unit/steps/test_source_p4.py @@ -42,7 +42,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def setup_step(self, step, args=None, patch=None, **kwargs): diff --git a/master/buildbot/test/unit/steps/test_source_repo.py b/master/buildbot/test/unit/steps/test_source_repo.py index 10f5d2f9b00c..d4a00f5a43c1 100644 --- a/master/buildbot/test/unit/steps/test_source_repo.py +++ b/master/buildbot/test/unit/steps/test_source_repo.py @@ -68,7 +68,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def shouldLogEnviron(self): diff --git a/master/buildbot/test/unit/steps/test_source_svn.py b/master/buildbot/test/unit/steps/test_source_svn.py index 921c8902c595..4bf40076d732 100644 --- a/master/buildbot/test/unit/steps/test_source_svn.py +++ b/master/buildbot/test/unit/steps/test_source_svn.py @@ -126,7 +126,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.tearDownSourceStep() yield self.tear_down_test_reactor() def patch_workerVersionIsOlderThan(self, result): diff --git a/master/buildbot/test/util/sourcesteps.py b/master/buildbot/test/util/sourcesteps.py index acedf8379b36..d4ecf2389a3c 100644 --- a/master/buildbot/test/util/sourcesteps.py +++ b/master/buildbot/test/util/sourcesteps.py @@ -35,9 +35,6 @@ class SourceStepMixin(TestBuildStepMixin): def setUpSourceStep(self): return super().setup_test_build_step() - def tearDownSourceStep(self): - return None - # utilities def setup_step(self, step, args=None, patch=None, **kwargs): From e380787d8d0a0c2c4a3229c5dae591e692d9bd77 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:37 +0200 Subject: [PATCH 09/18] test: Fix docstring for SourceStepMixin --- master/buildbot/test/util/sourcesteps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/buildbot/test/util/sourcesteps.py b/master/buildbot/test/util/sourcesteps.py index d4ecf2389a3c..f3c5b581fca8 100644 --- a/master/buildbot/test/util/sourcesteps.py +++ b/master/buildbot/test/util/sourcesteps.py @@ -26,7 +26,7 @@ class SourceStepMixin(TestBuildStepMixin): - fake sourcestamps - The following instance variables are available after C{setupSourceStep}, in + The following instance variables are available after C{setup_step}, in addition to those made available by L{TestBuildStepMixin}: @ivar sourcestamp: fake SourceStamp for the build From df948b1a85f862abc7d55f750baf7435f47f230b Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:38 +0200 Subject: [PATCH 10/18] test: Tear down CommandTestMixin automatically --- worker/buildbot_worker/test/unit/test_bot.py | 2 -- .../test/unit/test_commands_base.py | 3 --- .../test/unit/test_commands_fs.py | 21 --------------- .../test/unit/test_commands_shell.py | 3 --- .../test/unit/test_commands_transfer.py | 9 ------- worker/buildbot_worker/test/util/command.py | 26 ++++++++++--------- 6 files changed, 14 insertions(+), 50 deletions(-) diff --git a/worker/buildbot_worker/test/unit/test_bot.py b/worker/buildbot_worker/test/unit/test_bot.py index 2368d2b8450d..c1e51a849fe2 100644 --- a/worker/buildbot_worker/test/unit/test_bot.py +++ b/worker/buildbot_worker/test/unit/test_bot.py @@ -224,8 +224,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - self.tearDownCommand() - if self.bot and self.bot.running: yield self.bot.stopService() if os.path.exists(self.basedir): diff --git a/worker/buildbot_worker/test/unit/test_commands_base.py b/worker/buildbot_worker/test/unit/test_commands_base.py index 832c5401faaf..2b882a549b1e 100644 --- a/worker/buildbot_worker/test/unit/test_commands_base.py +++ b/worker/buildbot_worker/test/unit/test_commands_base.py @@ -61,9 +61,6 @@ class TestDummyCommand(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - def assertState(self, setup_done, running, started, interrupted, msg=None): self.assertEqual( { diff --git a/worker/buildbot_worker/test/unit/test_commands_fs.py b/worker/buildbot_worker/test/unit/test_commands_fs.py index 5a5e5c7d3a69..38bfa568f52c 100644 --- a/worker/buildbot_worker/test/unit/test_commands_fs.py +++ b/worker/buildbot_worker/test/unit/test_commands_fs.py @@ -34,9 +34,6 @@ class TestRemoveDirectory(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_simple_real(self): file_path = os.path.join(self.basedir, 'workdir') @@ -176,9 +173,6 @@ class TestCopyDirectory(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_simple(self): from_path = os.path.join(self.basedir, 'workdir') @@ -215,9 +209,6 @@ class TestMakeDirectory(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_empty_paths(self): self.make_command(fs.MakeDirectory, {'paths': []}, True) @@ -270,9 +261,6 @@ class TestStatFile(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_non_existent(self): path = os.path.join(self.basedir, 'no-such-file') @@ -321,9 +309,6 @@ class TestGlobPath(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_non_existent(self): self.make_command(fs.GlobPath, {'path': os.path.join(self.basedir, 'no-*-file')}, True) @@ -371,9 +356,6 @@ class TestListDir(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_non_existent(self): path = os.path.join(self.basedir, 'no-such-dir') @@ -415,9 +397,6 @@ class TestRemoveFile(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_simple(self): workdir = os.path.join(self.basedir, 'workdir') diff --git a/worker/buildbot_worker/test/unit/test_commands_shell.py b/worker/buildbot_worker/test/unit/test_commands_shell.py index b4c6e3f3a007..8a897f02a9c8 100644 --- a/worker/buildbot_worker/test/unit/test_commands_shell.py +++ b/worker/buildbot_worker/test/unit/test_commands_shell.py @@ -27,9 +27,6 @@ class TestWorkerShellCommand(CommandTestMixin, unittest.TestCase): def setUp(self): self.setUpCommand() - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_simple(self): workdir = os.path.join(self.basedir, 'workdir') diff --git a/worker/buildbot_worker/test/unit/test_commands_transfer.py b/worker/buildbot_worker/test/unit/test_commands_transfer.py index 987345e4a1a7..305082cdbbc0 100644 --- a/worker/buildbot_worker/test/unit/test_commands_transfer.py +++ b/worker/buildbot_worker/test/unit/test_commands_transfer.py @@ -123,8 +123,6 @@ def setUp(self): f.write(b"this is some data\n" * 10) def tearDown(self): - self.tearDownCommand() - if os.path.exists(self.datadir): shutil.rmtree(self.datadir) @@ -317,8 +315,6 @@ def setUp(self): f.write(b"and a little b" * 17) def tearDown(self): - self.tearDownCommand() - if os.path.exists(self.datadir): shutil.rmtree(self.datadir) @@ -400,9 +396,6 @@ def setUp(self): self.setUpCommand() self.fakemaster = FakeMasterMethods(self.add_update) - def tearDown(self): - self.tearDownCommand() - @defer.inlineCallbacks def test_directory_not_available(self): path = os.path.join(self.basedir, 'workdir', os.path.expanduser('data')) @@ -443,8 +436,6 @@ def setUp(self): os.makedirs(self.basedir) def tearDown(self): - self.tearDownCommand() - if os.path.exists(self.basedir): shutil.rmtree(self.basedir) diff --git a/worker/buildbot_worker/test/util/command.py b/worker/buildbot_worker/test/util/command.py index 99ab5761c6d9..68957492a29a 100644 --- a/worker/buildbot_worker/test/util/command.py +++ b/worker/buildbot_worker/test/util/command.py @@ -44,18 +44,20 @@ def setUpCommand(self): if os.path.exists(self.basedir): shutil.rmtree(self.basedir) - def tearDownCommand(self): - """ - Call this from the tearDown method to clean up any leftover workdirs and do - any additional cleanup required. - """ - # clean up the basedir unconditionally - if os.path.exists(self.basedir): - shutil.rmtree(self.basedir) - - # finish up the runprocess - if hasattr(self, 'runprocess_patched') and self.runprocess_patched: - runprocess.FakeRunProcess.test_done() + def cleanup(): + """ + Call this from the tearDown method to clean up any leftover workdirs and do + any additional cleanup required. + """ + # clean up the basedir unconditionally + if os.path.exists(self.basedir): + shutil.rmtree(self.basedir) + + # finish up the runprocess + if hasattr(self, 'runprocess_patched') and self.runprocess_patched: + runprocess.FakeRunProcess.test_done() + + self.addCleanup(cleanup) def make_command(self, cmdclass, args, makedirs=False): """ From dfe77d5c5cf325651c96015bd0c30b99eb1aabb2 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:39 +0200 Subject: [PATCH 11/18] test: Tear down EndpointMixin automatically --- master/buildbot/test/unit/data/test_base.py | 3 --- master/buildbot/test/unit/data/test_build_data.py | 9 --------- master/buildbot/test/unit/data/test_builders.py | 6 ------ master/buildbot/test/unit/data/test_buildrequests.py | 6 ------ master/buildbot/test/unit/data/test_builds.py | 6 ------ master/buildbot/test/unit/data/test_buildsets.py | 6 ------ master/buildbot/test/unit/data/test_changes.py | 6 ------ master/buildbot/test/unit/data/test_changesources.py | 6 ------ master/buildbot/test/unit/data/test_forceschedulers.py | 6 ------ master/buildbot/test/unit/data/test_logchunks.py | 3 --- master/buildbot/test/unit/data/test_logs.py | 6 ------ master/buildbot/test/unit/data/test_masters.py | 6 ------ master/buildbot/test/unit/data/test_projects.py | 6 ------ master/buildbot/test/unit/data/test_properties.py | 6 ------ master/buildbot/test/unit/data/test_root.py | 6 ------ master/buildbot/test/unit/data/test_schedulers.py | 6 ------ master/buildbot/test/unit/data/test_sourcestamps.py | 6 ------ master/buildbot/test/unit/data/test_steps.py | 6 ------ master/buildbot/test/unit/data/test_test_result_sets.py | 6 ------ master/buildbot/test/unit/data/test_test_results.py | 3 --- master/buildbot/test/unit/data/test_workers.py | 6 ------ master/buildbot/test/util/endpoint.py | 6 +----- 22 files changed, 1 insertion(+), 125 deletions(-) diff --git a/master/buildbot/test/unit/data/test_base.py b/master/buildbot/test/unit/data/test_base.py index 1829f3de3a7f..14c09ef14a86 100644 --- a/master/buildbot/test/unit/data/test_base.py +++ b/master/buildbot/test/unit/data/test_base.py @@ -106,9 +106,6 @@ class MyEndpoint(base.Endpoint): def setUp(self): yield self.setUpEndpoint() - def tearDown(self): - self.tearDownEndpoint() - def test_sets_master(self): self.assertIdentical(self.master, self.ep.master) diff --git a/master/buildbot/test/unit/data/test_build_data.py b/master/buildbot/test/unit/data/test_build_data.py index c1e91a787b12..94d41b953cf7 100644 --- a/master/buildbot/test/unit/data/test_build_data.py +++ b/master/buildbot/test/unit/data/test_build_data.py @@ -45,9 +45,6 @@ def setUp(self): fakedb.BuildData(id=91, buildid=30, name='name1', value=b'value1', source='source1'), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing_build_data_by_build_id(self): result = yield self.callGet(('builds', 30, 'data', 'name1')) @@ -153,9 +150,6 @@ def setUp(self): fakedb.BuildData(id=91, buildid=30, name='name1', value=b'value1', source='source1'), ]) - def tearDown(self): - self.tearDownEndpoint() - def validateData(self, data): self.assertIsInstance(data['raw'], bytes) self.assertIsInstance(data['mime-type'], str) @@ -286,9 +280,6 @@ def setUp(self): fakedb.BuildData(id=93, buildid=31, name='name3', value=b'value3', source='source3'), ]) - def tearDown(self): - self.tearDownEndpoint() - @parameterized.expand([ ('multiple_values', 7, ['name1', 'name2']), ('single_value', 8, ['name3']), diff --git a/master/buildbot/test/unit/data/test_builders.py b/master/buildbot/test/unit/data/test_builders.py index 22799611000e..4838436ae3ad 100644 --- a/master/buildbot/test/unit/data/test_builders.py +++ b/master/buildbot/test/unit/data/test_builders.py @@ -44,9 +44,6 @@ def setUp(self): fakedb.BuilderMaster(id=1, builderid=2, masterid=13), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): builder = yield self.callGet(('builders', 2)) @@ -130,9 +127,6 @@ def setUp(self): fakedb.ConfiguredWorker(id=1, workerid=1, buildermasterid=1), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): builders = yield self.callGet(('builders',)) diff --git a/master/buildbot/test/unit/data/test_buildrequests.py b/master/buildbot/test/unit/data/test_buildrequests.py index 1005225e0f7d..6e18bc8cfacc 100644 --- a/master/buildbot/test/unit/data/test_buildrequests.py +++ b/master/buildbot/test/unit/data/test_buildrequests.py @@ -66,9 +66,6 @@ def setUp(self): ), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def testGetExisting(self): self.db.buildrequests.claimBuildRequests([44], claimed_at=self.CLAIMED_AT) @@ -151,9 +148,6 @@ def setUp(self): fakedb.BuildsetSourceStamp(buildsetid=8822, sourcestampid=100), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def testGetAll(self): buildrequests = yield self.callGet(('buildrequests',)) diff --git a/master/buildbot/test/unit/data/test_builds.py b/master/buildbot/test/unit/data/test_builds.py index e40fe08125cd..d65a819a1d58 100644 --- a/master/buildbot/test/unit/data/test_builds.py +++ b/master/buildbot/test/unit/data/test_builds.py @@ -56,9 +56,6 @@ def setUp(self): ), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): build = yield self.callGet(('builds', 14)) @@ -181,9 +178,6 @@ def setUp(self): ), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_all(self): builds = yield self.callGet(('builds',)) diff --git a/master/buildbot/test/unit/data/test_buildsets.py b/master/buildbot/test/unit/data/test_buildsets.py index 031b7f7d9bb2..5fb2589042d1 100644 --- a/master/buildbot/test/unit/data/test_buildsets.py +++ b/master/buildbot/test/unit/data/test_buildsets.py @@ -49,9 +49,6 @@ def setUp(self): fakedb.Buildset(id=14, reason='no sourcestamps'), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): buildset = yield self.callGet(('buildsets', 13)) @@ -88,9 +85,6 @@ def setUp(self): fakedb.BuildsetSourceStamp(buildsetid=14, sourcestampid=92), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): buildsets = yield self.callGet(('buildsets',)) diff --git a/master/buildbot/test/unit/data/test_changes.py b/master/buildbot/test/unit/data/test_changes.py index afc6cbc2eae8..87106626dae4 100644 --- a/master/buildbot/test/unit/data/test_changes.py +++ b/master/buildbot/test/unit/data/test_changes.py @@ -51,9 +51,6 @@ def setUp(self): ), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): change = yield self.callGet(('changes', '13')) @@ -106,9 +103,6 @@ def setUp(self): fakedb.Build(buildrequestid=1, masterid=1, workerid=1, builderid=1, number=1), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): changes = yield self.callGet(('changes',)) diff --git a/master/buildbot/test/unit/data/test_changesources.py b/master/buildbot/test/unit/data/test_changesources.py index 120f801687ae..9e973dc7564c 100644 --- a/master/buildbot/test/unit/data/test_changesources.py +++ b/master/buildbot/test/unit/data/test_changesources.py @@ -47,9 +47,6 @@ def setUp(self): fakedb.ChangeSourceMaster(changesourceid=15, masterid=33), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): """get an existing changesource by id""" @@ -115,9 +112,6 @@ def setUp(self): fakedb.ChangeSourceMaster(changesourceid=16, masterid=33), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): changesources = yield self.callGet(('changesources',)) diff --git a/master/buildbot/test/unit/data/test_forceschedulers.py b/master/buildbot/test/unit/data/test_forceschedulers.py index a50630cf4646..07b3aaec18e8 100644 --- a/master/buildbot/test/unit/data/test_forceschedulers.py +++ b/master/buildbot/test/unit/data/test_forceschedulers.py @@ -194,9 +194,6 @@ def setUp(self): scheds = [ForceScheduler(name="defaultforce", builderNames=["builder"])] self.master.allSchedulers = lambda: scheds - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): res = yield self.callGet(('forceschedulers', "defaultforce")) @@ -220,9 +217,6 @@ def setUp(self): scheds = [ForceScheduler(name="defaultforce", builderNames=["builder"])] self.master.allSchedulers = lambda: scheds - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): res = yield self.callGet(('forceschedulers',)) diff --git a/master/buildbot/test/unit/data/test_logchunks.py b/master/buildbot/test/unit/data/test_logchunks.py index efc317cb6a08..846f23b3a7ad 100644 --- a/master/buildbot/test/unit/data/test_logchunks.py +++ b/master/buildbot/test/unit/data/test_logchunks.py @@ -95,9 +95,6 @@ def setUp(self): ] ) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def do_test_chunks(self, path, logid, expLines): # get the whole thing in one go diff --git a/master/buildbot/test/unit/data/test_logs.py b/master/buildbot/test/unit/data/test_logs.py index ac6e1377e0b6..c79ee3e2639d 100644 --- a/master/buildbot/test/unit/data/test_logs.py +++ b/master/buildbot/test/unit/data/test_logs.py @@ -48,9 +48,6 @@ def setUp(self): fakedb.Log(id=61, stepid=50, name='errors', slug='errors', type='t'), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): log = yield self.callGet(('logs', 60)) @@ -138,9 +135,6 @@ def setUp(self): fakedb.Step(id=52, buildid=13, number=11, name='nothing'), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_stepid(self): logs = yield self.callGet(('steps', 50, 'logs')) diff --git a/master/buildbot/test/unit/data/test_masters.py b/master/buildbot/test/unit/data/test_masters.py index a102e588d2c2..f7b14ecf7f65 100644 --- a/master/buildbot/test/unit/data/test_masters.py +++ b/master/buildbot/test/unit/data/test_masters.py @@ -49,9 +49,6 @@ def setUp(self): fakedb.Builder(id=24, name='bldr2'), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): master = yield self.callGet(('masters', 14)) @@ -100,9 +97,6 @@ def setUp(self): fakedb.BuilderMaster(masterid=13, builderid=22), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): masters = yield self.callGet(('masters',)) diff --git a/master/buildbot/test/unit/data/test_projects.py b/master/buildbot/test/unit/data/test_projects.py index 9f6ae11717ba..d5782d4930cb 100644 --- a/master/buildbot/test/unit/data/test_projects.py +++ b/master/buildbot/test/unit/data/test_projects.py @@ -41,9 +41,6 @@ def setUp(self): fakedb.Project(id=2, name='project2'), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing_id(self): project = yield self.callGet(('projects', 2)) @@ -88,9 +85,6 @@ def setUp(self): fakedb.BuilderMaster(id=300, builderid=200, masterid=100), ]) - def tearDown(self): - self.tearDownEndpoint() - @parameterized.expand([ ('no_filter', None, [1, 2, 3]), ('active', True, [2]), diff --git a/master/buildbot/test/unit/data/test_properties.py b/master/buildbot/test/unit/data/test_properties.py index 14f30bf674cb..ff3eee9ba63e 100644 --- a/master/buildbot/test/unit/data/test_properties.py +++ b/master/buildbot/test/unit/data/test_properties.py @@ -45,9 +45,6 @@ def setUp(self): fakedb.BuildsetProperty(buildsetid=14), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_properties(self): props = yield self.callGet(('buildsets', 14, 'properties')) @@ -73,9 +70,6 @@ def setUp(self): fakedb.BuildProperty(buildid=786, name="island_name", value="despair", source="Book"), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_properties(self): props = yield self.callGet(('builds', 786, 'properties')) diff --git a/master/buildbot/test/unit/data/test_root.py b/master/buildbot/test/unit/data/test_root.py index 99c61af1501f..07adde962970 100644 --- a/master/buildbot/test/unit/data/test_root.py +++ b/master/buildbot/test/unit/data/test_root.py @@ -32,9 +32,6 @@ def setUp(self): {'name': 'abc'}, ] - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): rootlinks = yield self.callGet(('',)) @@ -62,9 +59,6 @@ def setUp(self): self.master.data = connector.DataConnector() yield self.master.data.setServiceParent(self.master) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): specs = yield self.callGet(('application.spec',)) diff --git a/master/buildbot/test/unit/data/test_schedulers.py b/master/buildbot/test/unit/data/test_schedulers.py index a232297c52ca..f0a5ac03de0e 100644 --- a/master/buildbot/test/unit/data/test_schedulers.py +++ b/master/buildbot/test/unit/data/test_schedulers.py @@ -45,9 +45,6 @@ def setUp(self): fakedb.SchedulerMaster(schedulerid=15, masterid=33), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): scheduler = yield self.callGet(('schedulers', 14)) @@ -112,9 +109,6 @@ def setUp(self): fakedb.SchedulerMaster(schedulerid=16, masterid=33), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): schedulers = yield self.callGet(('schedulers',)) diff --git a/master/buildbot/test/unit/data/test_sourcestamps.py b/master/buildbot/test/unit/data/test_sourcestamps.py index 2c39f87ef0b2..b4e2c4448522 100644 --- a/master/buildbot/test/unit/data/test_sourcestamps.py +++ b/master/buildbot/test/unit/data/test_sourcestamps.py @@ -41,9 +41,6 @@ def setUp(self): fakedb.SourceStamp(id=14, patchid=99, branch='poplar'), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): sourcestamp = yield self.callGet(('sourcestamps', 13)) @@ -93,9 +90,6 @@ def setUp(self): fakedb.BuildsetSourceStamp(sourcestampid=14, buildsetid=30), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): sourcestamps = yield self.callGet(('sourcestamps',)) diff --git a/master/buildbot/test/unit/data/test_steps.py b/master/buildbot/test/unit/data/test_steps.py index fbd051b625de..747825d20bb3 100644 --- a/master/buildbot/test/unit/data/test_steps.py +++ b/master/buildbot/test/unit/data/test_steps.py @@ -73,9 +73,6 @@ def setUp(self): fakedb.Step(id=72, number=2, name='three', buildid=30, started_at=TIME4, hidden=True), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): step = yield self.callGet(('steps', 72)) @@ -183,9 +180,6 @@ def setUp(self): fakedb.Step(id=73, number=0, name='otherbuild', buildid=31, started_at=TIME3), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_buildid(self): steps = yield self.callGet(('builds', 30, 'steps')) diff --git a/master/buildbot/test/unit/data/test_test_result_sets.py b/master/buildbot/test/unit/data/test_test_result_sets.py index 9af074e2ee89..7fbeab7f5bb8 100644 --- a/master/buildbot/test/unit/data/test_test_result_sets.py +++ b/master/buildbot/test/unit/data/test_test_result_sets.py @@ -55,9 +55,6 @@ def setUp(self): ), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing_result_set(self): result = yield self.callGet(('test_result_sets', 13)) @@ -123,9 +120,6 @@ def setUp(self): ), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_result_sets_all(self): results = yield self.callGet(('test_result_sets',)) diff --git a/master/buildbot/test/unit/data/test_test_results.py b/master/buildbot/test/unit/data/test_test_results.py index 090e116045cd..422e06b63408 100644 --- a/master/buildbot/test/unit/data/test_test_results.py +++ b/master/buildbot/test/unit/data/test_test_results.py @@ -79,9 +79,6 @@ def setUp(self): ), ]) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing_results(self): results = yield self.callGet(('test_result_sets', 13, 'results')) diff --git a/master/buildbot/test/unit/data/test_workers.py b/master/buildbot/test/unit/data/test_workers.py index cd100cbb82ed..aa212140d7b1 100644 --- a/master/buildbot/test/unit/data/test_workers.py +++ b/master/buildbot/test/unit/data/test_workers.py @@ -127,9 +127,6 @@ def setUp(self): yield self.setUpEndpoint() yield self.db.insert_test_data(testData) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get_existing(self): worker = yield self.callGet(('workers', 2)) @@ -214,9 +211,6 @@ def setUp(self): yield self.setUpEndpoint() yield self.db.insert_test_data(testData) - def tearDown(self): - self.tearDownEndpoint() - @defer.inlineCallbacks def test_get(self): workers = yield self.callGet(('workers',)) diff --git a/master/buildbot/test/util/endpoint.py b/master/buildbot/test/util/endpoint.py index 707b08fb1a15..0ff14d57fed6 100644 --- a/master/buildbot/test/util/endpoint.py +++ b/master/buildbot/test/util/endpoint.py @@ -38,7 +38,7 @@ class EndpointMixin(TestReactorMixin, interfaces.InterfaceTests): @defer.inlineCallbacks def setUpEndpoint(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.db = self.master.db self.mq = self.master.mq @@ -68,10 +68,6 @@ def setUpEndpoint(self): if pp is not None ] - @defer.inlineCallbacks - def tearDownEndpoint(self): - yield self.tear_down_test_reactor() - def validateData(self, object): validation.verifyData(self, self.rtype.entityType, {}, object) From 5578286e47dc3efaa18e93e5e1ed5ae784efd00e Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:40 +0200 Subject: [PATCH 12/18] test: Tear down MigrateTestMixin automatically --- .../db_migrate/test_versions_060_add_builder_projects.py | 3 --- .../test_versions_061_add_builder_description_format.py | 3 --- .../test_versions_062_add_project_description_format.py | 3 --- .../test_versions_063_add_steps_locks_acquired_at.py | 3 --- .../db_migrate/test_versions_064_add_worker_pause_reason.py | 3 --- .../test_versions_065_add_buildsets_rebuilt_buildid.py | 3 --- .../test_versions_066_add_build_locks_duration_s.py | 3 --- master/buildbot/test/util/migration.py | 6 +----- 8 files changed, 1 insertion(+), 26 deletions(-) diff --git a/master/buildbot/test/unit/db_migrate/test_versions_060_add_builder_projects.py b/master/buildbot/test/unit/db_migrate/test_versions_060_add_builder_projects.py index 1368c879e101..e1a634cefe89 100644 --- a/master/buildbot/test/unit/db_migrate/test_versions_060_add_builder_projects.py +++ b/master/buildbot/test/unit/db_migrate/test_versions_060_add_builder_projects.py @@ -26,9 +26,6 @@ class Migration(migration.MigrateTestMixin, unittest.TestCase): def setUp(self): return self.setUpMigrateTest() - def tearDown(self): - return self.tearDownMigrateTest() - def create_tables_thd(self, conn): metadata = sa.MetaData() metadata.bind = conn diff --git a/master/buildbot/test/unit/db_migrate/test_versions_061_add_builder_description_format.py b/master/buildbot/test/unit/db_migrate/test_versions_061_add_builder_description_format.py index 3fcafbc16706..18d08575de3b 100644 --- a/master/buildbot/test/unit/db_migrate/test_versions_061_add_builder_description_format.py +++ b/master/buildbot/test/unit/db_migrate/test_versions_061_add_builder_description_format.py @@ -26,9 +26,6 @@ class Migration(migration.MigrateTestMixin, unittest.TestCase): def setUp(self): return self.setUpMigrateTest() - def tearDown(self): - return self.tearDownMigrateTest() - def create_tables_thd(self, conn): metadata = sa.MetaData() metadata.bind = conn diff --git a/master/buildbot/test/unit/db_migrate/test_versions_062_add_project_description_format.py b/master/buildbot/test/unit/db_migrate/test_versions_062_add_project_description_format.py index a5bbeb493d78..976878be4a7a 100644 --- a/master/buildbot/test/unit/db_migrate/test_versions_062_add_project_description_format.py +++ b/master/buildbot/test/unit/db_migrate/test_versions_062_add_project_description_format.py @@ -26,9 +26,6 @@ class Migration(migration.MigrateTestMixin, unittest.TestCase): def setUp(self): return self.setUpMigrateTest() - def tearDown(self): - return self.tearDownMigrateTest() - def create_tables_thd(self, conn): metadata = sa.MetaData() metadata.bind = conn diff --git a/master/buildbot/test/unit/db_migrate/test_versions_063_add_steps_locks_acquired_at.py b/master/buildbot/test/unit/db_migrate/test_versions_063_add_steps_locks_acquired_at.py index 2be4005ac353..a05c4926467b 100644 --- a/master/buildbot/test/unit/db_migrate/test_versions_063_add_steps_locks_acquired_at.py +++ b/master/buildbot/test/unit/db_migrate/test_versions_063_add_steps_locks_acquired_at.py @@ -24,9 +24,6 @@ class Migration(migration.MigrateTestMixin, unittest.TestCase): def setUp(self): return self.setUpMigrateTest() - def tearDown(self): - return self.tearDownMigrateTest() - def create_tables_thd(self, conn): metadata = sa.MetaData() metadata.bind = conn diff --git a/master/buildbot/test/unit/db_migrate/test_versions_064_add_worker_pause_reason.py b/master/buildbot/test/unit/db_migrate/test_versions_064_add_worker_pause_reason.py index 1080b3ed921e..749152b70974 100644 --- a/master/buildbot/test/unit/db_migrate/test_versions_064_add_worker_pause_reason.py +++ b/master/buildbot/test/unit/db_migrate/test_versions_064_add_worker_pause_reason.py @@ -25,9 +25,6 @@ class Migration(migration.MigrateTestMixin, unittest.TestCase): def setUp(self): return self.setUpMigrateTest() - def tearDown(self): - return self.tearDownMigrateTest() - def create_tables_thd(self, conn): metadata = sa.MetaData() metadata.bind = conn diff --git a/master/buildbot/test/unit/db_migrate/test_versions_065_add_buildsets_rebuilt_buildid.py b/master/buildbot/test/unit/db_migrate/test_versions_065_add_buildsets_rebuilt_buildid.py index 9dfc4379aaab..eeab15a5b753 100644 --- a/master/buildbot/test/unit/db_migrate/test_versions_065_add_buildsets_rebuilt_buildid.py +++ b/master/buildbot/test/unit/db_migrate/test_versions_065_add_buildsets_rebuilt_buildid.py @@ -25,9 +25,6 @@ class Migration(migration.MigrateTestMixin, unittest.TestCase): def setUp(self): return self.setUpMigrateTest() - def tearDown(self): - return self.tearDownMigrateTest() - def create_tables_thd(self, conn): metadata = sa.MetaData() metadata.bind = conn diff --git a/master/buildbot/test/unit/db_migrate/test_versions_066_add_build_locks_duration_s.py b/master/buildbot/test/unit/db_migrate/test_versions_066_add_build_locks_duration_s.py index 57bed89a6113..73430c444b54 100644 --- a/master/buildbot/test/unit/db_migrate/test_versions_066_add_build_locks_duration_s.py +++ b/master/buildbot/test/unit/db_migrate/test_versions_066_add_build_locks_duration_s.py @@ -24,9 +24,6 @@ class Migration(migration.MigrateTestMixin, unittest.TestCase): def setUp(self): return self.setUpMigrateTest() - def tearDown(self): - return self.tearDownMigrateTest() - def create_tables_thd(self, conn): metadata = sa.MetaData() metadata.bind = conn diff --git a/master/buildbot/test/util/migration.py b/master/buildbot/test/util/migration.py index f3f8056b9fac..20f02cff8297 100644 --- a/master/buildbot/test/util/migration.py +++ b/master/buildbot/test/util/migration.py @@ -44,7 +44,7 @@ class MigrateTestMixin(TestReactorMixin, dirs.DirsMixin): @defer.inlineCallbacks def setUpMigrateTest(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.basedir = os.path.abspath("basedir") self.setUpDirs('basedir') @@ -53,10 +53,6 @@ def setUpMigrateTest(self): ) self.db = self.master.db - @defer.inlineCallbacks - def tearDownMigrateTest(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_test_migration(self, base_revision, target_revision, setup_thd_cb, verify_thd_cb): def setup_thd(conn): From 10acae0c8c820f32cd2edf7a6692f4f8946bdd4f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:41 +0200 Subject: [PATCH 13/18] test: Tear down database pools automatically --- master/buildbot/test/unit/db/test_connector.py | 9 +++++++-- master/buildbot/test/unit/db/test_pool.py | 8 ++------ master/buildbot/test/unit/test_master.py | 10 ++++++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/master/buildbot/test/unit/db/test_connector.py b/master/buildbot/test/unit/db/test_connector.py index 1d60a2a35490..21c8652e4e24 100644 --- a/master/buildbot/test/unit/db/test_connector.py +++ b/master/buildbot/test/unit/db/test_connector.py @@ -44,10 +44,15 @@ def setUp(self): self.db = connector.DBConnector(os.path.abspath('basedir')) yield self.db.set_master(self.master) + @defer.inlineCallbacks + def cleanup(): + if self.db.pool is not None: + yield self.db.pool.stop() + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - if self.db.pool is not None: - yield self.db.pool.stop() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/db/test_pool.py b/master/buildbot/test/unit/db/test_pool.py index 19c15101661d..2527316c3416 100644 --- a/master/buildbot/test/unit/db/test_pool.py +++ b/master/buildbot/test/unit/db/test_pool.py @@ -41,10 +41,7 @@ def setUp(self): self.pool = pool.DBThreadPool(self.engine, reactor=reactor) self.pool.start() yield self.pool.do(thd_clean_database) - - @defer.inlineCallbacks - def tearDown(self): - yield self.pool.stop() + self.addCleanup(self.pool.stop) @defer.inlineCallbacks def test_do(self): @@ -163,10 +160,9 @@ def setUp(self): self.engine.optimal_thread_pool_size = 2 self.pool = pool.DBThreadPool(self.engine, reactor=reactor) self.pool.start() + self.addCleanup(self.pool.stop) - @defer.inlineCallbacks def tearDown(self): - yield self.pool.stop() os.unlink("test.sqlite") @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/test_master.py b/master/buildbot/test/unit/test_master.py index b6f7d53963b0..f2c2ff23a7ea 100644 --- a/master/buildbot/test/unit/test_master.py +++ b/master/buildbot/test/unit/test_master.py @@ -102,6 +102,14 @@ def setUp(self): yield self.secrets_manager.setServiceParent(self.master) self.db = self.master.db = fakedb.FakeDBConnector(self.basedir, self, auto_upgrade=True) yield self.db.set_master(self.master) + + @defer.inlineCallbacks + def cleanup(): + if self.db.pool is not None: + yield self.db.pool.stop() + + self.addCleanup(cleanup) + self.mq = self.master.mq = fakemq.FakeMQConnector(self) yield self.mq.setServiceParent(self.master) self.data = self.master.data = fakedata.FakeDataConnector(self.master, self) @@ -109,8 +117,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - if self.db.pool is not None: - yield self.db.pool.stop() yield self.tear_down_test_reactor() # tests From 8d9a9ff5e140c9b699037c073a708d1eabed23f8 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:42 +0200 Subject: [PATCH 14/18] test: Stop various services in tests automatically --- .../buildbot/test/integration/test_graphql.py | 5 +-- .../test/integration/test_telegram_bot.py | 14 ++++--- master/buildbot/test/integration/test_www.py | 12 ++---- .../test/integration/worker/test_comm.py | 37 +++++++++++-------- .../test/integration/worker/test_proxy.py | 28 +++++++------- .../integration/worker/test_workerside.py | 25 ++++++++----- .../unit/changes/test_gerritchangesource.py | 2 +- .../buildbot/test/unit/changes/test_github.py | 2 +- .../test/unit/changes/test_gitpoller.py | 8 ++-- .../test/unit/changes/test_hgpoller.py | 2 +- .../test/unit/changes/test_manager.py | 4 +- .../unit/process/test_botmaster_BotMaster.py | 2 +- .../process/test_buildrequestdistributor.py | 9 ++++- .../test/unit/process/test_metrics.py | 9 ++++- .../test/unit/process/test_users_manager.py | 4 +- .../test/unit/reporters/test_bitbucket.py | 6 +-- .../unit/reporters/test_bitbucketserver.py | 13 +++++-- .../reporters/test_gerrit_verify_status.py | 2 +- .../test/unit/reporters/test_github.py | 6 ++- .../test/unit/reporters/test_gitlab.py | 3 +- .../buildbot/test/unit/reporters/test_http.py | 2 +- .../test/unit/reporters/test_words.py | 2 +- .../test/unit/reporters/test_zulip.py | 9 ++++- .../test/unit/schedulers/test_canceller.py | 2 +- .../schedulers/test_canceller_buildset.py | 2 +- master/buildbot/test/unit/steps/test_http.py | 14 +++---- master/buildbot/test/unit/test_mq_simple.py | 9 ++++- master/buildbot/test/unit/test_mq_wamp.py | 13 +++++-- .../buildbot/test/unit/test_secret_in_file.py | 5 +-- .../test/unit/test_secret_in_passwordstore.py | 2 +- .../test/unit/test_secret_rendered_service.py | 2 +- .../buildbot/test/unit/test_stats_service.py | 2 +- .../test/unit/util/test_httpclientservice.py | 13 +++---- .../test/unit/util/test_kubeclientservice.py | 15 +++++--- .../unit/util/test_test_result_submitter.py | 2 +- .../buildbot/test/unit/worker/test_manager.py | 2 +- .../test/unit/worker/test_marathon.py | 7 ++-- .../test_protocols_manager_pbmanager.py | 6 +-- .../buildbot/test/unit/worker/test_upcloud.py | 4 +- master/buildbot/test/unit/www/test_avatar.py | 4 +- .../test/unit/www/test_hooks_github.py | 16 ++++---- .../test/unit/www/test_hooks_poller.py | 3 +- worker/buildbot_worker/test/unit/test_bot.py | 8 +--- .../test/unit/test_bot_Worker.py | 4 +- 44 files changed, 187 insertions(+), 154 deletions(-) diff --git a/master/buildbot/test/integration/test_graphql.py b/master/buildbot/test/integration/test_graphql.py index b78adb5a5cab..519c1092948c 100644 --- a/master/buildbot/test/integration/test_graphql.py +++ b/master/buildbot/test/integration/test_graphql.py @@ -93,13 +93,10 @@ def setUp(self): self.master.allSchedulers = lambda: scheds yield self.master.startService() + self.addCleanup(self.master.stopService) yield self.insert_initial_data() - @defer.inlineCallbacks - def tearDown(self): - yield self.master.stopService() - @defer.inlineCallbacks def insert_initial_data(self): yield self.master.db.insert_test_data([ diff --git a/master/buildbot/test/integration/test_telegram_bot.py b/master/buildbot/test/integration/test_telegram_bot.py index 92f42e9ae867..23fe7ed7529f 100644 --- a/master/buildbot/test/integration/test_telegram_bot.py +++ b/master/buildbot/test/integration/test_telegram_bot.py @@ -154,12 +154,14 @@ def send_message(chat, message, **kwargs): tb.bot.send_message = send_message - @defer.inlineCallbacks - def tearDown(self): - if self.master: - yield self.master.www.stopService() - yield self.master.mq.stopService() - yield self.master.test_shutdown() + @defer.inlineCallbacks + def cleanup(): + if self.master: + yield self.master.www.stopService() + yield self.master.mq.stopService() + yield self.master.test_shutdown() + + self.addCleanup(cleanup) @defer.inlineCallbacks def testWebhook(self): diff --git a/master/buildbot/test/integration/test_www.py b/master/buildbot/test/integration/test_www.py index 5eea7d464a7e..b2946edecf3c 100644 --- a/master/buildbot/test/integration/test_www.py +++ b/master/buildbot/test/integration/test_www.py @@ -103,23 +103,19 @@ def setUp(self): self.master = master + self.addCleanup(self.master.test_shutdown) + self.addCleanup(self.master.www.stopService) + # build an HTTP agent, using an explicit connection pool if Twisted # supports it (Twisted 13.0.0 and up) if hasattr(client, 'HTTPConnectionPool'): self.pool = client.HTTPConnectionPool(reactor) self.agent = client.Agent(reactor, pool=self.pool) + self.addCleanup(self.pool.closeCachedConnections) else: self.pool = None self.agent = client.Agent(reactor) - @defer.inlineCallbacks - def tearDown(self): - if self.pool: - yield self.pool.closeCachedConnections() - if self.master: - yield self.master.www.stopService() - yield self.master.test_shutdown() - @defer.inlineCallbacks def apiGet(self, url, expect200=True): pg = yield self.agent.request(b'GET', url) diff --git a/master/buildbot/test/integration/worker/test_comm.py b/master/buildbot/test/integration/worker/test_comm.py index 981a550b2ba9..454e40fec37d 100644 --- a/master/buildbot/test/integration/worker/test_comm.py +++ b/master/buildbot/test/integration/worker/test_comm.py @@ -195,24 +195,29 @@ def setUp(self): self.server_connection_string = "tcp:0:interface=127.0.0.1" self.client_connection_string_tpl = "tcp:host=127.0.0.1:port={port}" + @defer.inlineCallbacks + def cleanup(): + if self.broker: + del self.broker + if self.endpoint: + del self.endpoint + deferreds = [ + *self._detach_deferreds, + self.pbmanager.stopService(), + self.botmaster.stopService(), + self.workers.stopService(), + ] + + # if the worker is still attached, wait for it to detach, too + if self.buildworker and self.buildworker.detach_d: + deferreds.append(self.buildworker.detach_d) + + yield defer.gatherResults(deferreds, consumeErrors=True) + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - if self.broker: - del self.broker - if self.endpoint: - del self.endpoint - deferreds = [ - *self._detach_deferreds, - self.pbmanager.stopService(), - self.botmaster.stopService(), - self.workers.stopService(), - ] - - # if the worker is still attached, wait for it to detach, too - if self.buildworker and self.buildworker.detach_d: - deferreds.append(self.buildworker.detach_d) - - yield defer.gatherResults(deferreds, consumeErrors=True) yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/integration/worker/test_proxy.py b/master/buildbot/test/integration/worker/test_proxy.py index 5f549db17fac..898f64c25933 100644 --- a/master/buildbot/test/integration/worker/test_proxy.py +++ b/master/buildbot/test/integration/worker/test_proxy.py @@ -147,19 +147,21 @@ def setUp(self): self.target_port = self.queue.get() write_to_log(f"got target_port {self.target_port}\n") - def tearDown(self): - write_to_log("tearDown\n") - self.proxy_process.terminate() - self.proxy_process.join() - if self.enable_debug: - print("---- stdout ----") - with open(get_log_path(), encoding='utf-8') as file: - print(file.read()) - print("---- ------ ----") - with open(self.queue.get(), encoding='utf-8') as file: - print(file.read()) - print("---- ------ ----") - os.unlink(get_log_path()) + def cleanup(): + write_to_log("cleanup\n") + self.proxy_process.terminate() + self.proxy_process.join() + if self.enable_debug: + print("---- stdout ----") + with open(get_log_path(), encoding='utf-8') as file: + print(file.read()) + print("---- ------ ----") + with open(self.queue.get(), encoding='utf-8') as file: + print(file.read()) + print("---- ------ ----") + os.unlink(get_log_path()) + + self.addCleanup(cleanup) @defer.inlineCallbacks def setup_master(self, config_dict, startWorker=True): diff --git a/master/buildbot/test/integration/worker/test_workerside.py b/master/buildbot/test/integration/worker/test_workerside.py index 052a5b3f096a..dfe090f129f1 100644 --- a/master/buildbot/test/integration/worker/test_workerside.py +++ b/master/buildbot/test/integration/worker/test_workerside.py @@ -142,18 +142,23 @@ def setUp(self): self.tmpdirs = set() + @defer.inlineCallbacks + def cleanup(): + for tmp in self.tmpdirs: + if os.path.exists(tmp): + shutil.rmtree(tmp) + yield self.pbmanager.stopService() + yield self.botmaster.stopService() + yield self.workers.stopService() + + # if the worker is still attached, wait for it to detach, too + if self.buildworker: + yield self.buildworker.waitForCompleteShutdown() + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - for tmp in self.tmpdirs: - if os.path.exists(tmp): - shutil.rmtree(tmp) - yield self.pbmanager.stopService() - yield self.botmaster.stopService() - yield self.workers.stopService() - - # if the worker is still attached, wait for it to detach, too - if self.buildworker: - yield self.buildworker.waitForCompleteShutdown() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/changes/test_gerritchangesource.py b/master/buildbot/test/unit/changes/test_gerritchangesource.py index 7f5b8923da75..ec58cce04391 100644 --- a/master/buildbot/test/unit/changes/test_gerritchangesource.py +++ b/master/buildbot/test/unit/changes/test_gerritchangesource.py @@ -1053,10 +1053,10 @@ def setUp(self): self.setup_test_reactor(auto_tear_down=False) yield self.setUpChangeSource() yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/changes/test_github.py b/master/buildbot/test/unit/changes/test_github.py index d4fceed446d9..7b8a1771b898 100644 --- a/master/buildbot/test/unit/changes/test_github.py +++ b/master/buildbot/test/unit/changes/test_github.py @@ -190,12 +190,12 @@ def setUp(self): yield secret_service.setServiceParent(self.master) yield self.master.startService() + self.addCleanup(self.master.stopService) fake_storage_service.reconfigService(secretdict={"token": "1234"}) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/changes/test_gitpoller.py b/master/buildbot/test/unit/changes/test_gitpoller.py index 213e4e140741..859725ab1cc8 100644 --- a/master/buildbot/test/unit/changes/test_gitpoller.py +++ b/master/buildbot/test/unit/changes/test_gitpoller.py @@ -67,12 +67,12 @@ def setUp(self): self.setup_master_run_process() yield self.setUpChangeSource() yield self.master.startService() + self.addCleanup(self.master.stopService) self.poller = yield self.attachChangeSource(self.createPoller()) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @async_to_deferred @@ -2423,10 +2423,10 @@ def setUp(self): self.setup_test_reactor(auto_tear_down=False) yield self.setUpChangeSource() yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -2580,6 +2580,7 @@ def setUp(self): yield self.setUpChangeSource(want_real_reactor=True) yield self.master.startService() + self.addCleanup(self.master.stopService) self.poller_workdir = tempfile.mkdtemp( prefix="TestGitPollerBareRepository_", @@ -2596,10 +2597,7 @@ def setUp(self): ) ) - @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() - def _delete_repository(repo_path: Path): # on Win, git will mark objects as read-only git_objects_path = repo_path / "objects" diff --git a/master/buildbot/test/unit/changes/test_hgpoller.py b/master/buildbot/test/unit/changes/test_hgpoller.py index 825de11d51d0..ce56b627c83e 100644 --- a/master/buildbot/test/unit/changes/test_hgpoller.py +++ b/master/buildbot/test/unit/changes/test_hgpoller.py @@ -61,10 +61,10 @@ def _isRepositoryReady(): self.poller._isRepositoryReady = _isRepositoryReady yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/changes/test_manager.py b/master/buildbot/test/unit/changes/test_manager.py index 2e63de2bc00f..ff2a1baadb60 100644 --- a/master/buildbot/test/unit/changes/test_manager.py +++ b/master/buildbot/test/unit/changes/test_manager.py @@ -31,13 +31,15 @@ def setUp(self): self.setup_test_reactor(auto_tear_down=False) self.master = yield fakemaster.make_master(self, wantData=True) self.cm = manager.ChangeManager() + self.master.startService() + self.addCleanup(self.master.stopService) + yield self.cm.setServiceParent(self.master) self.new_config = mock.Mock() @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() def make_sources(self, n, klass=base.ChangeSource, **kwargs): diff --git a/master/buildbot/test/unit/process/test_botmaster_BotMaster.py b/master/buildbot/test/unit/process/test_botmaster_BotMaster.py index 7da0f15c8bd0..b4bb37e4045c 100644 --- a/master/buildbot/test/unit/process/test_botmaster_BotMaster.py +++ b/master/buildbot/test/unit/process/test_botmaster_BotMaster.py @@ -164,10 +164,10 @@ def setUp(self): yield self.botmaster.setServiceParent(self.master) self.new_config = mock.Mock() self.botmaster.startService() + self.addCleanup(self.botmaster.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.botmaster.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/process/test_buildrequestdistributor.py b/master/buildbot/test/unit/process/test_buildrequestdistributor.py index c96cee4fb4dd..a8421201af90 100644 --- a/master/buildbot/test/unit/process/test_buildrequestdistributor.py +++ b/master/buildbot/test/unit/process/test_buildrequestdistributor.py @@ -65,6 +65,13 @@ def prioritizeBuilders(master, builders): self.brd.parent = self.botmaster self.brd.startService() + @defer.inlineCallbacks + def cleanup(): + if self.brd.running: + yield self.brd.stopService() + + self.addCleanup(cleanup) + # a collection of rows that would otherwise clutter up every test self.base_rows = [ fakedb.Master(id=fakedb.FakeDBConnector.MASTER_ID), @@ -76,8 +83,6 @@ def prioritizeBuilders(master, builders): @defer.inlineCallbacks def tearDown(self): - if self.brd.running: - yield self.brd.stopService() yield self.tear_down_test_reactor() def make_workers(self, worker_count): diff --git a/master/buildbot/test/unit/process/test_metrics.py b/master/buildbot/test/unit/process/test_metrics.py index bc976af1dc21..bd72bda6e15c 100644 --- a/master/buildbot/test/unit/process/test_metrics.py +++ b/master/buildbot/test/unit/process/test_metrics.py @@ -36,10 +36,15 @@ def setUp(self): self.observer.startService() self.observer.reconfigServiceWithBuildbotConfig(self.master.config) + @defer.inlineCallbacks + def cleanup(): + if self.observer.running: + yield self.observer.stopService() + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - if self.observer.running: - yield self.observer.stopService() yield self.tear_down_test_reactor() diff --git a/master/buildbot/test/unit/process/test_users_manager.py b/master/buildbot/test/unit/process/test_users_manager.py index 968598cde650..e07d0b1b9329 100644 --- a/master/buildbot/test/unit/process/test_users_manager.py +++ b/master/buildbot/test/unit/process/test_users_manager.py @@ -32,12 +32,10 @@ def setUp(self): self.master = mock.Mock() self.umm = manager.UserManagerManager(self.master) self.umm.startService() + self.addCleanup(self.umm.stopService) self.config = MasterConfig() - def tearDown(self): - self.umm.stopService() - @defer.inlineCallbacks def test_reconfigServiceWithBuildbotConfig(self): # add a user manager diff --git a/master/buildbot/test/unit/reporters/test_bitbucket.py b/master/buildbot/test/unit/reporters/test_bitbucket.py index 295bfb899fd1..61599b84d4f5 100644 --- a/master/buildbot/test/unit/reporters/test_bitbucket.py +++ b/master/buildbot/test/unit/reporters/test_bitbucket.py @@ -58,10 +58,10 @@ def setUp(self): self.bsp = BitbucketStatusPush(Interpolate('key'), Interpolate('secret')) yield self.bsp.setServiceParent(self.master) yield self.bsp.startService() + self.addCleanup(self.bsp.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.bsp.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -307,10 +307,10 @@ def setUp(self): ) yield self.bsp.setServiceParent(self.master) yield self.bsp.startService() + self.addCleanup(self.bsp.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.bsp.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -383,10 +383,10 @@ def setUp(self): self.bsp = BitbucketStatusPush(Interpolate('key'), Interpolate('secret')) yield self.bsp.setServiceParent(self.master) yield self.bsp.startService() + self.addCleanup(self.bsp.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.bsp.stopService() yield self.tear_down_test_reactor() def parse(self, repourl): diff --git a/master/buildbot/test/unit/reporters/test_bitbucketserver.py b/master/buildbot/test/unit/reporters/test_bitbucketserver.py index 07c7024667a9..c5155b4d0dea 100644 --- a/master/buildbot/test/unit/reporters/test_bitbucketserver.py +++ b/master/buildbot/test/unit/reporters/test_bitbucketserver.py @@ -68,10 +68,10 @@ def setupReporter(self, **kwargs): "serv", Interpolate("username"), Interpolate("passwd"), **kwargs ) yield self.sp.setServiceParent(self.master) + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -247,14 +247,19 @@ def setup_properties(props): yield self.sp.setServiceParent(self.master) yield self.master.startService() + @defer.inlineCallbacks + def cleanup(): + if self.master.running: + yield self.master.stopService() + + self.addCleanup(cleanup) + def setUp(self): self.master = None @defer.inlineCallbacks def tearDown(self): if self.master: - if self.master.running: - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -635,6 +640,7 @@ def setUp(self): self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def setupReporter(self, verbose=True, generator_class=BuildStatusGenerator, **kwargs): @@ -668,7 +674,6 @@ def setupReporter(self, verbose=True, generator_class=BuildStatusGenerator, **kw @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py b/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py index fe8f2ca66868..c81cb38784af 100644 --- a/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py +++ b/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py @@ -46,6 +46,7 @@ def setUp(self): self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def createGerritStatus(self, **kwargs): @@ -59,7 +60,6 @@ def createGerritStatus(self, **kwargs): @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/reporters/test_github.py b/master/buildbot/test/unit/reporters/test_github.py index d8f0950b303c..c527304b740e 100644 --- a/master/buildbot/test/unit/reporters/test_github.py +++ b/master/buildbot/test/unit/reporters/test_github.py @@ -44,6 +44,8 @@ def setUp(self): self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() + self.addCleanup(self.master.stopService) + self._http = yield fakehttpclientservice.HTTPClientService.getService( self.master, self, @@ -60,7 +62,6 @@ def createService(self): @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -312,6 +313,8 @@ def setUp(self): self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() + self.addCleanup(self.master.stopService) + self._http = yield fakehttpclientservice.HTTPClientService.getService( self.master, self, @@ -328,7 +331,6 @@ def createService(self): @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/reporters/test_gitlab.py b/master/buildbot/test/unit/reporters/test_gitlab.py index e0df58331eaf..983e346b81b8 100644 --- a/master/buildbot/test/unit/reporters/test_gitlab.py +++ b/master/buildbot/test/unit/reporters/test_gitlab.py @@ -47,6 +47,8 @@ def setUp(self): self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() + self.addCleanup(self.master.stopService) + self._http = yield fakehttpclientservice.HTTPClientService.getService( self.master, self, @@ -70,7 +72,6 @@ def setup_properties(props): @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/reporters/test_http.py b/master/buildbot/test/unit/reporters/test_http.py index 9f6e9bc2186e..b82661c72368 100644 --- a/master/buildbot/test/unit/reporters/test_http.py +++ b/master/buildbot/test/unit/reporters/test_http.py @@ -34,6 +34,7 @@ def setUp(self): self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def createReporter(self, auth=("username", "passwd"), headers=None, **kwargs): @@ -52,7 +53,6 @@ def createReporter(self, auth=("username", "passwd"), headers=None, **kwargs): @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/reporters/test_words.py b/master/buildbot/test/unit/reporters/test_words.py index bf39dc944600..fbdec6bdcd2a 100644 --- a/master/buildbot/test/unit/reporters/test_words.py +++ b/master/buildbot/test/unit/reporters/test_words.py @@ -93,10 +93,10 @@ def cancelCleanShutdown(): self.contact = self.contactClass(user=self.USER, channel=self.bot.getChannel(self.CHANNEL)) yield self.contact.channel.setServiceParent(self.master) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() def patch_send(self): diff --git a/master/buildbot/test/unit/reporters/test_zulip.py b/master/buildbot/test/unit/reporters/test_zulip.py index 2df5270271cf..b8f406e166c7 100644 --- a/master/buildbot/test/unit/reporters/test_zulip.py +++ b/master/buildbot/test/unit/reporters/test_zulip.py @@ -36,10 +36,15 @@ def setUp(self): testcase=self, wantData=True, wantDb=True, wantMq=True ) + @defer.inlineCallbacks + def cleanup(): + if self.master.running: + yield self.master.stopService() + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - if self.master.running: - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/schedulers/test_canceller.py b/master/buildbot/test/unit/schedulers/test_canceller.py index c9f0dc63e513..8111494e2689 100644 --- a/master/buildbot/test/unit/schedulers/test_canceller.py +++ b/master/buildbot/test/unit/schedulers/test_canceller.py @@ -396,10 +396,10 @@ def setUp(self): self._cancelled_build_ids = [] yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() def create_ss_dict(self, project, codebase, repository, branch): diff --git a/master/buildbot/test/unit/schedulers/test_canceller_buildset.py b/master/buildbot/test/unit/schedulers/test_canceller_buildset.py index fb54cbdbd9b0..0b01e60cfc3f 100644 --- a/master/buildbot/test/unit/schedulers/test_canceller_buildset.py +++ b/master/buildbot/test/unit/schedulers/test_canceller_buildset.py @@ -36,10 +36,10 @@ def setUp(self): self._cancelled_build_ids = [] yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/steps/test_http.py b/master/buildbot/test/unit/steps/test_http.py index 62e04522cb35..6a06e5ced9f7 100644 --- a/master/buildbot/test/unit/steps/test_http.py +++ b/master/buildbot/test/unit/steps/test_http.py @@ -72,23 +72,23 @@ def setUp(self): # ignore 'http_proxy' environment variable when running tests session = http.getSession() + self.addCleanup(http.closeSession) session.trust_env = False # port 0 means random unused port self.site = SiteWithClose(TestPage()) + self.addCleanup(self.site.stopFactory) + self.addCleanup(self.site.close_connections) + self.listener = reactor.listenTCP(0, self.site) + self.addCleanup(self.listener.stopListening) + self.port = self.listener.getHost().port return self.setup_test_build_step() @defer.inlineCallbacks def tearDown(self): - http.closeSession() - try: - yield self.listener.stopListening() - yield self.site.stopFactory() - yield self.site.close_connections() - finally: - yield self.tear_down_test_reactor() + yield self.tear_down_test_reactor() def get_connection_string(self): return f"http://127.0.0.1:{self.port}" diff --git a/master/buildbot/test/unit/test_mq_simple.py b/master/buildbot/test/unit/test_mq_simple.py index 910cdccce216..b54db1ab328a 100644 --- a/master/buildbot/test/unit/test_mq_simple.py +++ b/master/buildbot/test/unit/test_mq_simple.py @@ -32,10 +32,15 @@ def setUp(self): self.mq.setServiceParent(self.master) yield self.mq.startService() + @defer.inlineCallbacks + def cleanup(): + if self.mq.running: + yield self.mq.stopService() + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - if self.mq.running: - yield self.mq.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/test_mq_wamp.py b/master/buildbot/test/unit/test_mq_wamp.py index 51bf1d72b4d2..1ae041d1707a 100644 --- a/master/buildbot/test/unit/test_mq_wamp.py +++ b/master/buildbot/test/unit/test_mq_wamp.py @@ -133,10 +133,15 @@ def setUp(self): yield self.mq.setServiceParent(self.master) yield self.mq.startService() + @defer.inlineCallbacks + def cleanup(): + if self.mq.running: + yield self.mq.stopService() + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - if self.mq.running: - yield self.mq.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -257,14 +262,16 @@ def setUp(self): yield self.mq.setServiceParent(self.master) self.connector = self.master.wamp = connector.WampConnector() yield self.connector.setServiceParent(self.master) + yield self.master.startService() + self.addCleanup(self.master.stopService) + config = FakeConfig() config.mq['router_url'] = os.environ["WAMP_ROUTER_URL"] yield self.connector.reconfigServiceWithBuildbotConfig(config) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/test_secret_in_file.py b/master/buildbot/test/unit/test_secret_in_file.py index f4a8800497ea..8a80e3eacb9b 100644 --- a/master/buildbot/test/unit/test_secret_in_file.py +++ b/master/buildbot/test/unit/test_secret_in_file.py @@ -42,10 +42,7 @@ def setUp(self): self.filepath = self.createFileTemp(self.tmp_dir, "tempfile.txt", text="key value\n") self.srvfile = SecretInAFile(self.tmp_dir) yield self.srvfile.startService() - - @defer.inlineCallbacks - def tearDown(self): - yield self.srvfile.stopService() + self.addCleanup(self.srvfile.stopService) def testCheckConfigSecretInAFileService(self): self.assertEqual(self.srvfile.name, "SecretInAFile") diff --git a/master/buildbot/test/unit/test_secret_in_passwordstore.py b/master/buildbot/test/unit/test_secret_in_passwordstore.py index 3f86e804b399..fc17f7ade0d2 100644 --- a/master/buildbot/test/unit/test_secret_in_passwordstore.py +++ b/master/buildbot/test/unit/test_secret_in_passwordstore.py @@ -41,10 +41,10 @@ def setUp(self): self.srvpass = SecretInPass("password", self.tmp_dir) yield self.srvpass.setServiceParent(self.master) yield self.master.startService() + self.addCleanup(self.srvpass.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.srvpass.stopService() yield self.tear_down_test_reactor() def create_temp_dir(self, dirname): diff --git a/master/buildbot/test/unit/test_secret_rendered_service.py b/master/buildbot/test/unit/test_secret_rendered_service.py index 894294677d42..c14d175efa23 100644 --- a/master/buildbot/test/unit/test_secret_rendered_service.py +++ b/master/buildbot/test/unit/test_secret_rendered_service.py @@ -34,10 +34,10 @@ def setUp(self): self.srvtest = FakeServiceUsingSecrets() yield self.srvtest.setServiceParent(self.master) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/test_stats_service.py b/master/buildbot/test/unit/test_stats_service.py index f119d1902698..d694f3c65473 100644 --- a/master/buildbot/test/unit/test_stats_service.py +++ b/master/buildbot/test/unit/test_stats_service.py @@ -63,10 +63,10 @@ def setUp(self): ) yield self.stats_service.setServiceParent(self.master) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() diff --git a/master/buildbot/test/unit/util/test_httpclientservice.py b/master/buildbot/test/unit/util/test_httpclientservice.py index 7fb843d38620..33d91860c805 100644 --- a/master/buildbot/test/unit/util/test_httpclientservice.py +++ b/master/buildbot/test/unit/util/test_httpclientservice.py @@ -355,20 +355,19 @@ def setUp(self): if httpclientservice.txrequests is None or httpclientservice.treq is None: raise unittest.SkipTest('this test requires txrequests and treq') self.site = SiteWithClose(MyResource()) + self.addCleanup(self.site.close_connections) + self.addCleanup(self.site.stopFactory) + self.listenport = reactor.listenTCP(0, self.site) + self.addCleanup(self.listenport.stopListening) + self.port = self.listenport.getHost().port self.parent = parent = service.MasterService() self.parent.reactor = reactor yield parent.startService() + self.addCleanup(self.parent.stopService) self._http = yield self.httpFactory(parent) - @defer.inlineCallbacks - def tearDown(self): - yield self.listenport.stopListening() - yield self.site.stopFactory() - yield self.site.close_connections() - yield self.parent.stopService() - @defer.inlineCallbacks def test_content(self): self.expect('get', '/', content_json={}) diff --git a/master/buildbot/test/unit/util/test_kubeclientservice.py b/master/buildbot/test/unit/util/test_kubeclientservice.py index 1b9acb3b45a7..71253bb31c35 100644 --- a/master/buildbot/test/unit/util/test_kubeclientservice.py +++ b/master/buildbot/test/unit/util/test_kubeclientservice.py @@ -112,10 +112,10 @@ def setUp(self): self.master, self, "http://localhost:8001" ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() def test_basic(self): @@ -206,14 +206,17 @@ class KubeClientServiceTest(unittest.TestCase): @defer.inlineCallbacks def setUp(self): self.parent = service.BuildbotService(name="parent") + + @defer.inlineCallbacks + def cleanup(): + if self.parent.running: + yield self.parent.stopService() + + self.addCleanup(cleanup) + self.client = kubeclientservice.KubeClientService() yield self.client.setServiceParent(self.parent) - @defer.inlineCallbacks - def tearDown(self): - if self.parent.running: - yield self.parent.stopService() - @defer.inlineCallbacks def test_stopped(self): worker = mock.Mock(name="worker1") diff --git a/master/buildbot/test/unit/util/test_test_result_submitter.py b/master/buildbot/test/unit/util/test_test_result_submitter.py index 5a33b0390f6e..74bd9ebf79d7 100644 --- a/master/buildbot/test/unit/util/test_test_result_submitter.py +++ b/master/buildbot/test/unit/util/test_test_result_submitter.py @@ -28,6 +28,7 @@ def setUp(self): self.setup_test_reactor(auto_tear_down=False) self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True) yield self.master.startService() + self.addCleanup(self.master.stopService) yield self.master.db.insert_test_data([ fakedb.Worker(id=47, name='linux'), @@ -43,7 +44,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/worker/test_manager.py b/master/buildbot/test/unit/worker/test_manager.py index b16ae66e09ac..60312b12ae9e 100644 --- a/master/buildbot/test/unit/worker/test_manager.py +++ b/master/buildbot/test/unit/worker/test_manager.py @@ -60,10 +60,10 @@ def setUp(self): self.new_config = mock.Mock() self.workers.startService() + self.addCleanup(self.workers.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.workers.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/worker/test_marathon.py b/master/buildbot/test/unit/worker/test_marathon.py index 0987abc1c6c4..e7496b1ee216 100644 --- a/master/buildbot/test/unit/worker/test_marathon.py +++ b/master/buildbot/test/unit/worker/test_marathon.py @@ -42,9 +42,6 @@ class FakeResult: code = 200 self._http.delete = lambda _: defer.succeed(FakeResult()) - if self.master is not None: - yield self.master.stopService() - yield self.master.test_shutdown() self.flushLoggedErrors(LatentWorkerSubstantiatiationCancelled) yield self.tear_down_test_reactor() @@ -58,13 +55,15 @@ def makeWorker(self, **kwargs): kwargs.setdefault('image', 'debian:wheezy') worker = MarathonLatentWorker('bot', 'tcp://marathon.local', **kwargs) self.worker = worker - self.master = yield fakemaster.make_master(self, wantData=True, auto_shutdown=False) + self.master = yield fakemaster.make_master(self, wantData=True) self._http = yield fakehttpclientservice.HTTPClientService.getService( self.master, self, 'tcp://marathon.local', auth=kwargs.get('auth') ) yield worker.setServiceParent(self.master) worker.reactor = self.reactor yield self.master.startService() + self.addCleanup(self.master.stopService) + worker.masterhash = "masterhash" return worker diff --git a/master/buildbot/test/unit/worker/test_protocols_manager_pbmanager.py b/master/buildbot/test/unit/worker/test_protocols_manager_pbmanager.py index 52aafd1a6a76..5aa1c0b9c619 100644 --- a/master/buildbot/test/unit/worker/test_protocols_manager_pbmanager.py +++ b/master/buildbot/test/unit/worker/test_protocols_manager_pbmanager.py @@ -42,11 +42,11 @@ class TestPBManager(unittest.TestCase): def setUp(self): self.pbm = PBManager() yield self.pbm.setServiceParent(FakeMaster()) + self.pbm.startService() - self.connections = [] + self.addCleanup(self.pbm.stopService) - def tearDown(self): - return self.pbm.stopService() + self.connections = [] def perspectiveFactory(self, mind, username): persp = mock.Mock() diff --git a/master/buildbot/test/unit/worker/test_upcloud.py b/master/buildbot/test/unit/worker/test_upcloud.py index dd45df31992e..678a140d8a25 100644 --- a/master/buildbot/test/unit/worker/test_upcloud.py +++ b/master/buildbot/test/unit/worker/test_upcloud.py @@ -86,8 +86,6 @@ def setUp(self): @defer.inlineCallbacks def tearDown(self): - if self.master is not None: - yield self.master.test_shutdown() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -95,7 +93,7 @@ def setupWorker(self, *args, **kwargs): worker = upcloud.UpcloudLatentWorker( *args, api_username='test-api-user', api_password='test-api-password', **kwargs ) - self.master = yield fakemaster.make_master(self, wantData=True, auto_shutdown=False) + self.master = yield fakemaster.make_master(self, wantData=True) self._http = worker.client = yield fakehttpclientservice.HTTPClientService.getService( self.master, self, diff --git a/master/buildbot/test/unit/www/test_avatar.py b/master/buildbot/test/unit/www/test_avatar.py index 3e9824d6ff47..e147f5902119 100644 --- a/master/buildbot/test/unit/www/test_avatar.py +++ b/master/buildbot/test/unit/www/test_avatar.py @@ -550,10 +550,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -750,10 +750,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() def test_incomplete_credentials(self): diff --git a/master/buildbot/test/unit/www/test_hooks_github.py b/master/buildbot/test/unit/www/test_hooks_github.py index 331b3d5a66e5..ad5e23a939af 100644 --- a/master/buildbot/test/unit/www/test_hooks_github.py +++ b/master/buildbot/test/unit/www/test_hooks_github.py @@ -624,10 +624,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() def assertDictSubset(self, expected_dict, response_dict): @@ -902,10 +902,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -952,10 +952,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1009,12 +1009,12 @@ def setUp(self): yield secret_service.setServiceParent(self.master) yield self.master.startService() + self.addCleanup(self.master.stopService) fake_storage.reconfigService(secretdict={self.secret_name: self.secret_value}) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1053,10 +1053,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1146,10 +1146,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() def assertDictSubset(self, expected_dict, response_dict): @@ -1264,10 +1264,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks @@ -1308,10 +1308,10 @@ def setUp(self): verify=True, ) yield self.master.startService() + self.addCleanup(self.master.stopService) @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/www/test_hooks_poller.py b/master/buildbot/test/unit/www/test_hooks_poller.py index e54eb8847466..d8d6f0e33bff 100644 --- a/master/buildbot/test/unit/www/test_hooks_poller.py +++ b/master/buildbot/test/unit/www/test_hooks_poller.py @@ -48,6 +48,8 @@ def setUpRequest(self, args, options=True, activate=True): ) master.www = www yield self.master.startService() + self.addCleanup(self.master.stopService) + self.changeHook = change_hook.ChangeHookResource( dialects={'poller': options}, master=master ) @@ -68,7 +70,6 @@ def setUpRequest(self, args, options=True, activate=True): @defer.inlineCallbacks def tearDown(self): - yield self.master.stopService() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/worker/buildbot_worker/test/unit/test_bot.py b/worker/buildbot_worker/test/unit/test_bot.py index c1e51a849fe2..ea5ceb48bf89 100644 --- a/worker/buildbot_worker/test/unit/test_bot.py +++ b/worker/buildbot_worker/test/unit/test_bot.py @@ -59,13 +59,11 @@ def setUp(self): self.real_bot = pb.BotPbLike(self.basedir, False) self.real_bot.setOsReleaseFile(f"{self.basedir}/test-release-file") self.real_bot.startService() + self.addCleanup(self.real_bot.stopService) self.bot = FakeRemote(self.real_bot) - @defer.inlineCallbacks def tearDown(self): - if self.real_bot and self.real_bot.running: - yield self.real_bot.stopService() if os.path.exists(self.basedir): shutil.rmtree(self.basedir) @@ -214,6 +212,7 @@ def setUp(self): self.bot = FakeBot(self.basedir, False) self.bot.startService() + self.addCleanup(self.bot.stopService) # get a WorkerForBuilder object from the bot and wrap it as a fake # remote @@ -222,10 +221,7 @@ def setUp(self): self.setUpCommand() - @defer.inlineCallbacks def tearDown(self): - if self.bot and self.bot.running: - yield self.bot.stopService() if os.path.exists(self.basedir): shutil.rmtree(self.basedir) diff --git a/worker/buildbot_worker/test/unit/test_bot_Worker.py b/worker/buildbot_worker/test/unit/test_bot_Worker.py index c2ad47f7d294..43a8802ebb0a 100644 --- a/worker/buildbot_worker/test/unit/test_bot_Worker.py +++ b/worker/buildbot_worker/test/unit/test_bot_Worker.py @@ -86,8 +86,6 @@ def setUp(self): def tearDown(self): if self.realm: yield self.realm.shutdown() - if self.worker and self.worker.running: - yield self.worker.stopService() if self.listeningport: yield self.listeningport.stopListening() if os.path.exists(self.basedir): @@ -209,6 +207,7 @@ def call_print(mind): protocol='pb', ) self.worker.startService() + self.addCleanup(self.worker.stopService) # and wait for the result of the print return d @@ -290,6 +289,7 @@ def call_shutdown(mind): ) self.worker.startService() + self.addCleanup(self.worker.stopService) def check(ign): self.assertEqual(called, [('shutdown',)]) From 22f73405ad4c187974372cb88c3bfc459b19e6bc Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:43 +0200 Subject: [PATCH 15/18] test: Run test end assertions via addCleanup() --- master/buildbot/test/unit/util/test_poll.py | 11 ++++++++--- master/buildbot/test/util/integration.py | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/master/buildbot/test/unit/util/test_poll.py b/master/buildbot/test/unit/util/test_poll.py index 4e86c9efa95d..a473ea5ed387 100644 --- a/master/buildbot/test/unit/util/test_poll.py +++ b/master/buildbot/test/unit/util/test_poll.py @@ -39,10 +39,14 @@ def setUp(self): self.calls = 0 self.fail_after_running = False + def cleanup(): + poll.reset_poll_methods() + self.assertEqual(self.reactor.getDelayedCalls(), []) + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - poll.reset_poll_methods() - self.assertEqual(self.reactor.getDelayedCalls(), []) yield self.tear_down_test_reactor() def test_call_not_started_does_nothing(self): @@ -202,9 +206,10 @@ def setUp(self): self.duration = 1 self.fail_after_running = False + self.addCleanup(poll.reset_poll_methods) + @defer.inlineCallbacks def tearDown(self): - poll.reset_poll_methods() yield self.tear_down_test_reactor() @defer.inlineCallbacks diff --git a/master/buildbot/test/util/integration.py b/master/buildbot/test/util/integration.py index d49734177194..2ce51d9ebcc5 100644 --- a/master/buildbot/test/util/integration.py +++ b/master/buildbot/test/util/integration.py @@ -179,9 +179,13 @@ def setUp(self): self.setup_test_reactor(auto_tear_down=False) self.setupDebugIntegrationLogs() + def cleanup(): + self.assertFalse(self.master.running, "master is still running!") + + self.addCleanup(cleanup) + @defer.inlineCallbacks def tearDown(self): - self.assertFalse(self.master.running, "master is still running!") yield self.tear_down_test_reactor() @defer.inlineCallbacks From ad080c858d9fa292e2e07675cdabf6e3a006705f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:44 +0200 Subject: [PATCH 16/18] test: Use addCleanup for ignoring resource deletions during tear down --- .../buildbot/test/unit/worker/test_marathon.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/master/buildbot/test/unit/worker/test_marathon.py b/master/buildbot/test/unit/worker/test_marathon.py index e7496b1ee216..3f200c706361 100644 --- a/master/buildbot/test/unit/worker/test_marathon.py +++ b/master/buildbot/test/unit/worker/test_marathon.py @@ -34,14 +34,18 @@ def setUp(self): self.worker = None self.master = None - @defer.inlineCallbacks - def tearDown(self): - if self.worker is not None: + def cleanup(): + if self.worker is not None: + + class FakeResult: + code = 200 - class FakeResult: - code = 200 + self._http.delete = lambda _: defer.succeed(FakeResult()) - self._http.delete = lambda _: defer.succeed(FakeResult()) + self.addCleanup(cleanup) + + @defer.inlineCallbacks + def tearDown(self): self.flushLoggedErrors(LatentWorkerSubstantiatiationCancelled) yield self.tear_down_test_reactor() From 417491bf2d1fee08315c4e9482626df5af8e4f55 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:45 +0200 Subject: [PATCH 17/18] test: Tear down TestReactorMixin automatically --- .../buildbot/test/integration/test_upgrade.py | 6 +- .../test/integration/worker/test_comm.py | 6 +- .../integration/worker/test_workerside.py | 6 +- .../test_bad_change_properties_rows.py | 6 +- .../buildbot/test/unit/changes/test_base.py | 12 +--- .../test/unit/changes/test_bitbucket.py | 6 +- .../test/unit/changes/test_changes.py | 6 +- .../unit/changes/test_gerritchangesource.py | 12 +--- .../buildbot/test/unit/changes/test_github.py | 6 +- .../test/unit/changes/test_gitpoller.py | 12 +--- .../test/unit/changes/test_hgpoller.py | 6 +- .../buildbot/test/unit/changes/test_mail.py | 6 +- .../test/unit/changes/test_manager.py | 6 +- .../test/unit/changes/test_p4poller.py | 6 +- master/buildbot/test/unit/changes/test_pb.py | 12 +--- .../test/unit/changes/test_svnpoller.py | 6 +- master/buildbot/test/unit/data/test_base.py | 6 +- .../test/unit/data/test_build_data.py | 6 +- .../buildbot/test/unit/data/test_builders.py | 6 +- .../test/unit/data/test_buildrequests.py | 6 +- master/buildbot/test/unit/data/test_builds.py | 6 +- .../buildbot/test/unit/data/test_buildsets.py | 6 +- .../buildbot/test/unit/data/test_changes.py | 6 +- .../test/unit/data/test_changesources.py | 6 +- .../buildbot/test/unit/data/test_connector.py | 18 +---- master/buildbot/test/unit/data/test_logs.py | 6 +- .../buildbot/test/unit/data/test_masters.py | 6 +- .../buildbot/test/unit/data/test_patches.py | 6 +- .../buildbot/test/unit/data/test_projects.py | 6 +- .../test/unit/data/test_properties.py | 6 +- .../test/unit/data/test_schedulers.py | 6 +- master/buildbot/test/unit/data/test_steps.py | 6 +- .../test/unit/data/test_test_result_sets.py | 6 +- .../test/unit/data/test_test_results.py | 6 +- .../buildbot/test/unit/data/test_workers.py | 6 +- master/buildbot/test/unit/db/test_base.py | 6 +- .../buildbot/test/unit/db/test_build_data.py | 6 +- master/buildbot/test/unit/db/test_builders.py | 6 +- .../test/unit/db/test_buildrequests.py | 6 +- master/buildbot/test/unit/db/test_builds.py | 6 +- .../buildbot/test/unit/db/test_buildsets.py | 6 +- master/buildbot/test/unit/db/test_changes.py | 6 +- .../test/unit/db/test_changesources.py | 6 +- .../buildbot/test/unit/db/test_connector.py | 6 +- master/buildbot/test/unit/db/test_logs.py | 6 +- master/buildbot/test/unit/db/test_masters.py | 6 +- master/buildbot/test/unit/db/test_projects.py | 6 +- .../buildbot/test/unit/db/test_schedulers.py | 6 +- .../test/unit/db/test_sourcestamps.py | 6 +- master/buildbot/test/unit/db/test_state.py | 6 +- master/buildbot/test/unit/db/test_steps.py | 6 +- .../test/unit/db/test_test_result_sets.py | 6 +- .../test/unit/db/test_test_results.py | 6 +- master/buildbot/test/unit/db/test_users.py | 6 +- master/buildbot/test/unit/db/test_workers.py | 6 +- .../unit/process/test_botmaster_BotMaster.py | 12 +--- .../buildbot/test/unit/process/test_build.py | 30 ++------ .../test/unit/process/test_builder.py | 36 ++-------- .../test/unit/process/test_buildrequest.py | 12 +--- .../process/test_buildrequestdistributor.py | 6 +- .../test/unit/process/test_buildstep.py | 24 ++----- .../buildbot/test/unit/process/test_debug.py | 6 +- master/buildbot/test/unit/process/test_log.py | 6 +- .../test/unit/process/test_logobserver.py | 30 ++------ .../test/unit/process/test_metrics.py | 6 +- .../test/unit/process/test_users_manual.py | 12 +--- .../test/unit/process/test_users_users.py | 6 +- .../buildbot/test/unit/reporters/test_base.py | 6 +- .../test/unit/reporters/test_bitbucket.py | 18 +---- .../unit/reporters/test_bitbucketserver.py | 19 +---- .../unit/reporters/test_generators_build.py | 12 +--- .../reporters/test_generators_buildrequest.py | 6 +- .../reporters/test_generators_buildset.py | 6 +- .../unit/reporters/test_generators_utils.py | 6 +- .../unit/reporters/test_generators_worker.py | 6 +- .../test/unit/reporters/test_gerrit.py | 6 +- .../reporters/test_gerrit_verify_status.py | 6 +- .../test/unit/reporters/test_github.py | 12 +--- .../test/unit/reporters/test_gitlab.py | 6 +- .../buildbot/test/unit/reporters/test_http.py | 6 +- .../buildbot/test/unit/reporters/test_mail.py | 6 +- .../test/unit/reporters/test_message.py | 6 +- .../test/unit/reporters/test_pushjet.py | 6 +- .../test/unit/reporters/test_pushover.py | 6 +- .../test/unit/reporters/test_telegram.py | 6 +- .../test/unit/reporters/test_utils.py | 12 +--- .../test/unit/reporters/test_words.py | 6 +- .../test/unit/reporters/test_zulip.py | 6 +- .../test/unit/schedulers/test_base.py | 6 +- .../test/unit/schedulers/test_basic.py | 18 +---- .../test/unit/schedulers/test_canceller.py | 12 +--- .../schedulers/test_canceller_buildset.py | 6 +- .../test/unit/schedulers/test_dependent.py | 6 +- .../test/unit/schedulers/test_forcesched.py | 6 +- .../unit/schedulers/test_timed_Nightly.py | 6 +- .../unit/schedulers/test_timed_NightlyBase.py | 6 +- .../test_timed_NightlyTriggerable.py | 6 +- .../unit/schedulers/test_timed_Periodic.py | 6 +- .../test/unit/schedulers/test_timed_Timed.py | 6 +- .../test/unit/schedulers/test_triggerable.py | 6 +- .../test/unit/schedulers/test_trysched.py | 22 ++---- .../test/unit/scripts/test_cleanupdb.py | 12 +--- .../buildbot/test/unit/scripts/test_copydb.py | 6 +- .../test/unit/scripts/test_create_master.py | 6 +- .../test/unit/scripts/test_logwatcher.py | 6 +- .../test/unit/scripts/test_upgrade_master.py | 6 +- master/buildbot/test/unit/steps/test_cmake.py | 6 +- .../buildbot/test/unit/steps/test_cppcheck.py | 7 +- master/buildbot/test/unit/steps/test_http.py | 6 +- .../buildbot/test/unit/steps/test_master.py | 28 ++------ master/buildbot/test/unit/steps/test_maxq.py | 7 +- master/buildbot/test/unit/steps/test_mswin.py | 6 +- .../unit/steps/test_package_deb_lintian.py | 7 +- .../unit/steps/test_package_deb_pbuilder.py | 25 ++----- .../test/unit/steps/test_package_rpm_mock.py | 15 +--- .../unit/steps/test_package_rpm_rpmbuild.py | 6 +- .../unit/steps/test_package_rpm_rpmlint.py | 7 +- .../buildbot/test/unit/steps/test_python.py | 24 ++----- .../test/unit/steps/test_python_twisted.py | 19 +---- .../test/unit/steps/test_renderable.py | 7 +- master/buildbot/test/unit/steps/test_shell.py | 48 +++---------- .../unit/steps/test_source_base_Source.py | 18 +---- .../test/unit/steps/test_source_bzr.py | 7 +- .../test/unit/steps/test_source_cvs.py | 7 +- .../test/unit/steps/test_source_darcs.py | 7 +- .../test/unit/steps/test_source_gerrit.py | 7 +- .../test/unit/steps/test_source_git.py | 12 +--- .../test/unit/steps/test_source_gitlab.py | 7 +- .../test/unit/steps/test_source_mercurial.py | 7 +- .../test/unit/steps/test_source_mtn.py | 7 +- .../test/unit/steps/test_source_p4.py | 7 +- .../test/unit/steps/test_source_repo.py | 7 +- .../test/unit/steps/test_source_svn.py | 6 +- .../buildbot/test/unit/steps/test_subunit.py | 7 +- .../buildbot/test/unit/steps/test_transfer.py | 37 ++-------- .../buildbot/test/unit/steps/test_trigger.py | 6 +- .../buildbot/test/unit/steps/test_vstudio.py | 72 ++++--------------- .../buildbot/test/unit/steps/test_worker.py | 36 ++-------- .../unit/test_download_secret_to_worker.py | 19 +---- .../test/unit/test_fake_httpclientservice.py | 6 +- .../test/unit/test_fake_secrets_manager.py | 6 +- .../test/unit/test_interpolate_secrets.py | 18 +---- .../test/unit/test_janitor_configurator.py | 6 +- .../test/unit/test_machine_generic.py | 12 +--- master/buildbot/test/unit/test_master.py | 6 +- master/buildbot/test/unit/test_mq.py | 12 +--- .../buildbot/test/unit/test_mq_connector.py | 6 +- master/buildbot/test/unit/test_mq_simple.py | 6 +- master/buildbot/test/unit/test_mq_wamp.py | 12 +--- .../test/unit/test_secret_in_passwordstore.py | 6 +- .../test/unit/test_secret_rendered_service.py | 6 +- .../buildbot/test/unit/test_stats_service.py | 6 +- .../test/unit/test_steps_git_diffinfo.py | 7 +- master/buildbot/test/unit/test_steps_mixin.py | 6 +- .../buildbot/test/unit/test_wamp_connector.py | 6 +- .../buildbot/test/unit/util/test_backoff.py | 6 +- .../buildbot/test/unit/util/test_codebase.py | 6 +- .../test/unit/util/test_deferwaiter.py | 12 +--- .../test/unit/util/test_kubeclientservice.py | 6 +- master/buildbot/test/unit/util/test_misc.py | 6 +- master/buildbot/test/unit/util/test_poll.py | 12 +--- .../test/unit/util/test_runprocess.py | 6 +- .../buildbot/test/unit/util/test_service.py | 6 +- master/buildbot/test/unit/util/test_state.py | 6 +- .../unit/util/test_test_result_submitter.py | 6 +- .../buildbot/test/unit/util/test_watchdog.py | 7 +- master/buildbot/test/unit/worker/test_base.py | 24 ++----- .../buildbot/test/unit/worker/test_docker.py | 6 +- .../test/unit/worker/test_kubernetes.py | 6 +- .../buildbot/test/unit/worker/test_libvirt.py | 6 +- .../buildbot/test/unit/worker/test_local.py | 6 +- .../buildbot/test/unit/worker/test_manager.py | 6 +- .../test/unit/worker/test_marathon.py | 4 +- .../test/unit/worker/test_openstack.py | 6 +- .../test/unit/worker/test_protocols_base.py | 13 +--- .../unit/worker/test_protocols_msgpack.py | 18 +---- .../test/unit/worker/test_protocols_pb.py | 18 +---- .../buildbot/test/unit/worker/test_upcloud.py | 6 +- master/buildbot/test/unit/www/test_auth.py | 50 +++---------- master/buildbot/test/unit/www/test_authz.py | 6 +- master/buildbot/test/unit/www/test_avatar.py | 18 +---- master/buildbot/test/unit/www/test_config.py | 12 +--- .../test/unit/www/test_endpointmatchers.py | 6 +- master/buildbot/test/unit/www/test_graphql.py | 6 +- .../buildbot/test/unit/www/test_hooks_base.py | 12 +--- .../test/unit/www/test_hooks_bitbucket.py | 6 +- .../unit/www/test_hooks_bitbucketcloud.py | 6 +- .../unit/www/test_hooks_bitbucketserver.py | 6 +- .../test/unit/www/test_hooks_github.py | 72 ++++--------------- .../test/unit/www/test_hooks_gitlab.py | 12 +--- .../test/unit/www/test_hooks_gitorious.py | 6 +- .../test/unit/www/test_hooks_poller.py | 6 +- .../test/unit/www/test_ldapuserinfo.py | 6 +- master/buildbot/test/unit/www/test_oauth.py | 9 +-- .../buildbot/test/unit/www/test_resource.py | 12 +--- master/buildbot/test/unit/www/test_rest.py | 30 ++------ master/buildbot/test/unit/www/test_service.py | 6 +- master/buildbot/test/unit/www/test_sse.py | 6 +- master/buildbot/test/util/integration.py | 6 +- 199 files changed, 331 insertions(+), 1656 deletions(-) diff --git a/master/buildbot/test/integration/test_upgrade.py b/master/buildbot/test/integration/test_upgrade.py index d0645d3e1d72..5fb94f3400c2 100644 --- a/master/buildbot/test/integration/test_upgrade.py +++ b/master/buildbot/test/integration/test_upgrade.py @@ -95,13 +95,9 @@ def setUpUpgradeTest(self): # save subclasses the trouble of calling our setUp and tearDown methods def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpUpgradeTest() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def assertModelMatches(self): def comp(engine): diff --git a/master/buildbot/test/integration/worker/test_comm.py b/master/buildbot/test/integration/worker/test_comm.py index 454e40fec37d..f7c47a8b0ad7 100644 --- a/master/buildbot/test/integration/worker/test_comm.py +++ b/master/buildbot/test/integration/worker/test_comm.py @@ -161,7 +161,7 @@ class TestWorkerComm(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True, wantDb=True) # set the worker port to a loopback address with unspecified @@ -216,10 +216,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def addWorker(self, **kwargs): """ diff --git a/master/buildbot/test/integration/worker/test_workerside.py b/master/buildbot/test/integration/worker/test_workerside.py index dfe090f129f1..4984ae390ba9 100644 --- a/master/buildbot/test/integration/worker/test_workerside.py +++ b/master/buildbot/test/integration/worker/test_workerside.py @@ -111,7 +111,7 @@ class TestWorkerConnection(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True, wantDb=True) # set the worker port to a loopback address with unspecified # port @@ -157,10 +157,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def addMasterSideWorker( self, diff --git a/master/buildbot/test/regressions/test_bad_change_properties_rows.py b/master/buildbot/test/regressions/test_bad_change_properties_rows.py index dbef7c8d8632..2687384cc10d 100644 --- a/master/buildbot/test/regressions/test_bad_change_properties_rows.py +++ b/master/buildbot/test/regressions/test_bad_change_properties_rows.py @@ -30,14 +30,10 @@ class TestBadRows(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_bogus_row_no_source(self): yield self.db.insert_test_data([ diff --git a/master/buildbot/test/unit/changes/test_base.py b/master/buildbot/test/unit/changes/test_base.py index 91f30d8e403f..5eb9ca35435b 100644 --- a/master/buildbot/test/unit/changes/test_base.py +++ b/master/buildbot/test/unit/changes/test_base.py @@ -32,13 +32,9 @@ class Subclass(base.ChangeSource): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpChangeSource() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_activation(self): cs = self.Subclass(name="DummyCS") @@ -83,16 +79,12 @@ class Subclass(base.ReconfigurablePollingChangeSource): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpChangeSource() yield self.attachChangeSource(self.Subclass(name="DummyCS")) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def runClockFor(self, secs): yield self.reactor.pump([0] + [1.0] * secs) diff --git a/master/buildbot/test/unit/changes/test_bitbucket.py b/master/buildbot/test/unit/changes/test_bitbucket.py index 88143c33a913..51546e868702 100644 --- a/master/buildbot/test/unit/changes/test_bitbucket.py +++ b/master/buildbot/test/unit/changes/test_bitbucket.py @@ -274,7 +274,7 @@ class TestBitbucketPullrequestPoller( changesource.ChangeSourceMixin, TestReactorMixin, LoggingMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpLogging() # create pull requests @@ -304,10 +304,6 @@ def setUp(self): return self.setUpChangeSource() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def _fakeGetPage(self, result): # Install a fake getPage that puts the requested URL in self.getPage_got_url # and return result diff --git a/master/buildbot/test/unit/changes/test_changes.py b/master/buildbot/test/unit/changes/test_changes.py index 752d524e4353..4679da674545 100644 --- a/master/buildbot/test/unit/changes/test_changes.py +++ b/master/buildbot/test/unit/changes/test_changes.py @@ -54,7 +54,7 @@ class Change(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.change23 = changes.Change(**{ # using **dict(..) forces kwargs "category": 'devel', @@ -107,10 +107,6 @@ def setUp(self): }) self.change25.number = 25 - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_fromChdict(self): # get a real honest-to-goodness chdict from the fake db diff --git a/master/buildbot/test/unit/changes/test_gerritchangesource.py b/master/buildbot/test/unit/changes/test_gerritchangesource.py index ec58cce04391..787341213044 100644 --- a/master/buildbot/test/unit/changes/test_gerritchangesource.py +++ b/master/buildbot/test/unit/changes/test_gerritchangesource.py @@ -99,15 +99,11 @@ class TestGerritChangeSource( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() self._got_events = [] yield self.setUpChangeSource() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def create_gerrit(self, host, user, *args, **kwargs): http_url = kwargs.get("http_url", None) @@ -1050,15 +1046,11 @@ class TestGerritEventLogPoller( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpChangeSource() yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def newChangeSource(self, **kwargs): auth = kwargs.pop('auth', ('log', 'pass')) diff --git a/master/buildbot/test/unit/changes/test_github.py b/master/buildbot/test/unit/changes/test_github.py index 7b8a1771b898..66e4fcdfee76 100644 --- a/master/buildbot/test/unit/changes/test_github.py +++ b/master/buildbot/test/unit/changes/test_github.py @@ -180,7 +180,7 @@ class TestGitHubPullrequestPoller( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpChangeSource() fake_storage_service = FakeSecretStorage() @@ -194,10 +194,6 @@ def setUp(self): fake_storage_service.reconfigService(secretdict={"token": "1234"}) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def newChangeSource(self, owner, repo, endpoint='https://api.github.com', **kwargs): http_headers = {'User-Agent': 'Buildbot'} diff --git a/master/buildbot/test/unit/changes/test_gitpoller.py b/master/buildbot/test/unit/changes/test_gitpoller.py index 859725ab1cc8..f61e38d308ec 100644 --- a/master/buildbot/test/unit/changes/test_gitpoller.py +++ b/master/buildbot/test/unit/changes/test_gitpoller.py @@ -63,7 +63,7 @@ def createPoller(self): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() yield self.setUpChangeSource() yield self.master.startService() @@ -71,10 +71,6 @@ def setUp(self): self.poller = yield self.attachChangeSource(self.createPoller()) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @async_to_deferred async def set_last_rev(self, state: dict[str, str]) -> None: await self.poller.setState('lastRev', state) @@ -2420,15 +2416,11 @@ class TestGitPollerConstructor( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpChangeSource() yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_deprecatedFetchRefspec(self): with self.assertRaisesConfigError("fetch_refspec is no longer supported"): diff --git a/master/buildbot/test/unit/changes/test_hgpoller.py b/master/buildbot/test/unit/changes/test_hgpoller.py index ce56b627c83e..5c3a08bd922e 100644 --- a/master/buildbot/test/unit/changes/test_hgpoller.py +++ b/master/buildbot/test/unit/changes/test_hgpoller.py @@ -38,7 +38,7 @@ class TestHgPollerBase( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() yield self.setUpChangeSource() @@ -63,10 +63,6 @@ def _isRepositoryReady(): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def check_current_rev(self, wished, branch='default'): rev = yield self.poller._getCurrentRev(branch) diff --git a/master/buildbot/test/unit/changes/test_mail.py b/master/buildbot/test/unit/changes/test_mail.py index 29225fdd394f..7f5dda6ed6ba 100644 --- a/master/buildbot/test/unit/changes/test_mail.py +++ b/master/buildbot/test/unit/changes/test_mail.py @@ -29,7 +29,7 @@ class TestMaildirSource( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.maildir = os.path.abspath("maildir") yield self.setUpChangeSource() @@ -52,10 +52,6 @@ def assertMailProcessed(self): self.assertFalse(os.path.exists(os.path.join(self.maildir, "new", "newmsg"))) self.assertTrue(os.path.exists(os.path.join(self.maildir, "cur", "newmsg"))) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # tests def test_describe(self): diff --git a/master/buildbot/test/unit/changes/test_manager.py b/master/buildbot/test/unit/changes/test_manager.py index ff2a1baadb60..90f91779c716 100644 --- a/master/buildbot/test/unit/changes/test_manager.py +++ b/master/buildbot/test/unit/changes/test_manager.py @@ -28,7 +28,7 @@ class TestChangeManager(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) self.cm = manager.ChangeManager() @@ -38,10 +38,6 @@ def setUp(self): yield self.cm.setServiceParent(self.master) self.new_config = mock.Mock() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def make_sources(self, n, klass=base.ChangeSource, **kwargs): for i in range(n): src = klass(name=f'ChangeSource {i}', **kwargs) diff --git a/master/buildbot/test/unit/changes/test_p4poller.py b/master/buildbot/test/unit/changes/test_p4poller.py index 01fe6086b610..2e6a6c93962f 100644 --- a/master/buildbot/test/unit/changes/test_p4poller.py +++ b/master/buildbot/test/unit/changes/test_p4poller.py @@ -109,14 +109,10 @@ class TestP4Poller( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() yield self.setUpChangeSource() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def add_p4_describe_result(self, number, result): self.expect_commands( ExpectMasterShell(['p4', 'describe', '-s', str(number)]).stdout(result) diff --git a/master/buildbot/test/unit/changes/test_pb.py b/master/buildbot/test/unit/changes/test_pb.py index c3895496c02c..17a190210ba0 100644 --- a/master/buildbot/test/unit/changes/test_pb.py +++ b/master/buildbot/test/unit/changes/test_pb.py @@ -40,16 +40,12 @@ class TestPBChangeSource( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpPBChangeSource() yield self.setUpChangeSource() self.master.pbmanager = self.pbmanager - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_registration_no_workerport(self): return self._test_registration(None, exp_ConfigErrors=True, user='alice', passwd='sekrit') @@ -216,13 +212,9 @@ def test_reconfigService_default_changed_but_inactive(self): class TestChangePerspective(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True, wantData=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_addChange_noprefix(self): cp = pb.ChangePerspective(self.master, None) diff --git a/master/buildbot/test/unit/changes/test_svnpoller.py b/master/buildbot/test/unit/changes/test_svnpoller.py index d3131cdbaba1..fe730ac36c86 100644 --- a/master/buildbot/test/unit/changes/test_svnpoller.py +++ b/master/buildbot/test/unit/changes/test_svnpoller.py @@ -259,14 +259,10 @@ class TestSVNPoller( MasterRunProcessMixin, changesource.ChangeSourceMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() return self.setUpChangeSource() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def attachSVNPoller(self, *args, **kwargs): s = svnpoller.SVNPoller(*args, **kwargs) diff --git a/master/buildbot/test/unit/data/test_base.py b/master/buildbot/test/unit/data/test_base.py index 14c09ef14a86..b76f3fa223e5 100644 --- a/master/buildbot/test/unit/data/test_base.py +++ b/master/buildbot/test/unit/data/test_base.py @@ -26,11 +26,7 @@ class ResourceType(TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() def makeResourceTypeSubclass(self, **attributes): attributes.setdefault('name', 'thing') diff --git a/master/buildbot/test/unit/data/test_build_data.py b/master/buildbot/test/unit/data/test_build_data.py index 94d41b953cf7..137c43d5dd50 100644 --- a/master/buildbot/test/unit/data/test_build_data.py +++ b/master/buildbot/test/unit/data/test_build_data.py @@ -323,7 +323,7 @@ def test_get_builds_id(self, name, buildid, exp_names): class TestBuildData(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = build_data.BuildData(self.master) yield self.master.db.insert_test_data([ @@ -335,10 +335,6 @@ def setUp(self): fakedb.Build(id=2, buildrequestid=41, masterid=88, builderid=88, workerid=47), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_set_build_data(self): @self.assertArgSpecMatches(self.master.data.updates.setBuildData, self.rtype.setBuildData) def setBuildData(self, buildid, name, value, source): diff --git a/master/buildbot/test/unit/data/test_builders.py b/master/buildbot/test/unit/data/test_builders.py index 4838436ae3ad..3aadc4571a72 100644 --- a/master/buildbot/test/unit/data/test_builders.py +++ b/master/buildbot/test/unit/data/test_builders.py @@ -215,7 +215,7 @@ def test_get_contains_two_tags_one_unknown(self): class Builder(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = builders.Builder(self.master) yield self.master.db.insert_test_data([ @@ -223,10 +223,6 @@ def setUp(self): fakedb.Master(id=14), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findBuilderId(self): @self.assertArgSpecMatches( self.master.data.updates.findBuilderId, # fake diff --git a/master/buildbot/test/unit/data/test_buildrequests.py b/master/buildbot/test/unit/data/test_buildrequests.py index 6e18bc8cfacc..dd072f49c1c1 100644 --- a/master/buildbot/test/unit/data/test_buildrequests.py +++ b/master/buildbot/test/unit/data/test_buildrequests.py @@ -268,14 +268,10 @@ class dBLayerException(Exception): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = buildrequests.BuildRequest(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def doTestCallthrough( self, diff --git a/master/buildbot/test/unit/data/test_builds.py b/master/buildbot/test/unit/data/test_builds.py index d65a819a1d58..e2437ba82450 100644 --- a/master/buildbot/test/unit/data/test_builds.py +++ b/master/buildbot/test/unit/data/test_builds.py @@ -337,7 +337,7 @@ class Build(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = builds.Build(self.master) @@ -353,10 +353,6 @@ def setUp(self): ), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_test_callthrough( self, diff --git a/master/buildbot/test/unit/data/test_buildsets.py b/master/buildbot/test/unit/data/test_buildsets.py index 5fb2589042d1..268d49c7e6b1 100644 --- a/master/buildbot/test/unit/data/test_buildsets.py +++ b/master/buildbot/test/unit/data/test_buildsets.py @@ -120,7 +120,7 @@ def test_get_incomplete(self): class Buildset(TestReactorMixin, util_interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = buildsets.Buildset(self.master) yield self.master.db.insert_test_data([ @@ -139,10 +139,6 @@ def setUp(self): fakedb.BuildRequest(id=999, buildsetid=199, builderid=42), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - SS234_DATA = { 'branch': 'br', 'codebase': 'cb', diff --git a/master/buildbot/test/unit/data/test_changes.py b/master/buildbot/test/unit/data/test_changes.py index 87106626dae4..ff72b33c7483 100644 --- a/master/buildbot/test/unit/data/test_changes.py +++ b/master/buildbot/test/unit/data/test_changes.py @@ -195,7 +195,7 @@ class Change(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = changes.Change(self.master) @@ -203,10 +203,6 @@ def setUp(self): fakedb.SourceStamp(id=99), # force minimum ID in tests below ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_addChange(self): @self.assertArgSpecMatches( self.master.data.updates.addChange, # fake diff --git a/master/buildbot/test/unit/data/test_changesources.py b/master/buildbot/test/unit/data/test_changesources.py index 9e973dc7564c..c1c5fb925d78 100644 --- a/master/buildbot/test/unit/data/test_changesources.py +++ b/master/buildbot/test/unit/data/test_changesources.py @@ -140,14 +140,10 @@ def test_get_masterid_missing(self): class ChangeSource(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = changesources.ChangeSource(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findChangeSourceId(self): @self.assertArgSpecMatches( self.master.data.updates.findChangeSourceId, # fake diff --git a/master/buildbot/test/unit/data/test_connector.py b/master/buildbot/test/unit/data/test_connector.py index 169ddb604c95..f746021ca017 100644 --- a/master/buildbot/test/unit/data/test_connector.py +++ b/master/buildbot/test/unit/data/test_connector.py @@ -112,44 +112,32 @@ def updateBuilderList(self, masterid, builderNames): class TestFakeData(TestReactorMixin, unittest.TestCase, Tests): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True, wantDb=True) self.data = self.master.data - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestDataConnector(TestReactorMixin, unittest.TestCase, Tests): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True) self.data = connector.DataConnector() yield self.data.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class DataConnector(TestReactorMixin, unittest.TestCase): maxDiff = None @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) # don't load by default self.patch(connector.DataConnector, 'submodules', []) self.data = connector.DataConnector() yield self.data.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def patchFooPattern(self): cls = type('FooEndpoint', (base.Endpoint,), {}) ep = cls(None, self.master) diff --git a/master/buildbot/test/unit/data/test_logs.py b/master/buildbot/test/unit/data/test_logs.py index c79ee3e2639d..f6cdd60d858b 100644 --- a/master/buildbot/test/unit/data/test_logs.py +++ b/master/buildbot/test/unit/data/test_logs.py @@ -194,14 +194,10 @@ def test_get_builder_build_number_step_number(self): class Log(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = logs.Log(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_test_callthrough( self, dbMethodName, method, exp_args=None, exp_kwargs=None, *args, **kwargs diff --git a/master/buildbot/test/unit/data/test_masters.py b/master/buildbot/test/unit/data/test_masters.py index f7b14ecf7f65..2c62c7a70e2c 100644 --- a/master/buildbot/test/unit/data/test_masters.py +++ b/master/buildbot/test/unit/data/test_masters.py @@ -125,14 +125,10 @@ def test_get_builderid_missing(self): class Master(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = masters.Master(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_masterActive(self): @self.assertArgSpecMatches( self.master.data.updates.masterActive, # fake diff --git a/master/buildbot/test/unit/data/test_patches.py b/master/buildbot/test/unit/data/test_patches.py index a1db26744cf0..eeb184aadc41 100644 --- a/master/buildbot/test/unit/data/test_patches.py +++ b/master/buildbot/test/unit/data/test_patches.py @@ -24,12 +24,8 @@ class Patch(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = patches.Patch(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # no update methods -> nothing to test diff --git a/master/buildbot/test/unit/data/test_projects.py b/master/buildbot/test/unit/data/test_projects.py index d5782d4930cb..36c56dd90334 100644 --- a/master/buildbot/test/unit/data/test_projects.py +++ b/master/buildbot/test/unit/data/test_projects.py @@ -109,17 +109,13 @@ def test_get(self, name, active_filter, expected_projectids): class Project(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = projects.Project(self.master) yield self.master.db.insert_test_data([ fakedb.Project(id=13, name="fake_project"), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_find_project_id(self): @self.assertArgSpecMatches( self.master.data.updates.find_project_id, # fake diff --git a/master/buildbot/test/unit/data/test_properties.py b/master/buildbot/test/unit/data/test_properties.py index ff3eee9ba63e..5ff63c5ab66e 100644 --- a/master/buildbot/test/unit/data/test_properties.py +++ b/master/buildbot/test/unit/data/test_properties.py @@ -85,14 +85,10 @@ def test_get_properties_from_builder(self): class Properties(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=False, wantDb=True, wantData=True) self.rtype = properties.Properties(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_test_callthrough( self, dbMethodName, method, exp_args=None, exp_kwargs=None, *args, **kwargs diff --git a/master/buildbot/test/unit/data/test_schedulers.py b/master/buildbot/test/unit/data/test_schedulers.py index f0a5ac03de0e..c42766f6ad1e 100644 --- a/master/buildbot/test/unit/data/test_schedulers.py +++ b/master/buildbot/test/unit/data/test_schedulers.py @@ -137,14 +137,10 @@ def test_get_masterid_missing(self): class Scheduler(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = schedulers.Scheduler(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_schedulerEnable(self): @self.assertArgSpecMatches( self.master.data.updates.schedulerEnable, self.rtype.schedulerEnable diff --git a/master/buildbot/test/unit/data/test_steps.py b/master/buildbot/test/unit/data/test_steps.py index 747825d20bb3..d0572b8790c6 100644 --- a/master/buildbot/test/unit/data/test_steps.py +++ b/master/buildbot/test/unit/data/test_steps.py @@ -211,7 +211,7 @@ def test_get_buildername(self): class Step(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = steps.Step(self.master) @@ -226,10 +226,6 @@ def setUp(self): ), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_addStep(self): @self.assertArgSpecMatches( self.master.data.updates.addStep, # fake diff --git a/master/buildbot/test/unit/data/test_test_result_sets.py b/master/buildbot/test/unit/data/test_test_result_sets.py index 7fbeab7f5bb8..d010e4c96c29 100644 --- a/master/buildbot/test/unit/data/test_test_result_sets.py +++ b/master/buildbot/test/unit/data/test_test_result_sets.py @@ -159,7 +159,7 @@ def test_get_result_sets_steps_stepid(self): class TestResultSet(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) yield self.master.db.insert_test_data([ fakedb.Master(id=1), @@ -188,10 +188,6 @@ def setUp(self): ]) self.rtype = test_result_sets.TestResultSet(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_add_test_result_set(self): @self.assertArgSpecMatches( self.master.data.updates.addTestResultSet, self.rtype.addTestResultSet diff --git a/master/buildbot/test/unit/data/test_test_results.py b/master/buildbot/test/unit/data/test_test_results.py index 422e06b63408..2ece68cfbf4b 100644 --- a/master/buildbot/test/unit/data/test_test_results.py +++ b/master/buildbot/test/unit/data/test_test_results.py @@ -95,7 +95,7 @@ def test_get_missing_results(self): class TestResult(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = test_results.TestResult(self.master) yield self.master.db.insert_test_data([ @@ -111,10 +111,6 @@ def setUp(self): fakedb.TestResultSet(id=13, builderid=88, buildid=30, stepid=131), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_add_test_results(self): @self.assertArgSpecMatches( self.master.data.updates.addTestResults, self.rtype.addTestResults diff --git a/master/buildbot/test/unit/data/test_workers.py b/master/buildbot/test/unit/data/test_workers.py index aa212140d7b1..b6fc5b49ab45 100644 --- a/master/buildbot/test/unit/data/test_workers.py +++ b/master/buildbot/test/unit/data/test_workers.py @@ -288,7 +288,7 @@ def test_set_worker_paused_find_by_paused(self): class Worker(TestReactorMixin, interfaces.InterfaceTests, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantDb=True, wantData=True) self.rtype = workers.Worker(self.master) yield self.master.db.insert_test_data([ @@ -296,10 +296,6 @@ def setUp(self): fakedb.Master(id=14), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findWorkerId(self): @self.assertArgSpecMatches( self.master.data.updates.findWorkerId, # fake diff --git a/master/buildbot/test/unit/db/test_base.py b/master/buildbot/test/unit/db/test_base.py index 0041a21a6e86..9a83a573958f 100644 --- a/master/buildbot/test/unit/db/test_base.py +++ b/master/buildbot/test/unit/db/test_base.py @@ -73,14 +73,10 @@ def test_checkLength_long_not_mysql(self): class TestBaseAsConnectorComponent(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_findSomethingId_race(self): tbl = self.db.model.masters diff --git a/master/buildbot/test/unit/db/test_build_data.py b/master/buildbot/test/unit/db/test_build_data.py index cd7adeb89795..49b32d6a2da5 100644 --- a/master/buildbot/test/unit/db/test_build_data.py +++ b/master/buildbot/test/unit/db/test_build_data.py @@ -41,14 +41,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_add_build_data(self): @self.assertArgSpecMatches(self.db.build_data.setBuildData) def setBuildData(self, buildid, name, value, source): diff --git a/master/buildbot/test/unit/db/test_builders.py b/master/buildbot/test/unit/db/test_builders.py index b3df51f744ae..6e63afb1b38c 100644 --- a/master/buildbot/test/unit/db/test_builders.py +++ b/master/buildbot/test/unit/db/test_builders.py @@ -39,14 +39,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findBuilderId(self): @self.assertArgSpecMatches(self.db.builders.findBuilderId) def findBuilderId(self, name, autoCreate=True): diff --git a/master/buildbot/test/unit/db/test_buildrequests.py b/master/buildbot/test/unit/db/test_buildrequests.py index 0ab958d5aa43..6795fd3360fc 100644 --- a/master/buildbot/test/unit/db/test_buildrequests.py +++ b/master/buildbot/test/unit/db/test_buildrequests.py @@ -47,7 +47,7 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) # set up a sourcestamp and buildset for use below @@ -67,10 +67,6 @@ def setUp(self): fakedb.BuildsetSourceStamp(buildsetid=self.BSID, sourcestampid=234), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_getBuildRequest(self): yield self.master.db.insert_test_data([ diff --git a/master/buildbot/test/unit/db/test_builds.py b/master/buildbot/test/unit/db/test_builds.py index b73b1f12d1a8..a9c0b2ff41c8 100644 --- a/master/buildbot/test/unit/db/test_builds.py +++ b/master/buildbot/test/unit/db/test_builds.py @@ -126,14 +126,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # signature tests def test_signature_getBuild(self): diff --git a/master/buildbot/test/unit/db/test_buildsets.py b/master/buildbot/test/unit/db/test_buildsets.py index 18f993354573..2b5b25593eb3 100644 --- a/master/buildbot/test/unit/db/test_buildsets.py +++ b/master/buildbot/test/unit/db/test_buildsets.py @@ -34,7 +34,7 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db @@ -48,10 +48,6 @@ def setUp(self): fakedb.Builder(id=2, name='bldr2'), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_addBuildset(self): @self.assertArgSpecMatches(self.db.buildsets.addBuildset) def addBuildset( diff --git a/master/buildbot/test/unit/db/test_changes.py b/master/buildbot/test/unit/db/test_changes.py index 46360692128b..b867038c2b6d 100644 --- a/master/buildbot/test/unit/db/test_changes.py +++ b/master/buildbot/test/unit/db/test_changes.py @@ -99,14 +99,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_addChange(self): @self.assertArgSpecMatches(self.db.changes.addChange) def addChange( diff --git a/master/buildbot/test/unit/db/test_changesources.py b/master/buildbot/test/unit/db/test_changesources.py index e148c9f0528b..5555878e91a9 100644 --- a/master/buildbot/test/unit/db/test_changesources.py +++ b/master/buildbot/test/unit/db/test_changesources.py @@ -43,14 +43,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findChangeSourceId(self): """The signature of findChangeSourceId is correct""" diff --git a/master/buildbot/test/unit/db/test_connector.py b/master/buildbot/test/unit/db/test_connector.py index 21c8652e4e24..a312bc37a401 100644 --- a/master/buildbot/test/unit/db/test_connector.py +++ b/master/buildbot/test/unit/db/test_connector.py @@ -33,7 +33,7 @@ class TestDBConnector(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master( self, wantDb=True, auto_upgrade=False, check_version=False @@ -51,10 +51,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def startService(self, check_version=False): self.master.config.db['db_url'] = self.db_url diff --git a/master/buildbot/test/unit/db/test_logs.py b/master/buildbot/test/unit/db/test_logs.py index e4830a0487dc..48410892164d 100644 --- a/master/buildbot/test/unit/db/test_logs.py +++ b/master/buildbot/test/unit/db/test_logs.py @@ -127,14 +127,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def checkTestLogLines(self): expLines = [ diff --git a/master/buildbot/test/unit/db/test_masters.py b/master/buildbot/test/unit/db/test_masters.py index 8e38de7a199f..c12c304787bf 100644 --- a/master/buildbot/test/unit/db/test_masters.py +++ b/master/buildbot/test/unit/db/test_masters.py @@ -38,15 +38,11 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.reactor.advance(SOMETIME) self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findMasterId(self): @self.assertArgSpecMatches(self.db.masters.findMasterId) def findMasterId(self, name): diff --git a/master/buildbot/test/unit/db/test_projects.py b/master/buildbot/test/unit/db/test_projects.py index 672a1aa1710b..b8fbfc34c1cb 100644 --- a/master/buildbot/test/unit/db/test_projects.py +++ b/master/buildbot/test/unit/db/test_projects.py @@ -30,14 +30,10 @@ def project_key(builder): class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_find_project_id(self): @self.assertArgSpecMatches(self.db.projects.find_project_id) def find_project_id(self, name, auto_create=True): diff --git a/master/buildbot/test/unit/db/test_schedulers.py b/master/buildbot/test/unit/db/test_schedulers.py index ac5b35b2245a..d74f9d2320e4 100644 --- a/master/buildbot/test/unit/db/test_schedulers.py +++ b/master/buildbot/test/unit/db/test_schedulers.py @@ -43,14 +43,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_enable(self): @self.assertArgSpecMatches(self.db.schedulers.enable) def enable(self, schedulerid, v): diff --git a/master/buildbot/test/unit/db/test_sourcestamps.py b/master/buildbot/test/unit/db/test_sourcestamps.py index e097b15f8984..1df280200359 100644 --- a/master/buildbot/test/unit/db/test_sourcestamps.py +++ b/master/buildbot/test/unit/db/test_sourcestamps.py @@ -43,14 +43,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findSourceStampId(self): @self.assertArgSpecMatches(self.db.sourcestamps.findSourceStampId) def findSourceStampId( diff --git a/master/buildbot/test/unit/db/test_state.py b/master/buildbot/test/unit/db/test_state.py index bdad0f185673..9590d936d160 100644 --- a/master/buildbot/test/unit/db/test_state.py +++ b/master/buildbot/test/unit/db/test_state.py @@ -25,14 +25,10 @@ class TestStateConnectorComponent(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_getObjectId_new(self): objectid = yield self.db.state.getObjectId('someobj', 'someclass') diff --git a/master/buildbot/test/unit/db/test_steps.py b/master/buildbot/test/unit/db/test_steps.py index 6f07b06df280..2d0c31412224 100644 --- a/master/buildbot/test/unit/db/test_steps.py +++ b/master/buildbot/test/unit/db/test_steps.py @@ -117,14 +117,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_getStep(self): @self.assertArgSpecMatches(self.db.steps.getStep) def getStep(self, stepid=None, buildid=None, number=None, name=None): diff --git a/master/buildbot/test/unit/db/test_test_result_sets.py b/master/buildbot/test/unit/db/test_test_result_sets.py index ebf615601038..3301b4f45288 100644 --- a/master/buildbot/test/unit/db/test_test_result_sets.py +++ b/master/buildbot/test/unit/db/test_test_result_sets.py @@ -71,14 +71,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_add_test_result_set(self): @self.assertArgSpecMatches(self.db.test_result_sets.addTestResultSet) def addTestResultSet(self, builderid, buildid, stepid, description, category, value_unit): diff --git a/master/buildbot/test/unit/db/test_test_results.py b/master/buildbot/test/unit/db/test_test_results.py index 699c4aaa0e56..c0c3b1ee0e99 100644 --- a/master/buildbot/test/unit/db/test_test_results.py +++ b/master/buildbot/test/unit/db/test_test_results.py @@ -46,14 +46,10 @@ class Tests(interfaces.InterfaceTests, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_get_test_code_paths(self): @self.assertArgSpecMatches(self.db.test_results.getTestCodePaths) def getTestCodePaths(self, builderid, path_prefix=None, result_spec=None): diff --git a/master/buildbot/test/unit/db/test_users.py b/master/buildbot/test/unit/db/test_users.py index 8a67e4caab93..f9707828a5ef 100644 --- a/master/buildbot/test/unit/db/test_users.py +++ b/master/buildbot/test/unit/db/test_users.py @@ -26,14 +26,10 @@ class TestUsersConnectorComponent(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # sample user data user1_rows = [ diff --git a/master/buildbot/test/unit/db/test_workers.py b/master/buildbot/test/unit/db/test_workers.py index 618b71306c71..ad4635737486 100644 --- a/master/buildbot/test/unit/db/test_workers.py +++ b/master/buildbot/test/unit/db/test_workers.py @@ -83,14 +83,10 @@ class Tests( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_signature_findWorkerId(self): @self.assertArgSpecMatches(self.db.workers.findWorkerId) def findWorkerId(self, name): diff --git a/master/buildbot/test/unit/process/test_botmaster_BotMaster.py b/master/buildbot/test/unit/process/test_botmaster_BotMaster.py index b4bb37e4045c..3fa0c997ad02 100644 --- a/master/buildbot/test/unit/process/test_botmaster_BotMaster.py +++ b/master/buildbot/test/unit/process/test_botmaster_BotMaster.py @@ -30,16 +30,12 @@ class TestCleanShutdown(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) self.botmaster = BotMaster() yield self.botmaster.setServiceParent(self.master) self.botmaster.startService() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertReactorStopped(self, _=None): self.assertTrue(self.reactor.stop_called) @@ -156,7 +152,7 @@ def test_shutdown_cancel(self): class TestBotMaster(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True) self.master.mq = self.master.mq self.master.botmaster.disownServiceParent() @@ -166,10 +162,6 @@ def setUp(self): self.botmaster.startService() self.addCleanup(self.botmaster.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_reconfigServiceWithBuildbotConfig(self): # check that reconfigServiceBuilders is called. diff --git a/master/buildbot/test/unit/process/test_build.py b/master/buildbot/test/unit/process/test_build.py index ba0f2ec9c1e2..a9412c58ff50 100644 --- a/master/buildbot/test/unit/process/test_build.py +++ b/master/buildbot/test/unit/process/test_build.py @@ -182,7 +182,7 @@ def makeControllableStepFactory(): class TestBuild(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() r = FakeRequest() r.sources = [FakeSource()] r.sources[0].changes = [FakeChange()] @@ -207,10 +207,6 @@ def setUp(self): self.build.text = [] self.build.buildid = 666 - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertWorkerPreparationFailure(self, reason): states = "".join(self.master.data.updates.stepStateString.values()) self.assertIn(states, reason) @@ -897,7 +893,7 @@ def get_active_builds(): class TestMultipleSourceStamps(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.builder = FakeBuilder(self.master) @@ -921,10 +917,6 @@ def setUp(self): self.build = Build([r], self.builder) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_buildReturnSourceStamp(self): """ Test that a build returns the correct sourcestamp @@ -948,7 +940,7 @@ def test_buildReturnSourceStamp_empty_codebase(self): class TestBuildBlameList(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.builder = FakeBuilder(self.master) @@ -973,10 +965,6 @@ def setUp(self): self.patchSource.revision = "67890" self.patchSource.patch_info = ("jeff", "jeff's new feature") - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_blamelist_for_changes(self): r = FakeRequest() r.sources.extend([self.sourceByMe, self.sourceByHim]) @@ -1001,7 +989,7 @@ class TestSetupProperties_MultipleSources(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.props = {} self.r = FakeRequest() self.r.sources = [] @@ -1022,10 +1010,6 @@ def setUp(self): # record properties that will be set self.build.properties.setProperty = self.setProperty - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def setProperty(self, n, v, s, runtime=False): if s not in self.props: self.props[s] = {} @@ -1050,7 +1034,7 @@ class TestSetupProperties_SingleSource(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.props = {} self.r = FakeRequest() self.r.sources = [] @@ -1066,10 +1050,6 @@ def setUp(self): # record properties that will be set self.build.properties.setProperty = self.setProperty - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def setProperty(self, n, v, s, runtime=False): if s not in self.props: self.props[s] = {} diff --git a/master/buildbot/test/unit/process/test_builder.py b/master/buildbot/test/unit/process/test_builder.py index a2f99db654e8..6427138a5540 100644 --- a/master/buildbot/test/unit/process/test_builder.py +++ b/master/buildbot/test/unit/process/test_builder.py @@ -108,7 +108,7 @@ def reconfigService(self, name, _, **kwargs): class TestBuilder(TestReactorMixin, BuilderMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() # a collection of rows that would otherwise clutter up every test yield self.setUpBuilderMixin() self.base_rows = [ @@ -118,10 +118,6 @@ def setUp(self): fakedb.BuildsetSourceStamp(buildsetid=11, sourcestampid=21), ] - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeBuilder(self, patch_random=False, startBuildsForSucceeds=True, **config_kwargs): yield super().makeBuilder(patch_random=patch_random, **config_kwargs) @@ -485,13 +481,9 @@ def test_defaultProperties(self): class TestGetBuilderId(TestReactorMixin, BuilderMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpBuilderMixin() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_getBuilderId(self): # noReconfig because reconfigService calls getBuilderId, and we haven't @@ -512,7 +504,7 @@ def test_getBuilderId(self): class TestGetOldestRequestTime(TestReactorMixin, BuilderMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpBuilderMixin() # a collection of rows that would otherwise clutter up every test @@ -535,10 +527,6 @@ def setUp(self): ] yield self.db.insert_test_data(self.base_rows) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_gort_unclaimed(self): yield self.makeBuilder(name='bldr1') @@ -562,7 +550,7 @@ def test_gort_all_claimed(self): class TestGetNewestCompleteTime(TestReactorMixin, BuilderMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpBuilderMixin() # a collection of rows that would otherwise clutter up every test @@ -588,10 +576,6 @@ def setUp(self): ] yield self.db.insert_test_data(self.base_rows) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_gnct_completed(self): yield self.makeBuilder(name='bldr1') @@ -608,7 +592,7 @@ def test_gnct_no_completed(self): class TestGetHighestPriority(TestReactorMixin, BuilderMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpBuilderMixin() # a collection of rows that would otherwise clutter up every test @@ -632,10 +616,6 @@ def setUp(self): ] yield self.db.insert_test_data(self.base_rows) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_ghp_unclaimed(self): yield self.makeBuilder(name='bldr1') @@ -654,7 +634,7 @@ class TestReconfig(TestReactorMixin, BuilderMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpBuilderMixin() yield self.db.insert_test_data([ @@ -662,10 +642,6 @@ def setUp(self): fakedb.Project(id=302, name='new_project'), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_reconfig(self): yield self.makeBuilder(description="Old", project="old_project", tags=["OldTag"]) diff --git a/master/buildbot/test/unit/process/test_buildrequest.py b/master/buildbot/test/unit/process/test_buildrequest.py index a387c1a85555..9bb75c60ee29 100644 --- a/master/buildbot/test/unit/process/test_buildrequest.py +++ b/master/buildbot/test/unit/process/test_buildrequest.py @@ -30,7 +30,7 @@ class TestBuildRequestCollapser(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True) self.master.botmaster = mock.Mock(name='botmaster') self.master.botmaster.builders = {} @@ -53,10 +53,6 @@ def createBuilder(self, name, builderid=None): return bldr - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_request_collapse(self, brids, exp): brCollapser = buildrequest.BuildRequestCollapser(self.master, brids) @@ -509,11 +505,7 @@ def test_asdict_with_patch(self): class TestBuildRequest(TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_fromBrdict(self): diff --git a/master/buildbot/test/unit/process/test_buildrequestdistributor.py b/master/buildbot/test/unit/process/test_buildrequestdistributor.py index a8421201af90..63f4cc18438a 100644 --- a/master/buildbot/test/unit/process/test_buildrequestdistributor.py +++ b/master/buildbot/test/unit/process/test_buildrequestdistributor.py @@ -47,7 +47,7 @@ def pick_nth_by_name(builder, workers=None, br=None): class TestBRDBase(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.botmaster = mock.Mock(name='botmaster') self.botmaster.builders = {} self.builders = {} @@ -81,10 +81,6 @@ def cleanup(): fakedb.BuildsetSourceStamp(sourcestampid=21, buildsetid=11), ] - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def make_workers(self, worker_count): rows = self.base_rows[:] for i in range(worker_count): diff --git a/master/buildbot/test/unit/process/test_buildstep.py b/master/buildbot/test/unit/process/test_buildstep.py index 95702457521c..15dd8d8c3686 100644 --- a/master/buildbot/test/unit/process/test_buildstep.py +++ b/master/buildbot/test/unit/process/test_buildstep.py @@ -115,13 +115,9 @@ def run(self): return SUCCESS def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # support def _setupWaterfallTest(self, hideStepIf, expect, expectedResult=SUCCESS): @@ -1090,14 +1086,10 @@ def addLogObserver(self, logname, observer): class TestFakeItfc(unittest.TestCase, TestBuildStepMixin, TestReactorMixin, InterfaceTests): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setup_test_build_step() self.setup_step(buildstep.BuildStep()) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestRealItfc(unittest.TestCase, InterfaceTests): def setUp(self): @@ -1118,14 +1110,10 @@ def run(self): class TestCommandMixin(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setup_test_build_step() self.setup_step(CommandMixinExample()) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_runRmdir(self): self.get_nth_step(0).testMethod = lambda: self.get_nth_step(0).runRmdir('/some/path') @@ -1236,13 +1224,9 @@ class TestShellMixin( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setup_test_build_step(with_secrets={"s3cr3t": "really_safe_string"}) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_setupShellMixin_bad_arg(self): mixin = SimpleShellCommand() with self.assertRaisesConfigError("invalid SimpleShellCommand argument invarg"): diff --git a/master/buildbot/test/unit/process/test_debug.py b/master/buildbot/test/unit/process/test_debug.py index 8bcdc01f4a6c..7801120849b2 100644 --- a/master/buildbot/test/unit/process/test_debug.py +++ b/master/buildbot/test/unit/process/test_debug.py @@ -32,14 +32,10 @@ class FakeManhole(service.AsyncService): class TestDebugServices(TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = mock.Mock(name='master') self.config = MasterConfig() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_reconfigService_manhole(self): master = yield fakemaster.make_master(self) diff --git a/master/buildbot/test/unit/process/test_log.py b/master/buildbot/test/unit/process/test_log.py index 7d97f0488589..7ecd7d189715 100644 --- a/master/buildbot/test/unit/process/test_log.py +++ b/master/buildbot/test/unit/process/test_log.py @@ -29,13 +29,9 @@ class Tests(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeLog(self, type, logEncoding='utf-8'): logid = yield self.master.data.updates.addLog(stepid=27, name='testlog', type=str(type)) diff --git a/master/buildbot/test/unit/process/test_logobserver.py b/master/buildbot/test/unit/process/test_logobserver.py index 2097b3be79f5..cb61012606c9 100644 --- a/master/buildbot/test/unit/process/test_logobserver.py +++ b/master/buildbot/test/unit/process/test_logobserver.py @@ -45,13 +45,9 @@ def finishReceived(self): class TestLogObserver(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_sequence(self): logid = yield self.master.data.updates.addLog(1, 'mine', 's') @@ -100,13 +96,9 @@ def finishReceived(self): class TestLineConsumerLogObesrver(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_test_sequence(self, consumer): logid = yield self.master.data.updates.addLog(1, 'mine', 's') @@ -177,13 +169,9 @@ def consumer(): class TestLogLineObserver(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_sequence(self): logid = yield self.master.data.updates.addLog(1, 'mine', 's') @@ -221,13 +209,9 @@ def test_old_setMaxLineLength(self): class TestOutputProgressObserver(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_sequence(self): logid = yield self.master.data.updates.addLog(1, 'mine', 's') @@ -245,13 +229,9 @@ def test_sequence(self): class TestBufferObserver(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_test_sequence(self, lo): logid = yield self.master.data.updates.addLog(1, 'mine', 's') diff --git a/master/buildbot/test/unit/process/test_metrics.py b/master/buildbot/test/unit/process/test_metrics.py index bd72bda6e15c..cd1c3caa4c5c 100644 --- a/master/buildbot/test/unit/process/test_metrics.py +++ b/master/buildbot/test/unit/process/test_metrics.py @@ -28,7 +28,7 @@ class TestMetricBase(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.observer = metrics.MetricLogObserver() self.observer.parent = self.master = yield fakemaster.make_master(self) self.master.config.metrics = {"log_interval": 0, "periodic_interval": 0} @@ -43,10 +43,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestMetricCountEvent(TestMetricBase): def testIncrement(self): diff --git a/master/buildbot/test/unit/process/test_users_manual.py b/master/buildbot/test/unit/process/test_users_manual.py index c8db4514cdf9..7ab66efa5c93 100644 --- a/master/buildbot/test/unit/process/test_users_manual.py +++ b/master/buildbot/test/unit/process/test_users_manual.py @@ -47,13 +47,9 @@ class TestUsersBase(unittest.TestCase): class TestCommandlineUserManagerPerspective(TestReactorMixin, unittest.TestCase, ManualUsersMixin): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpManualUsers() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def call_perspective_commandline(self, *args): persp = manual.CommandlineUserManagerPerspective(self.master) return persp.perspective_commandline(*args) @@ -250,17 +246,13 @@ def test_perspective_commandline_get_no_match_format(self): class TestCommandlineUserManager(TestReactorMixin, unittest.TestCase, ManualUsersMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpManualUsers() self.manual_component = manual.CommandlineUserManager( username="user", passwd="userpw", port="9990" ) yield self.manual_component.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_no_userpass(self): with self.assertRaises(AssertionError): diff --git a/master/buildbot/test/unit/process/test_users_users.py b/master/buildbot/test/unit/process/test_users_users.py index d73956d56d9f..5e987a41e1a9 100644 --- a/master/buildbot/test/unit/process/test_users_users.py +++ b/master/buildbot/test/unit/process/test_users_users.py @@ -28,15 +28,11 @@ class UsersTests(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.db = self.master.db self.test_sha = users.encrypt("cancer") - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def verify_users(self, users): users_no_attrs = copy.deepcopy(users) diff --git a/master/buildbot/test/unit/reporters/test_base.py b/master/buildbot/test/unit/reporters/test_base.py index 7628954de366..046de202aefc 100644 --- a/master/buildbot/test/unit/reporters/test_base.py +++ b/master/buildbot/test/unit/reporters/test_base.py @@ -40,15 +40,11 @@ class TestReporterBase( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.setUpLogging() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setupNotifier(self, generators): mn = ReporterBase(generators=generators) diff --git a/master/buildbot/test/unit/reporters/test_bitbucket.py b/master/buildbot/test/unit/reporters/test_bitbucket.py index 61599b84d4f5..11229ebec5c2 100644 --- a/master/buildbot/test/unit/reporters/test_bitbucket.py +++ b/master/buildbot/test/unit/reporters/test_bitbucket.py @@ -38,7 +38,7 @@ class TestBitbucketStatusPush( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.reporter_test_repo = 'https://example.org/user/repo' @@ -60,10 +60,6 @@ def setUp(self): yield self.bsp.startService() self.addCleanup(self.bsp.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_basic(self): build = yield self.insert_build_new() @@ -272,7 +268,7 @@ class TestBitbucketStatusPushProperties( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.reporter_test_repo = 'https://example.org/user/repo' @@ -309,10 +305,6 @@ def setUp(self): yield self.bsp.startService() self.addCleanup(self.bsp.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_properties(self): build = yield self.insert_build_new() @@ -377,7 +369,7 @@ def test_auth_error(self): class TestBitbucketStatusPushRepoParsing(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) self.bsp = BitbucketStatusPush(Interpolate('key'), Interpolate('secret')) @@ -385,10 +377,6 @@ def setUp(self): yield self.bsp.startService() self.addCleanup(self.bsp.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def parse(self, repourl): return tuple(self.bsp.get_owner_and_repo(repourl)) diff --git a/master/buildbot/test/unit/reporters/test_bitbucketserver.py b/master/buildbot/test/unit/reporters/test_bitbucketserver.py index c5155b4d0dea..3dd6dc92b1ae 100644 --- a/master/buildbot/test/unit/reporters/test_bitbucketserver.py +++ b/master/buildbot/test/unit/reporters/test_bitbucketserver.py @@ -54,7 +54,7 @@ class TestBitbucketServerStatusPush( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() @@ -70,10 +70,6 @@ def setupReporter(self, **kwargs): yield self.sp.setServiceParent(self.master) self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_start_and_finish_build(self, build): self._http.expect( @@ -220,7 +216,7 @@ class TestBitbucketServerCoreAPIStatusPush( ): @defer.inlineCallbacks def setupReporter(self, token=None, **kwargs): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) @@ -257,11 +253,6 @@ def cleanup(): def setUp(self): self.master = None - @defer.inlineCallbacks - def tearDown(self): - if self.master: - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_start_and_finish_build(self, build, parentPlan=False, epoch=False): _name = "Builder_parent #1 \u00bb Builder0 #0" if parentPlan else "Builder0 #0" @@ -636,7 +627,7 @@ class TestBitbucketServerPRCommentPush( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() @@ -672,10 +663,6 @@ def setupReporter(self, verbose=True, generator_class=BuildStatusGenerator, **kw ) yield self.cp.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setupBuildResults(self, buildResults, set_pr=True): yield super().insert_test_data([buildResults], buildResults) diff --git a/master/buildbot/test/unit/reporters/test_generators_build.py b/master/buildbot/test/unit/reporters/test_generators_build.py index c232f546c5c8..5118f39b970b 100644 --- a/master/buildbot/test/unit/reporters/test_generators_build.py +++ b/master/buildbot/test/unit/reporters/test_generators_build.py @@ -35,14 +35,10 @@ class TestBuildGenerator(ConfigErrorsMixin, TestReactorMixin, unittest.TestCase, ReporterTestMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def insert_build_finished_get_props( self, results, add_logs=None, want_logs_content=False, **kwargs @@ -301,14 +297,10 @@ class TestBuildStartEndGenerator( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def insert_build_finished_get_props( self, results, add_logs=None, want_logs_content=False, **kwargs diff --git a/master/buildbot/test/unit/reporters/test_generators_buildrequest.py b/master/buildbot/test/unit/reporters/test_generators_buildrequest.py index 8ddc4ea260e5..6ce7f00216bd 100644 --- a/master/buildbot/test/unit/reporters/test_generators_buildrequest.py +++ b/master/buildbot/test/unit/reporters/test_generators_buildrequest.py @@ -36,7 +36,7 @@ class TestBuildRequestGenerator( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) @@ -44,10 +44,6 @@ def setUp(self): builder.master = self.master self.master.botmaster.getBuilderById = Mock(return_value=builder) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @parameterized.expand([ ('tags', 'tag'), ('tags', 1), diff --git a/master/buildbot/test/unit/reporters/test_generators_buildset.py b/master/buildbot/test/unit/reporters/test_generators_buildset.py index 16e84f64be2f..0777b8dc75b9 100644 --- a/master/buildbot/test/unit/reporters/test_generators_buildset.py +++ b/master/buildbot/test/unit/reporters/test_generators_buildset.py @@ -34,14 +34,10 @@ class TestBuildSetGeneratorBase( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def insert_build_finished_get_props(self, results, **kwargs): build = yield self.insert_build_finished(results, **kwargs) diff --git a/master/buildbot/test/unit/reporters/test_generators_utils.py b/master/buildbot/test/unit/reporters/test_generators_utils.py index 29d1ff539b38..ff06b638885c 100644 --- a/master/buildbot/test/unit/reporters/test_generators_utils.py +++ b/master/buildbot/test/unit/reporters/test_generators_utils.py @@ -36,14 +36,10 @@ class TestBuildGenerator(ConfigErrorsMixin, TestReactorMixin, unittest.TestCase, ReporterTestMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def insert_build_finished_get_props(self, results, **kwargs): build = yield self.insert_build_finished(results, **kwargs) diff --git a/master/buildbot/test/unit/reporters/test_generators_worker.py b/master/buildbot/test/unit/reporters/test_generators_worker.py index 1431f308a88b..d845730bddbe 100644 --- a/master/buildbot/test/unit/reporters/test_generators_worker.py +++ b/master/buildbot/test/unit/reporters/test_generators_worker.py @@ -26,13 +26,9 @@ class TestWorkerMissingGenerator(ConfigErrorsMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def _get_worker_dict(self, worker_name): return { 'name': worker_name, diff --git a/master/buildbot/test/unit/reporters/test_gerrit.py b/master/buildbot/test/unit/reporters/test_gerrit.py index 871cdf205d12..3589f807743f 100644 --- a/master/buildbot/test/unit/reporters/test_gerrit.py +++ b/master/buildbot/test/unit/reporters/test_gerrit.py @@ -122,14 +122,10 @@ def sampleSummaryCBDeferred(buildInfoList, results, master, arg): class TestGerritStatusPush(TestReactorMixin, unittest.TestCase, ReporterTestMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setupGerritStatusPushSimple(self, *args, **kwargs): serv = kwargs.pop("server", "serv") diff --git a/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py b/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py index c81cb38784af..3f4500311303 100644 --- a/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py +++ b/master/buildbot/test/unit/reporters/test_gerrit_verify_status.py @@ -39,7 +39,7 @@ class TestGerritVerifyStatusPush( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.reporter_test_props = {'gerrit_changes': [{'change_id': 12, 'revision_id': 2}]} @@ -58,10 +58,6 @@ def createGerritStatus(self, **kwargs): self.sp = GerritVerifyStatusPush("gerrit", auth=auth, **kwargs) yield self.sp.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_basic(self): yield self.createGerritStatus() diff --git a/master/buildbot/test/unit/reporters/test_github.py b/master/buildbot/test/unit/reporters/test_github.py index c527304b740e..9d6b0e9b024e 100644 --- a/master/buildbot/test/unit/reporters/test_github.py +++ b/master/buildbot/test/unit/reporters/test_github.py @@ -35,7 +35,7 @@ class TestGitHubStatusPush( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() # project must be in the form / @@ -60,10 +60,6 @@ def setUp(self): def createService(self): return GitHubStatusPush(Interpolate('XXYYZZ')) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_basic(self): build = yield self.insert_build_new() @@ -303,7 +299,7 @@ def test_multiple_source_stamps_no_props(self): class TestGitHubStatusPushURL(TestReactorMixin, unittest.TestCase, ReporterTestMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() # project must be in the form / @@ -329,10 +325,6 @@ def setUp(self): def createService(self): return GitHubStatusPush('XXYYZZ') - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_ssh(self): self.reporter_test_repo = 'git@github.com:buildbot2/buildbot2.git' diff --git a/master/buildbot/test/unit/reporters/test_gitlab.py b/master/buildbot/test/unit/reporters/test_gitlab.py index 983e346b81b8..547944ce4d05 100644 --- a/master/buildbot/test/unit/reporters/test_gitlab.py +++ b/master/buildbot/test/unit/reporters/test_gitlab.py @@ -38,7 +38,7 @@ class TestGitLabStatusPush( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() # repository must be in the form http://gitlab// @@ -70,10 +70,6 @@ def setup_properties(props): builder.setup_properties = setup_properties self.master.botmaster.getBuilderById = mock.Mock(return_value=builder) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_buildrequest(self): buildrequest = yield self.insert_buildrequest_new() diff --git a/master/buildbot/test/unit/reporters/test_http.py b/master/buildbot/test/unit/reporters/test_http.py index b82661c72368..3a9a70461b63 100644 --- a/master/buildbot/test/unit/reporters/test_http.py +++ b/master/buildbot/test/unit/reporters/test_http.py @@ -30,7 +30,7 @@ class TestHttpStatusPush(TestReactorMixin, unittest.TestCase, ReporterTestMixin, ConfigErrorsMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) yield self.master.startService() @@ -51,10 +51,6 @@ def createReporter(self, auth=("username", "passwd"), headers=None, **kwargs): self.sp = HttpStatusPush("serv", auth=interpolated_auth, headers=headers, **kwargs) yield self.sp.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_basic(self): yield self.createReporter() diff --git a/master/buildbot/test/unit/reporters/test_mail.py b/master/buildbot/test/unit/reporters/test_mail.py index d80fc82dabe1..780d1fc84056 100644 --- a/master/buildbot/test/unit/reporters/test_mail.py +++ b/master/buildbot/test/unit/reporters/test_mail.py @@ -41,14 +41,10 @@ class TestMailNotifier(ConfigErrorsMixin, TestReactorMixin, unittest.TestCase, ReporterTestMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setupMailNotifier(self, *args, **kwargs): mn = MailNotifier(*args, **kwargs) diff --git a/master/buildbot/test/unit/reporters/test_message.py b/master/buildbot/test/unit/reporters/test_message.py index ae42d8844ad2..5f7361e3e25b 100644 --- a/master/buildbot/test/unit/reporters/test_message.py +++ b/master/buildbot/test/unit/reporters/test_message.py @@ -160,13 +160,9 @@ def test_get_message_source_stamp_text_with_props(self): class MessageFormatterTestBase(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setup_db(self, results1, results2, with_steps=False, extra_build_properties=None): if extra_build_properties is None: diff --git a/master/buildbot/test/unit/reporters/test_pushjet.py b/master/buildbot/test/unit/reporters/test_pushjet.py index fb11bf42175d..556cf7a77526 100644 --- a/master/buildbot/test/unit/reporters/test_pushjet.py +++ b/master/buildbot/test/unit/reporters/test_pushjet.py @@ -34,13 +34,9 @@ class TestPushjetNotifier(ConfigErrorsMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # returns a Deferred def setupFakeHttp(self, base_url='https://api.pushjet.io'): return fakehttpclientservice.HTTPClientService.getService(self.master, self, base_url) diff --git a/master/buildbot/test/unit/reporters/test_pushover.py b/master/buildbot/test/unit/reporters/test_pushover.py index bd8ed88ae179..bc0723ca626a 100644 --- a/master/buildbot/test/unit/reporters/test_pushover.py +++ b/master/buildbot/test/unit/reporters/test_pushover.py @@ -34,13 +34,9 @@ class TestPushoverNotifier(ConfigErrorsMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # returns a Deferred def setupFakeHttp(self): return fakehttpclientservice.HTTPClientService.getService( diff --git a/master/buildbot/test/unit/reporters/test_telegram.py b/master/buildbot/test/unit/reporters/test_telegram.py index 89b7b6c312b7..204466be4d14 100644 --- a/master/buildbot/test/unit/reporters/test_telegram.py +++ b/master/buildbot/test/unit/reporters/test_telegram.py @@ -560,15 +560,11 @@ class TestTelegramService(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.patch(reactor, 'callLater', self.reactor.callLater) self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) self.http = None - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setup_http_service(self): self.http = yield fakehttpclientservice.HTTPClientService.getService( diff --git a/master/buildbot/test/unit/reporters/test_utils.py b/master/buildbot/test/unit/reporters/test_utils.py index 74859eb81e01..d9dfa3334f9d 100644 --- a/master/buildbot/test/unit/reporters/test_utils.py +++ b/master/buildbot/test/unit/reporters/test_utils.py @@ -42,13 +42,9 @@ class TestDataUtils(TestReactorMixin, unittest.TestCase, logging.LoggingMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setupDb(self): self.db = self.master.db @@ -630,13 +626,9 @@ def test_getPreviousBuildWithRetry(self): class TestURLUtils(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_UrlForBuild(self): self.assertEqual( utils.getURLForBuild(self.master, 1, 3), 'http://localhost:8080/#/builders/1/builds/3' diff --git a/master/buildbot/test/unit/reporters/test_words.py b/master/buildbot/test/unit/reporters/test_words.py index fbdec6bdcd2a..ec2af3607b51 100644 --- a/master/buildbot/test/unit/reporters/test_words.py +++ b/master/buildbot/test/unit/reporters/test_words.py @@ -48,7 +48,7 @@ class ContactMixin(TestReactorMixin): @defer.inlineCallbacks def setUp(self) -> Generator[Any, None, None]: - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.patch(reactor, 'callLater', self.reactor.callLater) self.patch(reactor, 'seconds', self.reactor.seconds) self.patch(reactor, 'stop', self.reactor.stop) @@ -95,10 +95,6 @@ def cancelCleanShutdown(): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def patch_send(self): self.sent = [] diff --git a/master/buildbot/test/unit/reporters/test_zulip.py b/master/buildbot/test/unit/reporters/test_zulip.py index b8f406e166c7..116af0de8720 100644 --- a/master/buildbot/test/unit/reporters/test_zulip.py +++ b/master/buildbot/test/unit/reporters/test_zulip.py @@ -30,7 +30,7 @@ class TestZulipStatusPush( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_reporter_test() self.master = yield fakemaster.make_master( testcase=self, wantData=True, wantDb=True, wantMq=True @@ -43,10 +43,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setupZulipStatusPush(self, endpoint="http://example.com", token="123", stream=None): self.sp = ZulipStatusPush(endpoint=endpoint, token=token, stream=stream) diff --git a/master/buildbot/test/unit/schedulers/test_base.py b/master/buildbot/test/unit/schedulers/test_base.py index 57543190109f..e429d18f4e8e 100644 --- a/master/buildbot/test/unit/schedulers/test_base.py +++ b/master/buildbot/test/unit/schedulers/test_base.py @@ -37,13 +37,9 @@ class BaseScheduler(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCas @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeScheduler(self, name='testsched', builderNames=None, properties=None, codebases=None): if builderNames is None: diff --git a/master/buildbot/test/unit/schedulers/test_basic.py b/master/buildbot/test/unit/schedulers/test_basic.py index 44460a6dee13..95cfd7d3223a 100644 --- a/master/buildbot/test/unit/schedulers/test_basic.py +++ b/master/buildbot/test/unit/schedulers/test_basic.py @@ -102,13 +102,9 @@ def getChangeClassificationsForTimer(self, sched_id, timer_name): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def mkch(self, **kwargs): # create changeset and insert in database. @@ -379,13 +375,9 @@ def mkch(self, **kwargs): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_constructor_no_reason(self): sched = yield self.makeScheduler(basic.SingleBranchScheduler, branch="master") @@ -622,13 +614,9 @@ class AnyBranchScheduler( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_constructor_branch_forbidden(self): with self.assertRaises(config.ConfigErrors): basic.SingleBranchScheduler(name="tsched", treeStableTimer=60, branch='x') diff --git a/master/buildbot/test/unit/schedulers/test_canceller.py b/master/buildbot/test/unit/schedulers/test_canceller.py index 8111494e2689..7b221a71237d 100644 --- a/master/buildbot/test/unit/schedulers/test_canceller.py +++ b/master/buildbot/test/unit/schedulers/test_canceller.py @@ -49,7 +49,7 @@ def test_multiple_filters_on_builder(self, name, builder, props, expected): class TestOldBuildrequestTracker(unittest.TestCase, TestReactorMixin): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() filter = _OldBuildFilterSet() ss_filter = SourceStampFilter( @@ -61,10 +61,6 @@ def setUp(self): self.reactor, filter, lambda ss: ss['branch'], self.on_cancel ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def on_cancel(self, brid): self.cancellations.append(brid) @@ -388,7 +384,7 @@ def test_check_builders_keys_not_list(self, name, value, error): class TestOldBuildCanceller(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True, wantDb=True) self.master.mq.verifyMessages = False @@ -398,10 +394,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def create_ss_dict(self, project, codebase, repository, branch): # Changes have the same structure for the attributes that we're using, so we reuse this # function for changes. diff --git a/master/buildbot/test/unit/schedulers/test_canceller_buildset.py b/master/buildbot/test/unit/schedulers/test_canceller_buildset.py index 0b01e60cfc3f..f90de85cd317 100644 --- a/master/buildbot/test/unit/schedulers/test_canceller_buildset.py +++ b/master/buildbot/test/unit/schedulers/test_canceller_buildset.py @@ -28,7 +28,7 @@ class TestOldBuildCanceller(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True, wantDb=True) self.master.mq.verifyMessages = False @@ -38,10 +38,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def insert_test_data(self): yield self.master.db.insert_test_data([ diff --git a/master/buildbot/test/unit/schedulers/test_dependent.py b/master/buildbot/test/unit/schedulers/test_dependent.py index ba61f7a4470b..d04fca8aa8d7 100644 --- a/master/buildbot/test/unit/schedulers/test_dependent.py +++ b/master/buildbot/test/unit/schedulers/test_dependent.py @@ -38,13 +38,9 @@ class Dependent(scheduler.SchedulerMixin, TestReactorMixin, StateTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeScheduler(self, upstream=None): # build a fake upstream scheduler diff --git a/master/buildbot/test/unit/schedulers/test_forcesched.py b/master/buildbot/test/unit/schedulers/test_forcesched.py index 5d78e7de696a..6667a5c185d1 100644 --- a/master/buildbot/test/unit/schedulers/test_forcesched.py +++ b/master/buildbot/test/unit/schedulers/test_forcesched.py @@ -48,13 +48,9 @@ class TestForceScheduler( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeScheduler(self, name='testsched', builderNames=None, **kw): if builderNames is None: diff --git a/master/buildbot/test/unit/schedulers/test_timed_Nightly.py b/master/buildbot/test/unit/schedulers/test_timed_Nightly.py index 45c2369d62c1..45b56f73b056 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_Nightly.py +++ b/master/buildbot/test/unit/schedulers/test_timed_Nightly.py @@ -119,13 +119,9 @@ def mkch(self, **kwargs): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertConsumingChanges(self, **kwargs): self.assertEqual(self.consumingChanges, kwargs) diff --git a/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py b/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py index 8e2b0502feac..254172b3f960 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py +++ b/master/buildbot/test/unit/schedulers/test_timed_NightlyBase.py @@ -31,13 +31,9 @@ class NightlyBase(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCase) @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeScheduler(self, firstBuildDuration=0, **kwargs): return self.attachScheduler(timed.NightlyBase(**kwargs), self.OBJECTID, self.SCHEDULERID) diff --git a/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py b/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py index f7d953da5724..8342548cca58 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py +++ b/master/buildbot/test/unit/schedulers/test_timed_NightlyTriggerable.py @@ -48,13 +48,9 @@ def makeScheduler(self, firstBuildDuration=0, **kwargs): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # utilities def assertBuildsetAdded(self, sourcestamps=None, properties=None): diff --git a/master/buildbot/test/unit/schedulers/test_timed_Periodic.py b/master/buildbot/test/unit/schedulers/test_timed_Periodic.py index f8e79b16aa1b..135b4936c454 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_Periodic.py +++ b/master/buildbot/test/unit/schedulers/test_timed_Periodic.py @@ -33,13 +33,9 @@ class Periodic(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeScheduler(self, firstBuildDuration=0, firstBuildError=False, exp_branch=None, **kwargs): self.sched = sched = timed.Periodic(**kwargs) diff --git a/master/buildbot/test/unit/schedulers/test_timed_Timed.py b/master/buildbot/test/unit/schedulers/test_timed_Timed.py index 113dd5c18ae8..70fde9786555 100644 --- a/master/buildbot/test/unit/schedulers/test_timed_Timed.py +++ b/master/buildbot/test/unit/schedulers/test_timed_Timed.py @@ -27,13 +27,9 @@ class Timed(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class Subclass(timed.Timed): def getNextBuildTime(self, lastActuation): self.got_lastActuation = lastActuation diff --git a/master/buildbot/test/unit/schedulers/test_triggerable.py b/master/buildbot/test/unit/schedulers/test_triggerable.py index e57c502b09df..ac6f205fb1cc 100644 --- a/master/buildbot/test/unit/schedulers/test_triggerable.py +++ b/master/buildbot/test/unit/schedulers/test_triggerable.py @@ -38,17 +38,13 @@ class Triggerable(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCase) @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() # Necessary to get an assertable submitted_at time. self.reactor.advance(946684799) yield self.setUpScheduler() self.subscription = None - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeScheduler(self, overrideBuildsetMethods=False, **kwargs): yield self.master.db.insert_test_data([fakedb.Builder(id=77, name='b')]) diff --git a/master/buildbot/test/unit/schedulers/test_trysched.py b/master/buildbot/test/unit/schedulers/test_trysched.py index 1a3c639efc2f..91d38c4b62b6 100644 --- a/master/buildbot/test/unit/schedulers/test_trysched.py +++ b/master/buildbot/test/unit/schedulers/test_trysched.py @@ -35,13 +35,9 @@ class TryBase(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeScheduler(self, **kwargs): return self.attachScheduler( trysched.Try_Userpass(**kwargs), self.OBJECTID, self.SCHEDULERID @@ -128,15 +124,13 @@ class Try_Jobdir(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() self.jobdir = None - @defer.inlineCallbacks def tearDown(self): if self.jobdir: shutil.rmtree(self.jobdir) - yield self.tear_down_test_reactor() # tests @@ -876,13 +870,9 @@ class Try_Userpass_Perspective(scheduler.SchedulerMixin, TestReactorMixin, unitt @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeScheduler(self, **kwargs): return self.attachScheduler( trysched.Try_Userpass(**kwargs), @@ -1054,13 +1044,9 @@ class Try_Userpass(scheduler.SchedulerMixin, TestReactorMixin, unittest.TestCase @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpScheduler() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def makeScheduler(self, **kwargs): sched = yield self.attachScheduler( diff --git a/master/buildbot/test/unit/scripts/test_cleanupdb.py b/master/buildbot/test/unit/scripts/test_cleanupdb.py index c96069b1b45b..295a090205d1 100644 --- a/master/buildbot/test/unit/scripts/test_cleanupdb.py +++ b/master/buildbot/test/unit/scripts/test_cleanupdb.py @@ -87,15 +87,11 @@ class TestCleanupDb( misc.StdoutAssertionsMixin, dirs.DirsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpDirs('basedir') write_buildbot_tac(os.path.join('basedir', 'buildbot.tac')) self.setUpStdoutAssertions() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def createMasterCfg(self, extraconfig=""): write_master_cfg(os.path.join('basedir', 'master.cfg'), 'sqlite://', extraconfig) @@ -127,7 +123,7 @@ class TestCleanupDbRealDb( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpDirs('basedir') write_buildbot_tac(os.path.join('basedir', 'buildbot.tac')) self.setUpStdoutAssertions() @@ -136,10 +132,6 @@ def setUp(self): self, wantDb=True, wantRealReactor=True, sqlite_memory=False ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def createMasterCfg(self, db_url, extraconfig=""): write_master_cfg(os.path.join('basedir', 'master.cfg'), db_url, extraconfig) diff --git a/master/buildbot/test/unit/scripts/test_copydb.py b/master/buildbot/test/unit/scripts/test_copydb.py index 2f680e722f39..7b457b176cab 100644 --- a/master/buildbot/test/unit/scripts/test_copydb.py +++ b/master/buildbot/test/unit/scripts/test_copydb.py @@ -57,15 +57,11 @@ def write_buildbot_tac(path): class TestCopyDb(misc.StdoutAssertionsMixin, dirs.DirsMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpDirs('basedir') write_buildbot_tac(os.path.join('basedir', 'buildbot.tac')) self.setUpStdoutAssertions() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def create_master_cfg(self, db_url='sqlite://', extraconfig=""): with open(os.path.join('basedir', 'master.cfg'), "w", encoding='utf-8') as f: f.write( diff --git a/master/buildbot/test/unit/scripts/test_create_master.py b/master/buildbot/test/unit/scripts/test_create_master.py index 3edf9831a396..a5a8b343ac1f 100644 --- a/master/buildbot/test/unit/scripts/test_create_master.py +++ b/master/buildbot/test/unit/scripts/test_create_master.py @@ -91,15 +91,11 @@ class TestCreateMasterFunctions( unittest.TestCase, ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpDirs('test') self.basedir = os.path.abspath(os.path.join('test', 'basedir')) self.setUpStdoutAssertions() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertInTacFile(self, str): with open(os.path.join('test', 'buildbot.tac'), encoding='utf-8') as f: content = f.read() diff --git a/master/buildbot/test/unit/scripts/test_logwatcher.py b/master/buildbot/test/unit/scripts/test_logwatcher.py index a4952bc08969..79da7773fca1 100644 --- a/master/buildbot/test/unit/scripts/test_logwatcher.py +++ b/master/buildbot/test/unit/scripts/test_logwatcher.py @@ -47,14 +47,10 @@ class TestLogWatcher(unittest.TestCase, dirs.DirsMixin, TestReactorMixin): def setUp(self): self.setUpDirs('workdir') - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.spawned_process = mock.Mock() self.reactor.spawnProcess = mock.Mock(return_value=self.spawned_process) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_start(self): lw = MockedLogWatcher('workdir/test.log', _reactor=self.reactor) lw._start = mock.Mock() diff --git a/master/buildbot/test/unit/scripts/test_upgrade_master.py b/master/buildbot/test/unit/scripts/test_upgrade_master.py index 692076289418..cd1f5af4828c 100644 --- a/master/buildbot/test/unit/scripts/test_upgrade_master.py +++ b/master/buildbot/test/unit/scripts/test_upgrade_master.py @@ -114,15 +114,11 @@ class TestUpgradeMasterFunctions( unittest.TestCase, ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpDirs('test') self.basedir = os.path.abspath(os.path.join('test', 'basedir')) self.setUpStdoutAssertions() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def writeFile(self, path, contents): with open(path, "w", encoding='utf-8') as f: f.write(contents) diff --git a/master/buildbot/test/unit/steps/test_cmake.py b/master/buildbot/test/unit/steps/test_cmake.py index aba36c91a7ea..449174dfddda 100644 --- a/master/buildbot/test/unit/steps/test_cmake.py +++ b/master/buildbot/test/unit/steps/test_cmake.py @@ -28,13 +28,9 @@ class TestCMake(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def expect_and_run_command(self, *params): command = [CMake.DEFAULT_CMAKE, *list(params)] diff --git a/master/buildbot/test/unit/steps/test_cppcheck.py b/master/buildbot/test/unit/steps/test_cppcheck.py index 48f4c50dcd7d..08bb12566ad5 100644 --- a/master/buildbot/test/unit/steps/test_cppcheck.py +++ b/master/buildbot/test/unit/steps/test_cppcheck.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot.process.properties import WithProperties @@ -28,13 +27,9 @@ class Cppcheck(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_success(self): self.setup_step(cppcheck.Cppcheck(enable=['all'], inconclusive=True)) self.expect_commands( diff --git a/master/buildbot/test/unit/steps/test_http.py b/master/buildbot/test/unit/steps/test_http.py index 6a06e5ced9f7..4cf24b345bdc 100644 --- a/master/buildbot/test/unit/steps/test_http.py +++ b/master/buildbot/test/unit/steps/test_http.py @@ -66,7 +66,7 @@ def render_POST(self, request): class TestHTTPStep(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() if txrequests is None: raise unittest.SkipTest("Need to install txrequests to test http steps") @@ -86,10 +86,6 @@ def setUp(self): self.port = self.listener.getHost().port return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def get_connection_string(self): return f"http://127.0.0.1:{self.port}" diff --git a/master/buildbot/test/unit/steps/test_master.py b/master/buildbot/test/unit/steps/test_master.py index 0b350750ead0..a3e78ac4dc33 100644 --- a/master/buildbot/test/unit/steps/test_master.py +++ b/master/buildbot/test/unit/steps/test_master.py @@ -36,20 +36,18 @@ class TestMasterShellCommand(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() if runtime.platformType == 'win32': self.comspec = os.environ.get(_COMSPEC_ENV) os.environ[_COMSPEC_ENV] = r'C:\WINDOWS\system32\cmd.exe' return self.setup_test_build_step() - @defer.inlineCallbacks def tearDown(self): if runtime.platformType == 'win32': if self.comspec: os.environ[_COMSPEC_ENV] = self.comspec else: del os.environ[_COMSPEC_ENV] - yield self.tear_down_test_reactor() def test_constr_args(self): self.setup_step( @@ -169,13 +167,9 @@ def test_constr_args_descriptionSuffix(self): class TestSetProperty(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_simple(self): self.setup_step( master.SetProperty( @@ -192,13 +186,9 @@ def test_simple(self): class TestLogRenderable(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_simple(self): self.setup_step( master.LogRenderable( @@ -214,13 +204,9 @@ def test_simple(self): class TestsSetProperties(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def doOneTest(self, **kwargs): # all three tests should create a 'a' property with 'b' value, all with different # more or less dynamic methods @@ -246,13 +232,9 @@ def manipulate(props): class TestAssert(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_eq_pass(self): self.setup_step(master.Assert(Property("test_prop") == "foo")) self.build.setProperty("test_prop", "foo", "bar") diff --git a/master/buildbot/test/unit/steps/test_maxq.py b/master/buildbot/test/unit/steps/test_maxq.py index 7aaf40707c9c..1adacca77822 100644 --- a/master/buildbot/test/unit/steps/test_maxq.py +++ b/master/buildbot/test/unit/steps/test_maxq.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot import config @@ -27,13 +26,9 @@ class TestShellCommandExecution(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_testdir_required(self): with self.assertRaises(config.ConfigErrors): maxq.MaxQ() diff --git a/master/buildbot/test/unit/steps/test_mswin.py b/master/buildbot/test/unit/steps/test_mswin.py index 258092ff4c0a..cdaf234171ee 100644 --- a/master/buildbot/test/unit/steps/test_mswin.py +++ b/master/buildbot/test/unit/steps/test_mswin.py @@ -35,13 +35,9 @@ class TestRobocopySimple(TestBuildStepMixin, TestReactorMixin, unittest.TestCase """ def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def _run_simple_test( self, source, diff --git a/master/buildbot/test/unit/steps/test_package_deb_lintian.py b/master/buildbot/test/unit/steps/test_package_deb_lintian.py index c73c63463681..92fa7de36da0 100644 --- a/master/buildbot/test/unit/steps/test_package_deb_lintian.py +++ b/master/buildbot/test/unit/steps/test_package_deb_lintian.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot import config @@ -26,13 +25,9 @@ class TestDebLintian(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_fileloc(self): with self.assertRaises(config.ConfigErrors): lintian.DebLintian() diff --git a/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py b/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py index 46ad7edfd9fa..279c64680555 100644 --- a/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py +++ b/master/buildbot/test/unit/steps/test_package_deb_pbuilder.py @@ -15,7 +15,6 @@ import time -from twisted.internet import defer from twisted.trial import unittest from buildbot import config @@ -31,13 +30,9 @@ class TestDebPbuilder(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_new(self): self.setup_step(pbuilder.DebPbuilder()) self.expect_commands( @@ -490,13 +485,9 @@ def test_othermirror(self): class TestDebCowbuilder(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_new(self): self.setup_step(pbuilder.DebCowbuilder()) self.expect_commands( @@ -642,13 +633,9 @@ def test_buildonly_reg(self): class TestUbuPbuilder(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_distribution(self): with self.assertRaises(config.ConfigErrors): pbuilder.UbuPbuilder() @@ -695,13 +682,9 @@ def test_new(self): class TestUbuCowbuilder(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_distribution(self): with self.assertRaises(config.ConfigErrors): pbuilder.UbuCowbuilder() diff --git a/master/buildbot/test/unit/steps/test_package_rpm_mock.py b/master/buildbot/test/unit/steps/test_package_rpm_mock.py index 885d9ef428b7..0ad7130b5a36 100644 --- a/master/buildbot/test/unit/steps/test_package_rpm_mock.py +++ b/master/buildbot/test/unit/steps/test_package_rpm_mock.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot import config @@ -28,7 +27,7 @@ class TestMock(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() def test_no_root(self): @@ -106,13 +105,9 @@ def test_resultdir_renderable(self): class TestMockBuildSRPM(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_spec(self): with self.assertRaises(config.ConfigErrors): mock.MockBuildSRPM(root='TESTROOT') @@ -148,13 +143,9 @@ def test_success(self): class TestMockRebuild(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_srpm(self): with self.assertRaises(config.ConfigErrors): mock.MockRebuild(root='TESTROOT') diff --git a/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py b/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py index 7893841e9d51..9c16bf2b3222 100644 --- a/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py +++ b/master/buildbot/test/unit/steps/test_package_rpm_rpmbuild.py @@ -30,13 +30,9 @@ class RpmBuild(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_specfile(self): with self.assertRaises(config.ConfigErrors): rpmbuild.RpmBuild() diff --git a/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py b/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py index 2ec0e82e337f..cbb5d959b049 100644 --- a/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py +++ b/master/buildbot/test/unit/steps/test_package_rpm_rpmlint.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot.process.results import SUCCESS @@ -25,13 +24,9 @@ class TestRpmLint(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_success(self): self.setup_step(rpmlint.RpmLint()) self.expect_commands(ExpectShell(workdir='wkdir', command=['rpmlint', '-i', '.']).exit(0)) diff --git a/master/buildbot/test/unit/steps/test_python.py b/master/buildbot/test/unit/steps/test_python.py index 8329a1fb0220..ca4c79f7a3ce 100644 --- a/master/buildbot/test/unit/steps/test_python.py +++ b/master/buildbot/test/unit/steps/test_python.py @@ -125,13 +125,9 @@ class BuildEPYDoc(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_sample(self): self.setup_step(python.BuildEPYDoc()) self.expect_commands( @@ -143,13 +139,9 @@ def test_sample(self): class PyLint(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @parameterized.expand([('no_results', True), ('with_results', False)]) def test_success(self, name, store_results): self.setup_step(python.PyLint(command=['pylint'], store_results=store_results)) @@ -441,13 +433,9 @@ def test_regex_parseable_1_3_1(self): class PyFlakes(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_success(self): self.setup_step(python.PyFlakes()) self.expect_commands(ExpectShell(workdir='wkdir', command=['make', 'pyflakes']).exit(0)) @@ -528,13 +516,9 @@ def test_misc(self): class TestSphinx(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_builddir_required(self): with self.assertRaises(config.ConfigErrors): python.Sphinx() diff --git a/master/buildbot/test/unit/steps/test_python_twisted.py b/master/buildbot/test/unit/steps/test_python_twisted.py index 44475fd60b79..6b34095f2406 100644 --- a/master/buildbot/test/unit/steps/test_python_twisted.py +++ b/master/buildbot/test/unit/steps/test_python_twisted.py @@ -15,7 +15,6 @@ import textwrap -from twisted.internet import defer from twisted.trial import unittest from buildbot.process.properties import Property @@ -94,13 +93,9 @@ class Trial(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_run_env(self): self.setup_step( python_twisted.Trial( @@ -399,13 +394,9 @@ def test_run_jobsProperties(self): class HLint(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_run_ok(self): self.setup_build(build_files=['foo.xhtml']) self.setup_step(python_twisted.HLint(workdir='build')) @@ -469,13 +460,9 @@ def test_run_warnings(self): class RemovePYCs(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_run_ok(self): self.setup_step(python_twisted.RemovePYCs()) self.expect_commands( diff --git a/master/buildbot/test/unit/steps/test_renderable.py b/master/buildbot/test/unit/steps/test_renderable.py index 0ace8fd96a7f..1a9b22132435 100644 --- a/master/buildbot/test/unit/steps/test_renderable.py +++ b/master/buildbot/test/unit/steps/test_renderable.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot.process.buildstep import BuildStep @@ -33,13 +32,9 @@ class TestBuildStepNameIsRenderable( TestBuildStepMixin, unittest.TestCase, TestReactorMixin, configmixin.ConfigErrorsMixin ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_name_is_renderable(self): step = TestBuildStep(name=Interpolate('%(kw:foo)s', foo='bar')) self.setup_step(step) diff --git a/master/buildbot/test/unit/steps/test_shell.py b/master/buildbot/test/unit/steps/test_shell.py index 23a853f9762e..da8deed00a82 100644 --- a/master/buildbot/test/unit/steps/test_shell.py +++ b/master/buildbot/test/unit/steps/test_shell.py @@ -40,13 +40,9 @@ class TestShellCommandExecution( TestBuildStepMixin, configmixin.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_doStepIf_False(self): self.setup_step(shell.ShellCommand(command="echo hello", doStepIf=False)) self.expect_outcome(result=SKIPPED, state_string="'echo hello' (skipped)") @@ -181,13 +177,9 @@ def test_missing_command_error(self): class TreeSize(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_run_success(self): self.setup_step(shell.TreeSize()) self.expect_commands( @@ -218,13 +210,9 @@ def test_run_failed(self): class SetPropertyFromCommand(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_constructor_conflict(self): with self.assertRaises(config.ConfigErrors): shell.SetPropertyFromCommand(property='foo', extract_fn=lambda: None) @@ -352,13 +340,9 @@ def test_error_none_set(self): class PerlModuleTest(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_new_version_success(self): self.setup_step(shell.PerlModuleTest(command="cmd")) self.expect_commands( @@ -466,13 +450,9 @@ def test_old_version_failed(self): class Configure(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_class_attrs(self): step = shell.Configure() self.assertEqual(step.command, ['./configure']) @@ -489,13 +469,9 @@ class WarningCountingShellCommand( TestBuildStepMixin, configmixin.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_warnings(self): self.setup_step(shell.WarningCountingShellCommand(workdir='w', command=['make'])) self.expect_commands( @@ -818,13 +794,9 @@ def test_missing_command_error(self): class Compile(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_class_args(self): # since this step is just a pre-configured WarningCountingShellCommand, # there' not much to test! @@ -839,13 +811,9 @@ def test_class_args(self): class Test(TestBuildStepMixin, configmixin.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_setTestResults(self): step = self.setup_step(shell.Test()) step.setTestResults(total=10, failed=3, passed=5, warnings=3) diff --git a/master/buildbot/test/unit/steps/test_source_base_Source.py b/master/buildbot/test/unit/steps/test_source_base_Source.py index cf6ba0bd830a..c80dae4fa64d 100644 --- a/master/buildbot/test/unit/steps/test_source_base_Source.py +++ b/master/buildbot/test/unit/steps/test_source_base_Source.py @@ -32,13 +32,9 @@ def startVC(self): class TestSource(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def setup_deferred_mock(self): m = mock.Mock() @@ -169,13 +165,9 @@ def test_old_style_source_step_throws_exception(self): class TestSourceDescription(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_constructor_args_strings(self): step = Source( workdir='build', description='svn update (running)', descriptionDone='svn update' @@ -206,13 +198,9 @@ def mode_incremental(self): class TestSourceAttrGroup(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_attrgroup_hasattr(self): step = AttrGroup() self.assertTrue(step._hasAttrGroupMember('mode', 'full')) diff --git a/master/buildbot/test/unit/steps/test_source_bzr.py b/master/buildbot/test/unit/steps/test_source_bzr.py index 18255685aee9..d2efdf6c562a 100644 --- a/master/buildbot/test/unit/steps/test_source_bzr.py +++ b/master/buildbot/test/unit/steps/test_source_bzr.py @@ -16,7 +16,6 @@ import os -from twisted.internet import defer from twisted.internet import error from twisted.python.reflect import namedModule from twisted.trial import unittest @@ -38,13 +37,9 @@ class TestBzr(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_mode_full(self): self.setup_step( bzr.Bzr( diff --git a/master/buildbot/test/unit/steps/test_source_cvs.py b/master/buildbot/test/unit/steps/test_source_cvs.py index 4aab14969117..379f76d35518 100644 --- a/master/buildbot/test/unit/steps/test_source_cvs.py +++ b/master/buildbot/test/unit/steps/test_source_cvs.py @@ -15,7 +15,6 @@ import time -from twisted.internet import defer from twisted.internet import error from twisted.trial import unittest @@ -38,13 +37,9 @@ class TestCVS(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def setup_step(self, step, *args, **kwargs): super().setup_step(step, *args, **kwargs) diff --git a/master/buildbot/test/unit/steps/test_source_darcs.py b/master/buildbot/test/unit/steps/test_source_darcs.py index 36ff9e890f1f..6eff2db74dbe 100644 --- a/master/buildbot/test/unit/steps/test_source_darcs.py +++ b/master/buildbot/test/unit/steps/test_source_darcs.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.internet import error from twisted.trial import unittest @@ -34,13 +33,9 @@ class TestDarcs(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_no_empty_step_config(self): with self.assertRaises(config.ConfigErrors): darcs.Darcs() diff --git a/master/buildbot/test/unit/steps/test_source_gerrit.py b/master/buildbot/test/unit/steps/test_source_gerrit.py index 417431acb98c..69d8d3b23916 100644 --- a/master/buildbot/test/unit/steps/test_source_gerrit.py +++ b/master/buildbot/test/unit/steps/test_source_gerrit.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot.process.results import SUCCESS @@ -30,13 +29,9 @@ class TestGerrit( sourcesteps.SourceStepMixin, config.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_mode_full_clean(self): self.setup_step( gerrit.Gerrit( diff --git a/master/buildbot/test/unit/steps/test_source_git.py b/master/buildbot/test/unit/steps/test_source_git.py index 8ecc4321ae0c..52d45af1456d 100644 --- a/master/buildbot/test/unit/steps/test_source_git.py +++ b/master/buildbot/test/unit/steps/test_source_git.py @@ -48,14 +48,10 @@ class TestGit( stepClass = git.Git def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.sourceName = self.stepClass.__name__ return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_mode_full_filters_2_26(self): self.setup_step( self.stepClass( @@ -4753,16 +4749,12 @@ class TestGitCommit( stepClass = git.GitCommit def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.message_list = ['my commit', '42'] self.path_list = ['file1.txt', 'file2.txt'] return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_add_fail(self): self.setup_step( self.stepClass(workdir='wkdir', paths=self.path_list, messages=self.message_list) diff --git a/master/buildbot/test/unit/steps/test_source_gitlab.py b/master/buildbot/test/unit/steps/test_source_gitlab.py index 768a6fe0f80b..3231bce2dfc3 100644 --- a/master/buildbot/test/unit/steps/test_source_gitlab.py +++ b/master/buildbot/test/unit/steps/test_source_gitlab.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot.process.results import SUCCESS @@ -32,7 +31,7 @@ class TestGitLab( stepClass = gitlab.GitLab def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.sourceName = self.stepClass.__name__ return self.setUpSourceStep() @@ -54,10 +53,6 @@ def setup_step(self, step, args, **kwargs): step.build.properties.setProperty("target_project_id", 239, "gitlab target project ID") return step - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_with_merge_branch(self): self.setup_step( self.stepClass( diff --git a/master/buildbot/test/unit/steps/test_source_mercurial.py b/master/buildbot/test/unit/steps/test_source_mercurial.py index 9b234784286b..d5bb1345fdf0 100644 --- a/master/buildbot/test/unit/steps/test_source_mercurial.py +++ b/master/buildbot/test/unit/steps/test_source_mercurial.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.internet import error from twisted.python.reflect import namedModule from twisted.trial import unittest @@ -35,13 +34,9 @@ class TestMercurial(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def patch_workerVersionIsOlderThan(self, result): self.patch(mercurial.Mercurial, 'workerVersionIsOlderThan', lambda x, y, z: result) diff --git a/master/buildbot/test/unit/steps/test_source_mtn.py b/master/buildbot/test/unit/steps/test_source_mtn.py index bd3b795d74e3..3ad9439cb698 100644 --- a/master/buildbot/test/unit/steps/test_source_mtn.py +++ b/master/buildbot/test/unit/steps/test_source_mtn.py @@ -14,7 +14,6 @@ # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.internet import error from twisted.trial import unittest @@ -42,13 +41,9 @@ class TestMonotone( MTN_VER = 'monotone 1.0 (base revision: UNKNOWN_REV)' def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_mode_full_clean(self): self.setup_step( mtn.Monotone( diff --git a/master/buildbot/test/unit/steps/test_source_p4.py b/master/buildbot/test/unit/steps/test_source_p4.py index 93ad7852028a..f5efa02d576a 100644 --- a/master/buildbot/test/unit/steps/test_source_p4.py +++ b/master/buildbot/test/unit/steps/test_source_p4.py @@ -17,7 +17,6 @@ import platform import textwrap -from twisted.internet import defer from twisted.internet import error from twisted.python import reflect from twisted.trial import unittest @@ -37,13 +36,9 @@ class TestP4(sourcesteps.SourceStepMixin, TestReactorMixin, ConfigErrorsMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def setup_step(self, step, args=None, patch=None, **kwargs): if args is None: args = {} diff --git a/master/buildbot/test/unit/steps/test_source_repo.py b/master/buildbot/test/unit/steps/test_source_repo.py index d4a00f5a43c1..02e714b77205 100644 --- a/master/buildbot/test/unit/steps/test_source_repo.py +++ b/master/buildbot/test/unit/steps/test_source_repo.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot.changes.changes import Change @@ -61,15 +60,11 @@ def test_parse3(self): class TestRepo(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.shouldRetry = False self.logEnviron = True return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def shouldLogEnviron(self): r = self.logEnviron self.logEnviron = False diff --git a/master/buildbot/test/unit/steps/test_source_svn.py b/master/buildbot/test/unit/steps/test_source_svn.py index 4bf40076d732..129121f83d8e 100644 --- a/master/buildbot/test/unit/steps/test_source_svn.py +++ b/master/buildbot/test/unit/steps/test_source_svn.py @@ -121,13 +121,9 @@ class TestSVN(sourcesteps.SourceStepMixin, TestReactorMixin, unittest.TestCase): """ def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setUpSourceStep() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def patch_workerVersionIsOlderThan(self, result): self.patch(svn.SVN, 'workerVersionIsOlderThan', lambda x, y, z: result) diff --git a/master/buildbot/test/unit/steps/test_subunit.py b/master/buildbot/test/unit/steps/test_subunit.py index cf77c2bd4d08..45c7ba68c6b4 100644 --- a/master/buildbot/test/unit/steps/test_subunit.py +++ b/master/buildbot/test/unit/steps/test_subunit.py @@ -17,7 +17,6 @@ import re import sys -from twisted.internet import defer from twisted.trial import unittest from buildbot.process.results import FAILURE @@ -56,13 +55,9 @@ def setUp(self): if TestProtocolClient is None: raise unittest.SkipTest("Need to install python-subunit to test subunit step") - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_empty(self): self.setup_step(subunit.SubunitShellCommand(command='test')) self.expect_commands(ExpectShell(workdir='wkdir', command="test").exit(0)) diff --git a/master/buildbot/test/unit/steps/test_transfer.py b/master/buildbot/test/unit/steps/test_transfer.py index fe25e955dae8..c2b317e0463e 100644 --- a/master/buildbot/test/unit/steps/test_transfer.py +++ b/master/buildbot/test/unit/steps/test_transfer.py @@ -43,17 +43,15 @@ class TestFileUpload(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() fd, self.destfile = tempfile.mkstemp() os.close(fd) os.unlink(self.destfile) return self.setup_test_build_step() - @defer.inlineCallbacks def tearDown(self): if os.path.exists(self.destfile): os.unlink(self.destfile) - yield self.tear_down_test_reactor() def testConstructorModeType(self): with self.assertRaises(config.ConfigErrors): @@ -310,20 +308,17 @@ def test_init_positional_args(self): class TestDirectoryUpload(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.destdir = os.path.abspath('destdir') if os.path.exists(self.destdir): shutil.rmtree(self.destdir) return self.setup_test_build_step() - @defer.inlineCallbacks def tearDown(self): if os.path.exists(self.destdir): shutil.rmtree(self.destdir) - yield self.tear_down_test_reactor() - def testBasic(self): self.setup_step(transfer.DirectoryUpload(workersrc="srcdir", masterdest=self.destdir)) @@ -495,20 +490,17 @@ def test_init_positional_args(self): class TestMultipleFileUpload(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.destdir = os.path.abspath('destdir') if os.path.exists(self.destdir): shutil.rmtree(self.destdir) return self.setup_test_build_step() - @defer.inlineCallbacks def tearDown(self): if os.path.exists(self.destdir): shutil.rmtree(self.destdir) - yield self.tear_down_test_reactor() - def testEmpty(self): self.setup_step(transfer.MultipleFileUpload(workersrcs=[], masterdest=self.destdir)) @@ -939,19 +931,16 @@ def test_init_positional_args(self): class TestFileDownload(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() fd, self.destfile = tempfile.mkstemp() os.close(fd) os.unlink(self.destfile) return self.setup_test_build_step() - @defer.inlineCallbacks def tearDown(self): if os.path.exists(self.destfile): os.unlink(self.destfile) - yield self.tear_down_test_reactor() - def test_init_workerdest_keyword(self): step = transfer.FileDownload(mastersrc='srcfile', workerdest='dstfile') @@ -1051,13 +1040,9 @@ def test_no_file(self): class TestStringDownload(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # check that ConfigErrors is raised on invalid 'mode' argument def testModeConfError(self): @@ -1160,13 +1145,9 @@ def test_init_positional_args(self): class TestJSONStringDownload(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def testBasic(self): msg = {"message": 'Hello World'} @@ -1262,13 +1243,9 @@ def test_init_positional_args(self): class TestJSONPropertiesDownload(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def testBasic(self): self.setup_step(transfer.JSONPropertiesDownload("props.json")) diff --git a/master/buildbot/test/unit/steps/test_trigger.py b/master/buildbot/test/unit/steps/test_trigger.py index ef97df2bab02..996534786ee0 100644 --- a/master/buildbot/test/unit/steps/test_trigger.py +++ b/master/buildbot/test/unit/steps/test_trigger.py @@ -100,13 +100,9 @@ def BRID_TO_BUILD_NUMBER(brid): class TestTrigger(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setup_step(self, step, sourcestampsInBuild=None, gotRevisionsInBuild=None, *args, **kwargs): sourcestamps = sourcestampsInBuild or [] diff --git a/master/buildbot/test/unit/steps/test_vstudio.py b/master/buildbot/test/unit/steps/test_vstudio.py index f2bb9e814f3c..a0cc58d5175f 100644 --- a/master/buildbot/test/unit/steps/test_vstudio.py +++ b/master/buildbot/test/unit/steps/test_vstudio.py @@ -228,13 +228,9 @@ class VisualStudio(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): """ def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_default_config(self): vs = vstudio.VisualStudio() self.assertEqual(vs.config, 'release') @@ -350,13 +346,9 @@ def test_rendering(self): class TestVC6(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def getExpectedEnv(self, installdir, LIB=None, p=None, i=None): include = [ installdir + r'\VC98\INCLUDE;', @@ -449,13 +441,9 @@ def test_env_prepend(self): class TestVC7(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def getExpectedEnv(self, installdir, LIB=None, p=None, i=None): include = [ installdir + r'\VC7\INCLUDE;', @@ -585,13 +573,9 @@ def getExpectedEnv(self, installdir, x64=False, LIB=None, i=None, p=None): class TestVC8(VC8ExpectedEnvMixin, TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_args(self): self.setup_step(vstudio.VC8(projectfile='pf', config='cfg', project='pj', arch='arch')) self.expect_commands( @@ -647,13 +631,9 @@ def test_rendering(self): class TestVCExpress9(VC8ExpectedEnvMixin, TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_args(self): self.setup_step(vstudio.VCExpress9(projectfile='pf', config='cfg', project='pj')) self.expect_commands( @@ -705,13 +685,9 @@ def test_mode_build_env(self): class TestVC9(VC8ExpectedEnvMixin, TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_installdir(self): self.setup_step(vstudio.VC9(projectfile='pf', config='cfg', project='pj')) self.expect_commands( @@ -727,13 +703,9 @@ def test_installdir(self): class TestVC10(VC8ExpectedEnvMixin, TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_installdir(self): self.setup_step(vstudio.VC10(projectfile='pf', config='cfg', project='pj')) self.expect_commands( @@ -749,13 +721,9 @@ def test_installdir(self): class TestVC11(VC8ExpectedEnvMixin, TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_installdir(self): self.setup_step(vstudio.VC11(projectfile='pf', config='cfg', project='pj')) self.expect_commands( @@ -771,13 +739,9 @@ def test_installdir(self): class TestMsBuild(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_no_platform(self): self.setup_step( @@ -874,13 +838,9 @@ def test_rebuild_solution(self): class TestMsBuild141(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_no_platform(self): self.setup_step( @@ -995,13 +955,9 @@ def test_aliases_MsBuild15(self): class TestMsBuild16(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_version_range_is_correct(self): self.setup_step( vstudio.MsBuild16(projectfile='pf', config='cfg', platform='Win32', project='pj') @@ -1023,13 +979,9 @@ def test_version_range_is_correct(self): class TestMsBuild17(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_version_range_is_correct(self): self.setup_step( vstudio.MsBuild17(projectfile='pf', config='cfg', platform='Win32', project='pj') diff --git a/master/buildbot/test/unit/steps/test_worker.py b/master/buildbot/test/unit/steps/test_worker.py index a73c4ba6246e..c27ac0a5ab0c 100644 --- a/master/buildbot/test/unit/steps/test_worker.py +++ b/master/buildbot/test/unit/steps/test_worker.py @@ -42,13 +42,9 @@ class TestSetPropertiesFromEnv(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_simple(self): self.setup_step( worker.SetPropertiesFromEnv( @@ -82,13 +78,9 @@ def test_case_folding(self): class TestFileExists(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_found(self): self.setup_step(worker.FileExists(file="x")) self.expect_commands(ExpectStat(file='x').stat_file().exit(0)) @@ -125,13 +117,9 @@ def test_old_version(self): class TestCopyDirectory(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_success(self): self.setup_step(worker.CopyDirectory(src="s", dest="d")) self.expect_commands(ExpectCpdir(fromdir='s', todir='d', timeout=120).exit(0)) @@ -169,13 +157,9 @@ def test_render(self): class TestRemoveDirectory(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_success(self): self.setup_step(worker.RemoveDirectory(dir="d")) self.expect_commands(ExpectRmdir(dir='d').exit(0)) @@ -198,13 +182,9 @@ def test_render(self): class TestMakeDirectory(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_success(self): self.setup_step(worker.MakeDirectory(dir="d")) self.expect_commands(ExpectMkdir(dir='d').exit(0)) @@ -240,13 +220,9 @@ def run(self): class TestCompositeStepMixin(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_runRemoteCommand(self): cmd_args = ('foo', {'bar': False}) diff --git a/master/buildbot/test/unit/test_download_secret_to_worker.py b/master/buildbot/test/unit/test_download_secret_to_worker.py index 7cc8e13e17c3..cabf22e3973a 100644 --- a/master/buildbot/test/unit/test_download_secret_to_worker.py +++ b/master/buildbot/test/unit/test_download_secret_to_worker.py @@ -17,7 +17,6 @@ import os import stat -from twisted.internet import defer from twisted.python.filepath import FilePath from twisted.trial import unittest @@ -38,16 +37,12 @@ class TestDownloadFileSecretToWorkerCommand( TestBuildStepMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() tempdir = FilePath(self.mktemp()) tempdir.createDirectory() self.temp_path = tempdir.path return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def testBasic(self): self.setup_step( DownloadSecretsToWorker([ @@ -81,16 +76,12 @@ def testBasic(self): class TestRemoveWorkerFileSecretCommand30(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() tempdir = FilePath(self.mktemp()) tempdir.createDirectory() self.temp_path = tempdir.path return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def testBasic(self): self.setup_build(worker_version={'*': '3.0'}) self.setup_step( @@ -122,16 +113,12 @@ class TestRemoveFileSecretToWorkerCommand( TestBuildStepMixin, configmixin.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() tempdir = FilePath(self.mktemp()) tempdir.createDirectory() self.temp_path = tempdir.path return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def testBasic(self): self.setup_step( RemoveWorkerFileSecret([ diff --git a/master/buildbot/test/unit/test_fake_httpclientservice.py b/master/buildbot/test/unit/test_fake_httpclientservice.py index cd3dec8dc5fe..19586fa89945 100644 --- a/master/buildbot/test/unit/test_fake_httpclientservice.py +++ b/master/buildbot/test/unit/test_fake_httpclientservice.py @@ -43,7 +43,7 @@ def doGetRoot(self): class Test(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - yield self.setup_test_reactor(auto_tear_down=False) + yield self.setup_test_reactor() baseurl = 'http://127.0.0.1:8080' master = yield fakemaster.make_master(self) @@ -54,10 +54,6 @@ def setUp(self): yield self.tested.setServiceParent(master) yield master.startService() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_root(self): self._http.expect("get", "/", content_json={'foo': 'bar'}) diff --git a/master/buildbot/test/unit/test_fake_secrets_manager.py b/master/buildbot/test/unit/test_fake_secrets_manager.py index 1f28dc0af8ef..2bd985746157 100644 --- a/master/buildbot/test/unit/test_fake_secrets_manager.py +++ b/master/buildbot/test/unit/test_fake_secrets_manager.py @@ -11,16 +11,12 @@ class TestSecretsManager(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.master.config.secretsProviders = [ FakeSecretStorage(secretdict={"foo": "bar", "other": "value"}) ] - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def testGetManagerService(self): secret_service_manager = SecretManager() diff --git a/master/buildbot/test/unit/test_interpolate_secrets.py b/master/buildbot/test/unit/test_interpolate_secrets.py index d545973eccb8..da3c59f3ba1c 100644 --- a/master/buildbot/test/unit/test_interpolate_secrets.py +++ b/master/buildbot/test/unit/test_interpolate_secrets.py @@ -19,7 +19,7 @@ def __init__(self, master): class TestInterpolateSecrets(TestReactorMixin, unittest.TestCase, ConfigErrorsMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) fakeStorageService = FakeSecretStorage() fakeStorageService.reconfigService(secretdict={"foo": "bar", "other": "value"}) @@ -28,10 +28,6 @@ def setUp(self): yield self.secretsrv.setServiceParent(self.master) self.build = FakeBuildWithMaster(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_secret(self): command = Interpolate("echo %(secret:foo)s") @@ -48,14 +44,10 @@ def test_secret_not_found(self): class TestInterpolateSecretsNoService(TestReactorMixin, unittest.TestCase, ConfigErrorsMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.build = FakeBuildWithMaster(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_secret(self): command = Interpolate("echo %(secret:fuo)s") @@ -66,7 +58,7 @@ def test_secret(self): class TestInterpolateSecretsHiddenSecrets(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) fakeStorageService = FakeSecretStorage() password = "bar" @@ -78,10 +70,6 @@ def setUp(self): yield self.secretsrv.setServiceParent(self.master) self.build = FakeBuildWithMaster(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_secret(self): command = Interpolate("echo %(secret:foo)s") diff --git a/master/buildbot/test/unit/test_janitor_configurator.py b/master/buildbot/test/unit/test_janitor_configurator.py index a23d322dc971..fd060c638d6d 100644 --- a/master/buildbot/test/unit/test_janitor_configurator.py +++ b/master/buildbot/test/unit/test_janitor_configurator.py @@ -68,14 +68,10 @@ class LogChunksJanitorTests( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setup_test_build_step() self.patch(janitor, "now", lambda: datetime.datetime(year=2017, month=1, day=1)) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_basic(self): self.setup_step(LogChunksJanitor(logHorizon=timedelta(weeks=1))) diff --git a/master/buildbot/test/unit/test_machine_generic.py b/master/buildbot/test/unit/test_machine_generic.py index 7ac46d457d39..3e2ea403822b 100644 --- a/master/buildbot/test/unit/test_machine_generic.py +++ b/master/buildbot/test/unit/test_machine_generic.py @@ -55,13 +55,9 @@ class TestActions( MasterRunProcessMixin, config.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_local_wake_action(self): self.expect_commands( @@ -263,16 +259,12 @@ def test_remote_ssh_suspend_action_no_keys(self, write_local_file_mock, temp_dir class TestHttpAction(config.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.http = yield fakehttpclientservice.HTTPClientService.getService( self.master, self, "http://localhost/request" ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_http_wrong_method(self): manager = FakeManager(self.master) diff --git a/master/buildbot/test/unit/test_master.py b/master/buildbot/test/unit/test_master.py index f2c2ff23a7ea..cf41066616b0 100644 --- a/master/buildbot/test/unit/test_master.py +++ b/master/buildbot/test/unit/test_master.py @@ -79,7 +79,7 @@ def test_configfile_default(self): class StartupAndReconfig(dirs.DirsMixin, logging.LoggingMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpLogging() self.basedir = os.path.abspath('basedir') yield self.setUpDirs(self.basedir) @@ -115,10 +115,6 @@ def cleanup(): self.data = self.master.data = fakedata.FakeDataConnector(self.master, self) yield self.data.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # tests @defer.inlineCallbacks def test_startup_bad_config(self): diff --git a/master/buildbot/test/unit/test_mq.py b/master/buildbot/test/unit/test_mq.py index 34190bf10c57..19ff407ada9d 100644 --- a/master/buildbot/test/unit/test_mq.py +++ b/master/buildbot/test/unit/test_mq.py @@ -133,24 +133,16 @@ def test_waitUntilEvent_check_false(self): class TestFakeMQ(TestReactorMixin, unittest.TestCase, Tests): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True) self.mq = self.master.mq self.mq.verifyMessages = False - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestSimpleMQ(TestReactorMixin, unittest.TestCase, RealTests): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.mq = simple.SimpleMQ() yield self.mq.setServiceParent(self.master) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() diff --git a/master/buildbot/test/unit/test_mq_connector.py b/master/buildbot/test/unit/test_mq_connector.py index 69351e5bbcd3..dd14d3135c17 100644 --- a/master/buildbot/test/unit/test_mq_connector.py +++ b/master/buildbot/test/unit/test_mq_connector.py @@ -42,16 +42,12 @@ def startConsuming(self, callback, filter, persistent_name=None): class MQConnector(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.mqconfig = self.master.config.mq = {} self.conn = connector.MQConnector() yield self.conn.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def patchFakeMQ(self, name='fake'): self.patch( connector.MQConnector, diff --git a/master/buildbot/test/unit/test_mq_simple.py b/master/buildbot/test/unit/test_mq_simple.py index b54db1ab328a..e63fd7228442 100644 --- a/master/buildbot/test/unit/test_mq_simple.py +++ b/master/buildbot/test/unit/test_mq_simple.py @@ -26,7 +26,7 @@ class SimpleMQ(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.mq = simple.SimpleMQ() self.mq.setServiceParent(self.master) @@ -39,10 +39,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_forward_data(self): callback = mock.Mock() diff --git a/master/buildbot/test/unit/test_mq_wamp.py b/master/buildbot/test/unit/test_mq_wamp.py index 1ae041d1707a..b2608382851d 100644 --- a/master/buildbot/test/unit/test_mq_wamp.py +++ b/master/buildbot/test/unit/test_mq_wamp.py @@ -126,7 +126,7 @@ class WampMQ(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.master.wamp = FakeWampConnector() self.mq = wamp.WampMQ() @@ -140,10 +140,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_startConsuming_basic(self): self.master.wamp.subscribe = mock.Mock() @@ -254,7 +250,7 @@ class WampMQReal(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() if "WAMP_ROUTER_URL" not in os.environ: raise unittest.SkipTest(self.HOW_TO_RUN) self.master = yield fakemaster.make_master(self) @@ -270,10 +266,6 @@ def setUp(self): config.mq['router_url'] = os.environ["WAMP_ROUTER_URL"] yield self.connector.reconfigServiceWithBuildbotConfig(config) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_forward_data(self): d = defer.Deferred() diff --git a/master/buildbot/test/unit/test_secret_in_passwordstore.py b/master/buildbot/test/unit/test_secret_in_passwordstore.py index fc17f7ade0d2..288aa9c74a2a 100644 --- a/master/buildbot/test/unit/test_secret_in_passwordstore.py +++ b/master/buildbot/test/unit/test_secret_in_passwordstore.py @@ -33,7 +33,7 @@ class TestSecretInPass( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() self.master = yield fakemaster.make_master(self) with mock.patch.object(Path, "is_file", return_value=True): @@ -43,10 +43,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.srvpass.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def create_temp_dir(self, dirname): tempdir = FilePath(self.mktemp()) tempdir.createDirectory() diff --git a/master/buildbot/test/unit/test_secret_rendered_service.py b/master/buildbot/test/unit/test_secret_rendered_service.py index c14d175efa23..22af3a975b7c 100644 --- a/master/buildbot/test/unit/test_secret_rendered_service.py +++ b/master/buildbot/test/unit/test_secret_rendered_service.py @@ -25,7 +25,7 @@ def returnRenderedSecrets(self, secretKey): class TestRenderSecrets(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) fakeStorageService = FakeSecretStorage(secretdict={"foo": "bar", "other": "value"}) self.secretsrv = SecretManager() @@ -36,10 +36,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_secret_rendered(self): yield self.srvtest.configureService() diff --git a/master/buildbot/test/unit/test_stats_service.py b/master/buildbot/test/unit/test_stats_service.py index d694f3c65473..649e467c63a4 100644 --- a/master/buildbot/test/unit/test_stats_service.py +++ b/master/buildbot/test/unit/test_stats_service.py @@ -45,7 +45,7 @@ class TestStatsServicesBase(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True, wantDb=True) yield self.master.db.insert_test_data( @@ -65,10 +65,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestStatsServicesConfiguration(TestStatsServicesBase): @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/test_steps_git_diffinfo.py b/master/buildbot/test/unit/test_steps_git_diffinfo.py index bd7082146197..4aa30bc799c2 100644 --- a/master/buildbot/test/unit/test_steps_git_diffinfo.py +++ b/master/buildbot/test/unit/test_steps_git_diffinfo.py @@ -13,7 +13,6 @@ # # Copyright Buildbot Team Members -from twisted.internet import defer from twisted.trial import unittest from buildbot.process import results @@ -33,13 +32,9 @@ class TestDiffInfo(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): skip = 'unidiff is required for GitDiffInfo tests' def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_merge_base_failure(self): self.setup_step(gitdiffinfo.GitDiffInfo()) self.expect_commands( diff --git a/master/buildbot/test/unit/test_steps_mixin.py b/master/buildbot/test/unit/test_steps_mixin.py index 6d48ab9997ca..3bb27fc25a13 100644 --- a/master/buildbot/test/unit/test_steps_mixin.py +++ b/master/buildbot/test/unit/test_steps_mixin.py @@ -48,13 +48,9 @@ def run(self): class TestTestBuildStepMixin(TestBuildStepMixin, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() return self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_setup_build(self): self.setup_build( diff --git a/master/buildbot/test/unit/test_wamp_connector.py b/master/buildbot/test/unit/test_wamp_connector.py index 9e6505e5401a..cd0b44660dc3 100644 --- a/master/buildbot/test/unit/test_wamp_connector.py +++ b/master/buildbot/test/unit/test_wamp_connector.py @@ -59,7 +59,7 @@ class TestedWampConnector(connector.WampConnector): class WampConnector(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() master = yield fakemaster.make_master(self) self.connector = TestedWampConnector() @@ -69,10 +69,6 @@ def setUp(self): yield master.startService() yield self.connector.reconfigServiceWithBuildbotConfig(config) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_reconfig_same_config(self): config = FakeConfig({'type': 'wamp', 'router_url': "wss://foo", 'realm': "bb"}) diff --git a/master/buildbot/test/unit/util/test_backoff.py b/master/buildbot/test/unit/util/test_backoff.py index c7ea157512af..6ed49e29b22f 100644 --- a/master/buildbot/test/unit/util/test_backoff.py +++ b/master/buildbot/test/unit/util/test_backoff.py @@ -28,11 +28,7 @@ class TestException(Exception): class ExponentialBackoffEngineAsyncTests(unittest.TestCase, TestReactorMixin): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() def test_construct_asserts(self): with self.assertRaises(ValueError): diff --git a/master/buildbot/test/unit/util/test_codebase.py b/master/buildbot/test/unit/util/test_codebase.py index c9482fa727ef..2597f56e1666 100644 --- a/master/buildbot/test/unit/util/test_codebase.py +++ b/master/buildbot/test/unit/util/test_codebase.py @@ -42,15 +42,11 @@ class TestAbsoluteSourceStampsMixin( @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True, wantData=True) self.db = self.master.db self.object = FakeObject(self.master, self.codebases) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def mkch(self, **kwargs): ch = self.makeFakeChange(**kwargs) diff --git a/master/buildbot/test/unit/util/test_deferwaiter.py b/master/buildbot/test/unit/util/test_deferwaiter.py index f4fc399aa6df..199df122b6d7 100644 --- a/master/buildbot/test/unit/util/test_deferwaiter.py +++ b/master/buildbot/test/unit/util/test_deferwaiter.py @@ -76,11 +76,7 @@ def test_passes_result(self): class RepeatedActionHandlerTests(unittest.TestCase, TestReactorMixin): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_does_not_add_action_on_start(self): @@ -432,11 +428,7 @@ def action(): class NonRepeatedActionHandlerTests(unittest.TestCase, TestReactorMixin): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_does_not_add_action_on_start(self): diff --git a/master/buildbot/test/unit/util/test_kubeclientservice.py b/master/buildbot/test/unit/util/test_kubeclientservice.py index 71253bb31c35..e4b4682d3ff9 100644 --- a/master/buildbot/test/unit/util/test_kubeclientservice.py +++ b/master/buildbot/test/unit/util/test_kubeclientservice.py @@ -106,7 +106,7 @@ class KubeClientServiceTestKubeHardcodedConfig( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self._http = yield fakehttpclientservice.HTTPClientService.getService( self.master, self, "http://localhost:8001" @@ -114,10 +114,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_basic(self): self.config = kubeclientservice.KubeHardcodedConfig( master_url="http://localhost:8001", namespace="default" diff --git a/master/buildbot/test/unit/util/test_misc.py b/master/buildbot/test/unit/util/test_misc.py index f948e18fd976..b9fcdc729f2d 100644 --- a/master/buildbot/test/unit/util/test_misc.py +++ b/master/buildbot/test/unit/util/test_misc.py @@ -86,13 +86,9 @@ def check_locked(self, arg1, arg2): class TestCancelAfter(TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.d = defer.Deferred() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_succeeds(self): d = misc.cancelAfter(10, self.d, self.reactor) self.assertIdentical(d, self.d) diff --git a/master/buildbot/test/unit/util/test_poll.py b/master/buildbot/test/unit/util/test_poll.py index a473ea5ed387..28b6b10f69c7 100644 --- a/master/buildbot/test/unit/util/test_poll.py +++ b/master/buildbot/test/unit/util/test_poll.py @@ -31,7 +31,7 @@ def poll(self): raise RuntimeError('oh noes') def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = mock.Mock() self.master.reactor = self.reactor @@ -45,10 +45,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_call_not_started_does_nothing(self): self.reactor.advance(100) self.assertEqual(self.calls, 0) @@ -196,7 +192,7 @@ def poll(self): raise RuntimeError('oh noes') def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = mock.Mock() self.master.reactor = self.reactor @@ -208,10 +204,6 @@ def setUp(self): self.addCleanup(poll.reset_poll_methods) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_call_when_started_forces_run(self): self.poll.start(interval=10, now=True) diff --git a/master/buildbot/test/unit/util/test_runprocess.py b/master/buildbot/test/unit/util/test_runprocess.py index c5821373af2f..1854c84ab97b 100644 --- a/master/buildbot/test/unit/util/test_runprocess.py +++ b/master/buildbot/test/unit/util/test_runprocess.py @@ -37,15 +37,11 @@ class TestRunProcess(TestReactorMixin, LoggingMixin, unittest.TestCase): FAKE_PID = 1234 def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpLogging() self.process = None self.reactor.spawnProcess = self.fake_spawn_process - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def fake_spawn_process(self, pp, command, args, env, workdir, usePTY=False): self.assertIsNone(self.process) self.pp = pp diff --git a/master/buildbot/test/unit/util/test_service.py b/master/buildbot/test/unit/util/test_service.py index e3cc95102e92..0f81ea119b9d 100644 --- a/master/buildbot/test/unit/util/test_service.py +++ b/master/buildbot/test/unit/util/test_service.py @@ -103,14 +103,10 @@ class DummyService(service.ClusteredBuildbotService): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True, wantData=True) self.svc = self.makeService() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeService(self, attach_to_master=True, name=SVC_NAME, serviceid=SVC_ID): svc = self.DummyService(name=name) diff --git a/master/buildbot/test/unit/util/test_state.py b/master/buildbot/test/unit/util/test_state.py index 7e520ac9faf4..7f75e7443c9d 100644 --- a/master/buildbot/test/unit/util/test_state.py +++ b/master/buildbot/test/unit/util/test_state.py @@ -34,14 +34,10 @@ class TestStateMixin(TestReactorMixin, StateTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True) self.object = FakeObject(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_getState(self): yield self.set_fake_state(self.object, 'fav_color', ['red', 'purple']) diff --git a/master/buildbot/test/unit/util/test_test_result_submitter.py b/master/buildbot/test/unit/util/test_test_result_submitter.py index 74bd9ebf79d7..06679ce04e16 100644 --- a/master/buildbot/test/unit/util/test_test_result_submitter.py +++ b/master/buildbot/test/unit/util/test_test_result_submitter.py @@ -25,7 +25,7 @@ class TestTestResultSubmitter(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantData=True, wantDb=True) yield self.master.startService() self.addCleanup(self.master.stopService) @@ -42,10 +42,6 @@ def setUp(self): fakedb.Step(id=131, number=132, name='step132', buildid=30), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_complete_empty(self): sub = TestResultSubmitter() diff --git a/master/buildbot/test/unit/util/test_watchdog.py b/master/buildbot/test/unit/util/test_watchdog.py index d2eaea5b0b67..fa6cd31ae5fe 100644 --- a/master/buildbot/test/unit/util/test_watchdog.py +++ b/master/buildbot/test/unit/util/test_watchdog.py @@ -15,7 +15,6 @@ from unittest import mock -from twisted.internet import defer from twisted.trial import unittest from buildbot.test.reactor import TestReactorMixin @@ -24,11 +23,7 @@ class TestWatchdog(TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() def test_not_started_no_calls(self): m = mock.Mock() diff --git a/master/buildbot/test/unit/worker/test_base.py b/master/buildbot/test/unit/worker/test_base.py index eacb3902b41a..695b489fb240 100644 --- a/master/buildbot/test/unit/worker/test_base.py +++ b/master/buildbot/test/unit/worker/test_base.py @@ -115,13 +115,9 @@ def canStartBuild(self): class RealWorkerItfc(TestReactorMixin, unittest.TestCase, WorkerInterfaceTests): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.wrk = ConcreteWorker('wrk', 'pa') - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def callAttached(self): self.master = yield fakemaster.make_master(self, wantData=True) @@ -137,14 +133,10 @@ def callAttached(self): class FakeWorkerItfc(TestReactorMixin, unittest.TestCase, WorkerInterfaceTests): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.wrk = worker.FakeWorker(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def callAttached(self): self.conn = fakeprotocol.FakeConnection(self.wrk) return self.wrk.attached(self.conn) @@ -153,7 +145,7 @@ def callAttached(self): class TestAbstractWorker(logging.LoggingMixin, TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setUpLogging() self.master = yield fakemaster.make_master(self, wantDb=True, wantData=True) self.botmaster = self.master.botmaster @@ -161,10 +153,6 @@ def setUp(self): self.workers = self.master.workers = bworkermanager.FakeWorkerManager() yield self.workers.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def createWorker(self, name='bot', password='pass', attached=False, configured=True, **kwargs): worker = ConcreteWorker(name, password, **kwargs) @@ -929,17 +917,13 @@ def test_worker_quarantine_stop_timer(self): class TestAbstractLatentWorker(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True, wantData=True) self.botmaster = self.master.botmaster yield self.master.workers.disownServiceParent() self.workers = self.master.workers = bworkermanager.FakeWorkerManager() yield self.workers.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def do_test_reconfigService(self, old, new, existingRegistration=True): old.parent = self.master diff --git a/master/buildbot/test/unit/worker/test_docker.py b/master/buildbot/test/unit/worker/test_docker.py index 6a64748e02e3..1c1cfb41ac0e 100644 --- a/master/buildbot/test/unit/worker/test_docker.py +++ b/master/buildbot/test/unit/worker/test_docker.py @@ -47,7 +47,7 @@ def _create_client(self, *args, **kwargs): return self._client def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.patch(dockerworker, 'docker', docker) @@ -61,10 +61,6 @@ def setUp(self): docker.Client.containerCreated = False docker.Client.start_exception = None - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_constructor_noimage_nodockerfile(self): with self.assertRaises(config.ConfigErrors): diff --git a/master/buildbot/test/unit/worker/test_kubernetes.py b/master/buildbot/test/unit/worker/test_kubernetes.py index d2687ac4866d..8dbf5f40902c 100644 --- a/master/buildbot/test/unit/worker/test_kubernetes.py +++ b/master/buildbot/test/unit/worker/test_kubernetes.py @@ -63,7 +63,7 @@ class TestKubernetesWorker(TestReactorMixin, unittest.TestCase): worker = None def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() @defer.inlineCallbacks def setupWorker(self, *args, config=None, **kwargs): @@ -86,10 +86,6 @@ def setupWorker(self, *args, config=None, **kwargs): self.addCleanup(self.master.stopService) return worker - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def get_expected_metadata(self): return {"name": "buildbot-worker-87de7e"} diff --git a/master/buildbot/test/unit/worker/test_libvirt.py b/master/buildbot/test/unit/worker/test_libvirt.py index e9bc24a44575..1c3ed07a7d1a 100644 --- a/master/buildbot/test/unit/worker/test_libvirt.py +++ b/master/buildbot/test/unit/worker/test_libvirt.py @@ -67,16 +67,12 @@ class TestException(Exception): class TestLibVirtWorker(TestReactorMixin, MasterRunProcessMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setup_master_run_process() self.connections = {} self.patch(libvirtworker, "libvirt", libvirtfake) self.threadpool = TestServerThreadPool(self) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def libvirt_open(self, uri): if uri not in self.connections: raise RuntimeError('Could not find test connection') diff --git a/master/buildbot/test/unit/worker/test_local.py b/master/buildbot/test/unit/worker/test_local.py index fb128729d04c..4aa20222464f 100644 --- a/master/buildbot/test/unit/worker/test_local.py +++ b/master/buildbot/test/unit/worker/test_local.py @@ -32,15 +32,11 @@ class TestLocalWorker(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantDb=True, wantData=True) self.botmaster = self.master.botmaster self.workers = self.master.workers - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def createWorker(self, name='bot', attached=False, configured=True, **kwargs): worker = local.LocalWorker(name, **kwargs) if configured: diff --git a/master/buildbot/test/unit/worker/test_manager.py b/master/buildbot/test/unit/worker/test_manager.py index 60312b12ae9e..3ea15d2e6c59 100644 --- a/master/buildbot/test/unit/worker/test_manager.py +++ b/master/buildbot/test/unit/worker/test_manager.py @@ -47,7 +47,7 @@ class FakeWorker2(FakeWorker): class TestWorkerManager(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self, wantMq=True, wantData=True) self.master.mq = self.master.mq self.workers = workermanager.WorkerManager(self.master) @@ -62,10 +62,6 @@ def setUp(self): self.workers.startService() self.addCleanup(self.workers.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_reconfigServiceWorkers_add_remove(self): worker = FakeWorker('worker1') diff --git a/master/buildbot/test/unit/worker/test_marathon.py b/master/buildbot/test/unit/worker/test_marathon.py index 3f200c706361..89dcfaee1dfd 100644 --- a/master/buildbot/test/unit/worker/test_marathon.py +++ b/master/buildbot/test/unit/worker/test_marathon.py @@ -29,7 +29,7 @@ class TestMarathonLatentWorker(unittest.TestCase, TestReactorMixin): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.build = Properties(image="busybox:latest", builder="docker_worker") self.worker = None self.master = None @@ -44,10 +44,8 @@ class FakeResult: self.addCleanup(cleanup) - @defer.inlineCallbacks def tearDown(self): self.flushLoggedErrors(LatentWorkerSubstantiatiationCancelled) - yield self.tear_down_test_reactor() def test_constructor_normal(self): worker = MarathonLatentWorker('bot', 'tcp://marathon.local', 'foo', 'bar', 'debian:wheezy') diff --git a/master/buildbot/test/unit/worker/test_openstack.py b/master/buildbot/test/unit/worker/test_openstack.py index f4738397aa91..f9a552079271 100644 --- a/master/buildbot/test/unit/worker/test_openstack.py +++ b/master/buildbot/test/unit/worker/test_openstack.py @@ -43,7 +43,7 @@ class TestOpenStackWorker(TestReactorMixin, unittest.TestCase): bs_image_args = {"flavor": 1, "image": '28a65eb4-f354-4420-97dc-253b826547f7', **os_auth} def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.patch(openstack, "client", novaclient) self.patch(openstack, "loading", novaclient) self.patch(openstack, "session", novaclient) @@ -55,10 +55,6 @@ def setUp(self): ) self.masterhash = hashlib.sha1(b'fake:/master').hexdigest()[:6] - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setupWorker(self, *args, **kwargs): worker = openstack.OpenStackLatentWorker(*args, **kwargs) diff --git a/master/buildbot/test/unit/worker/test_protocols_base.py b/master/buildbot/test/unit/worker/test_protocols_base.py index 1563cac5fa52..d0b1abe4fb23 100644 --- a/master/buildbot/test/unit/worker/test_protocols_base.py +++ b/master/buildbot/test/unit/worker/test_protocols_base.py @@ -15,7 +15,6 @@ from unittest import mock -from twisted.internet import defer from twisted.trial import unittest from buildbot.test.fake import fakeprotocol @@ -26,25 +25,17 @@ class TestFakeConnection(protocols.ConnectionInterfaceTest, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.worker = mock.Mock() self.conn = fakeprotocol.FakeConnection(self.worker) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestConnection(protocols.ConnectionInterfaceTest, TestReactorMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.worker = mock.Mock() self.conn = base.Connection(self.worker.workername) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_notify(self): cb = mock.Mock() diff --git a/master/buildbot/test/unit/worker/test_protocols_msgpack.py b/master/buildbot/test/unit/worker/test_protocols_msgpack.py index f7ffe0d91749..a35cc7d10b33 100644 --- a/master/buildbot/test/unit/worker/test_protocols_msgpack.py +++ b/master/buildbot/test/unit/worker/test_protocols_msgpack.py @@ -32,13 +32,9 @@ class TestListener(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_constructor(self): listener = msgpack.Listener(self.master) self.assertEqual(listener.master, self.master) @@ -88,29 +84,21 @@ class TestConnectionApi( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.conn = msgpack.Connection(self.master, mock.Mock(), mock.Mock()) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestConnection(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.protocol = mock.Mock() self.worker = mock.Mock() self.worker.workername = 'test_worker' self.conn = msgpack.Connection(self.master, self.worker, self.protocol) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_constructor(self): self.assertEqual(self.conn.protocol, self.protocol) self.assertEqual(self.conn.master, self.master) diff --git a/master/buildbot/test/unit/worker/test_protocols_pb.py b/master/buildbot/test/unit/worker/test_protocols_pb.py index 1dca42960cdc..64179fc06491 100644 --- a/master/buildbot/test/unit/worker/test_protocols_pb.py +++ b/master/buildbot/test/unit/worker/test_protocols_pb.py @@ -30,13 +30,9 @@ class TestListener(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeListener(self): listener = pb.Listener(self.master) return listener @@ -89,27 +85,19 @@ class TestConnectionApi( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.conn = pb.Connection(self.master, mock.Mock(), mock.Mock()) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - class TestConnection(TestReactorMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakemaster.make_master(self) self.mind = mock.Mock() self.worker = mock.Mock() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_constructor(self): conn = pb.Connection(self.master, self.worker, self.mind) diff --git a/master/buildbot/test/unit/worker/test_upcloud.py b/master/buildbot/test/unit/worker/test_upcloud.py index 678a140d8a25..012d49baf536 100644 --- a/master/buildbot/test/unit/worker/test_upcloud.py +++ b/master/buildbot/test/unit/worker/test_upcloud.py @@ -82,11 +82,7 @@ class TestUpcloudWorker(TestReactorMixin, unittest.TestCase): master = None def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def setupWorker(self, *args, **kwargs): diff --git a/master/buildbot/test/unit/www/test_auth.py b/master/buildbot/test/unit/www/test_auth.py index 9cd2ebf49360..e99ad71fa69d 100644 --- a/master/buildbot/test/unit/www/test_auth.py +++ b/master/buildbot/test/unit/www/test_auth.py @@ -42,14 +42,10 @@ def setUpAuthResource(self): class AuthRootResource(TestReactorMixin, www.WwwTestMixin, AuthResourceMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpAuthResource() self.rsrc = auth.AuthRootResource(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_getChild_login(self): glr = mock.Mock(name='glr') self.master.www.auth.getLoginResource = glr @@ -66,16 +62,12 @@ def test_getChild_logout(self): class AuthBase(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.auth = auth.AuthBase() self.master = yield self.make_master(url='h:/a/b/') self.auth.master = self.master self.req = self.make_request(b'/') - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_maybeAutoLogin(self): self.assertEqual((yield self.auth.maybeAutoLogin(self.req)), None) @@ -111,15 +103,11 @@ def test_exists(self): class RemoteUserAuth(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.auth = auth.RemoteUserAuth(header=b'HDR') yield self.make_master() self.request = self.make_request(b'/') - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_maybeAutoLogin(self): self.request.input_headers[b'HDR'] = b'rachel@foo.com' @@ -155,15 +143,11 @@ def test_get_login_resource_does_not_throw(self): class AuthRealm(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.auth = auth.RemoteUserAuth(header=b'HDR') self.auth = auth.NoAuth() yield self.make_master() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_requestAvatar(self): realm = auth.AuthRealm(self.master, self.auth) itfc, rsrc, _ = realm.requestAvatar("me", None, IResource) @@ -173,7 +157,7 @@ def test_requestAvatar(self): class TwistedICredAuthBase(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() # twisted.web makes it difficult to simulate the authentication process, so # this only tests the mechanics of the getLoginResource method. @@ -208,11 +192,7 @@ def check_credentials(self, us, ps): return us == 'fellow' and ps == 'correct' def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_callable(self): @@ -228,13 +208,9 @@ def test_callable(self): class LoginResource(TestReactorMixin, www.WwwTestMixin, AuthResourceMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpAuthResource() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_render(self): self.rsrc = auth.LoginResource(self.master) @@ -251,14 +227,10 @@ class PreAuthenticatedLoginResource( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpAuthResource() self.rsrc = auth.PreAuthenticatedLoginResource(self.master, 'him') - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_render(self): self.auth.maybeAutoLogin = mock.Mock() @@ -280,14 +252,10 @@ def updateUserInfo(request): class LogoutResource(TestReactorMixin, www.WwwTestMixin, AuthResourceMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() yield self.setUpAuthResource() self.rsrc = auth.LogoutResource(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_render(self): self.master.session.expire = mock.Mock() diff --git a/master/buildbot/test/unit/www/test_authz.py b/master/buildbot/test/unit/www/test_authz.py index 481829bfad45..46687583f248 100644 --- a/master/buildbot/test/unit/www/test_authz.py +++ b/master/buildbot/test/unit/www/test_authz.py @@ -36,7 +36,7 @@ class Authz(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() authzcfg = authz.Authz( # simple matcher with '*' glob character stringsMatcher=authz.fnmatchStrMatcher, @@ -107,10 +107,6 @@ def setUp(self): ), ]) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def setAllowRules(self, allow_rules): # we should add links to authz and master instances in each new rule for r in allow_rules: diff --git a/master/buildbot/test/unit/www/test_avatar.py b/master/buildbot/test/unit/www/test_avatar.py index e147f5902119..9822e274280a 100644 --- a/master/buildbot/test/unit/www/test_avatar.py +++ b/master/buildbot/test/unit/www/test_avatar.py @@ -32,11 +32,7 @@ def getUserAvatar(self, email, username, size, defaultAvatarUrl): class AvatarResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_default(self): @@ -526,7 +522,7 @@ def getUserAvatar(self, email, username, size, defaultAvatarUrl): class GitHubAvatar(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() master = yield self.make_master( url='http://a/b/', @@ -552,10 +548,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_username(self): username_search_endpoint = '/users/defunkt' @@ -726,7 +718,7 @@ def test_email_error(self): class GitHubAvatarBasicAuth(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() avatar_method = avatar.AvatarGitHub(client_id="oauth_id", client_secret="oauth_secret") master = yield self.make_master( @@ -752,10 +744,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_incomplete_credentials(self): with self.assertRaises(config.ConfigErrors): avatar.AvatarGitHub(client_id="oauth_id") diff --git a/master/buildbot/test/unit/www/test_config.py b/master/buildbot/test/unit/www/test_config.py index a1acc763b463..68d89baaa1de 100644 --- a/master/buildbot/test/unit/www/test_config.py +++ b/master/buildbot/test/unit/www/test_config.py @@ -51,11 +51,7 @@ def test_serialize_www_frontend_theme_to_css(self): class TestConfigResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_render(self): @@ -88,11 +84,7 @@ def test_render(self): class IndexResourceTest(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() def get_react_base_path(self): path = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) diff --git a/master/buildbot/test/unit/www/test_endpointmatchers.py b/master/buildbot/test/unit/www/test_endpointmatchers.py index b162ffac3896..beb5f5e661bb 100644 --- a/master/buildbot/test/unit/www/test_endpointmatchers.py +++ b/master/buildbot/test/unit/www/test_endpointmatchers.py @@ -27,17 +27,13 @@ class EndpointBase(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield self.make_master(url='h:/a/b/') self.db = self.master.db self.matcher = self.makeMatcher() self.matcher.setAuthz(self.master.authz) yield self.insertData() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeMatcher(self): raise NotImplementedError() diff --git a/master/buildbot/test/unit/www/test_graphql.py b/master/buildbot/test/unit/www/test_graphql.py index ed433cc869a3..891ee17926cc 100644 --- a/master/buildbot/test/unit/www/test_graphql.py +++ b/master/buildbot/test/unit/www/test_graphql.py @@ -225,15 +225,11 @@ class DisabledV3RootResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCa @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield self.make_master(url="http://server/path/") self.rsrc = graphql.V3RootResource(self.master) self.rsrc.reconfigResource(self.master.config) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_basic_disabled(self): yield self.render_resource(self.rsrc, b"/") diff --git a/master/buildbot/test/unit/www/test_hooks_base.py b/master/buildbot/test/unit/www/test_hooks_base.py index 4b551ec8b6f6..799541e2b0fb 100644 --- a/master/buildbot/test/unit/www/test_hooks_base.py +++ b/master/buildbot/test/unit/www/test_hooks_base.py @@ -39,13 +39,9 @@ def _prepare_request(payload, headers=None): class TestChangeHookConfiguredWithBase(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.changeHook = yield _prepare_base_change_hook(self) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_base_with_change(self, payload): self.request = _prepare_request(payload) @@ -102,7 +98,7 @@ def test_base_with_changes(self): class TestChangeHookConfiguredWithCustomBase(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() class CustomBase(BaseHookHandler): def getChanges(self, request): @@ -117,10 +113,6 @@ def getChanges(self, request): self.changeHook = yield _prepare_base_change_hook(self, custom_class=CustomBase) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_base_with_change(self, payload): self.request = _prepare_request(payload) diff --git a/master/buildbot/test/unit/www/test_hooks_bitbucket.py b/master/buildbot/test/unit/www/test_hooks_bitbucket.py index 779b8568d21f..396c2a5c9dec 100644 --- a/master/buildbot/test/unit/www/test_hooks_bitbucket.py +++ b/master/buildbot/test/unit/www/test_hooks_bitbucket.py @@ -139,16 +139,12 @@ class TestChangeHookConfiguredWithBitbucketChange(unittest.TestCase, TestReactor @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() master = yield fakeMasterForHooks(self) self.change_hook = change_hook.ChangeHookResource( dialects={'bitbucket': True}, master=master ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def testGitWithChange(self): change_dict = {b'payload': [gitJsonPayload]} diff --git a/master/buildbot/test/unit/www/test_hooks_bitbucketcloud.py b/master/buildbot/test/unit/www/test_hooks_bitbucketcloud.py index 9f711eb0e53d..8727052276b1 100644 --- a/master/buildbot/test/unit/www/test_hooks_bitbucketcloud.py +++ b/master/buildbot/test/unit/www/test_hooks_bitbucketcloud.py @@ -684,7 +684,7 @@ def _prepare_request(payload, headers=None, change_dict=None): class TestChangeHookConfiguredWithGitChange(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() master = yield fakeMasterForHooks(self) self.change_hook = change_hook.ChangeHookResource( dialects={ @@ -695,10 +695,6 @@ def setUp(self): master=master, ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertDictSubset(self, expected_dict, response_dict): expected = {} for key in expected_dict.keys(): diff --git a/master/buildbot/test/unit/www/test_hooks_bitbucketserver.py b/master/buildbot/test/unit/www/test_hooks_bitbucketserver.py index d620f61d89d4..d72c339b49bd 100644 --- a/master/buildbot/test/unit/www/test_hooks_bitbucketserver.py +++ b/master/buildbot/test/unit/www/test_hooks_bitbucketserver.py @@ -709,7 +709,7 @@ def _prepare_request(payload, headers=None, change_dict=None): class TestChangeHookConfiguredWithGitChange(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() master = yield fakeMasterForHooks(self) self.change_hook = change_hook.ChangeHookResource( dialects={ @@ -720,10 +720,6 @@ def setUp(self): master=master, ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertDictSubset(self, expected_dict, response_dict): expected = {} for key in expected_dict.keys(): diff --git a/master/buildbot/test/unit/www/test_hooks_github.py b/master/buildbot/test/unit/www/test_hooks_github.py index ad5e23a939af..f6bcc3260c99 100644 --- a/master/buildbot/test/unit/www/test_hooks_github.py +++ b/master/buildbot/test/unit/www/test_hooks_github.py @@ -609,7 +609,7 @@ def _prepare_request(event, payload, _secret=None, headers=None): class TestChangeHookConfiguredWithGitChange(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.changeHook = yield _prepare_github_change_hook( self, strict=False, github_property_whitelist=["github.*"] ) @@ -626,10 +626,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertDictSubset(self, expected_dict, response_dict): expected = {} for key in expected_dict.keys(): @@ -887,7 +883,7 @@ class TestChangeHookConfiguredWithGitChangeCustomPullrequestRef( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.changeHook = yield _prepare_github_change_hook( self, strict=False, github_property_whitelist=["github.*"], pullrequest_ref="head" ) @@ -904,10 +900,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_git_pull_request_with_custom_ref(self): commit = deepcopy([gitJsonPayloadPullRequest]) @@ -929,7 +921,7 @@ class TestChangeHookConfiguredWithGitChangeCustomPullrequestRefWithAuth( ): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() _token = '7e076f41-b73a-4045-a817' self.changeHook = yield _prepare_github_change_hook( self, @@ -954,10 +946,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_git_pull_request_with_custom_ref(self): commit = deepcopy([gitJsonPayloadPullRequest]) @@ -980,7 +968,7 @@ class TestChangeHookRefWithAuth(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.changeHook = yield _prepare_github_change_hook( self, @@ -1013,10 +1001,6 @@ def setUp(self): fake_storage.reconfigService(secretdict={self.secret_name: self.secret_value}) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_git_pull_request(self): commit_endpoint = '/repos/defunkt/github/commits/05c588ba8cd510ecbe112d020f215facb17817a7' @@ -1034,7 +1018,7 @@ def test_git_pull_request(self): class TestChangeHookConfiguredWithAuthAndCustomSkips(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() _token = '7e076f41-b73a-4045-a817' self.changeHook = yield _prepare_github_change_hook( self, strict=False, skips=[r'\[ *bb *skip *\]'], token=_token @@ -1055,10 +1039,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_push_with_skip_message(self, payload): self.request = _prepare_request(b'push', payload) @@ -1126,7 +1106,7 @@ def test_pull_request_no_skip(self): class TestChangeHookConfiguredWithAuth(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() _token = '7e076f41-b73a-4045-a817' self.changeHook = yield _prepare_github_change_hook( @@ -1148,10 +1128,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertDictSubset(self, expected_dict, response_dict): expected = {} for key in expected_dict.keys(): @@ -1249,7 +1225,7 @@ def test_git_pull_request_with_skip_message(self): class TestChangeHookConfiguredWithCustomApiRoot(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.changeHook = yield _prepare_github_change_hook( self, strict=False, github_api_endpoint='https://black.magic.io' ) @@ -1266,10 +1242,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_pull_request(self, payload): self.request = _prepare_request(b'pull_request', payload) @@ -1288,7 +1260,7 @@ def test_pull_request(self): class TestChangeHookConfiguredWithCustomApiRootWithAuth(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() _token = '7e076f41-b73a-4045-a817' self.changeHook = yield _prepare_github_change_hook( @@ -1310,10 +1282,6 @@ def setUp(self): yield self.master.startService() self.addCleanup(self.master.stopService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_pull_request(self, payload): self.request = _prepare_request(b'pull_request', payload) @@ -1334,7 +1302,7 @@ class TestChangeHookConfiguredWithStrict(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() fakeStorageService = FakeSecretStorage() fakeStorageService.reconfigService(secretdict={"secret_key": self._SECRET}) @@ -1347,10 +1315,6 @@ def setUp(self): ) self.changeHook.master.addService(secretService) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_signature_ok(self): self.request = _prepare_request(b'push', gitJsonPayload, _secret=self._SECRET) @@ -1442,13 +1406,9 @@ def test_signature_missing(self): class TestChangeHookConfiguredWithCodebaseValue(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.changeHook = yield _prepare_github_change_hook(self, codebase='foobar') - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_git_with_change(self, payload): self.request = _prepare_request(b'push', payload) @@ -1471,13 +1431,9 @@ def _codebase_function(payload): class TestChangeHookConfiguredWithCodebaseFunction(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.changeHook = yield _prepare_github_change_hook(self, codebase=_codebase_function) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def _check_git_with_change(self, payload): self.request = _prepare_request(b'push', payload) @@ -1496,7 +1452,7 @@ def test_git_with_change_json(self): class TestChangeHookConfiguredWithCustomEventHandler(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() class CustomGitHubEventHandler(GitHubEventHandler): def handle_ping(self, _, __): @@ -1507,10 +1463,6 @@ def handle_ping(self, _, __): self, **{'class': CustomGitHubEventHandler} ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_ping(self): self.request = _prepare_request(b'ping', b'{}') diff --git a/master/buildbot/test/unit/www/test_hooks_gitlab.py b/master/buildbot/test/unit/www/test_hooks_gitlab.py index 2adf7f5c6de1..73d1600d43af 100644 --- a/master/buildbot/test/unit/www/test_hooks_gitlab.py +++ b/master/buildbot/test/unit/www/test_hooks_gitlab.py @@ -1019,14 +1019,10 @@ def FakeRequestMR(content): class TestChangeHookConfiguredWithGitChange(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() master = yield fakeMasterForHooks(self) self.changeHook = change_hook.ChangeHookResource(dialects={'gitlab': True}, master=master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def check_changes_tag_event(self, r, project='', codebase=None): self.assertEqual(len(self.changeHook.master.data.updates.changesAdded), 2) change = self.changeHook.master.data.updates.changesAdded[0] @@ -1252,7 +1248,7 @@ class TestChangeHookConfiguredWithSecret(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield fakeMasterForHooks(self) fakeStorageService = FakeSecretStorage() @@ -1266,10 +1262,6 @@ def setUp(self): dialects={'gitlab': {'secret': util.Secret("secret_key")}}, master=self.master ) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_missing_secret(self): self.request = FakeRequest(content=gitJsonPayloadTag) diff --git a/master/buildbot/test/unit/www/test_hooks_gitorious.py b/master/buildbot/test/unit/www/test_hooks_gitorious.py index f81989f8c1e8..e8c0310646d7 100644 --- a/master/buildbot/test/unit/www/test_hooks_gitorious.py +++ b/master/buildbot/test/unit/www/test_hooks_gitorious.py @@ -64,15 +64,11 @@ class TestChangeHookConfiguredWithGitChange(unittest.TestCase, TestReactorMixin): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() dialects = {'gitorious': True} master = yield fakeMasterForHooks(self) self.changeHook = change_hook.ChangeHookResource(dialects=dialects, master=master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - # Test 'base' hook with attributes. We should get a json string # representing a Change object as a dictionary. All values show be set. @defer.inlineCallbacks diff --git a/master/buildbot/test/unit/www/test_hooks_poller.py b/master/buildbot/test/unit/www/test_hooks_poller.py index d8d6f0e33bff..78a26f09b76d 100644 --- a/master/buildbot/test/unit/www/test_hooks_poller.py +++ b/master/buildbot/test/unit/www/test_hooks_poller.py @@ -35,7 +35,7 @@ def poll(self): self.called = True def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() @defer.inlineCallbacks def setUpRequest(self, args, options=True, activate=True): @@ -68,10 +68,6 @@ def setUpRequest(self, args, options=True, activate=True): yield self.request.test_render(self.changeHook) yield util.asyncSleep(0.1) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_no_args(self): yield self.setUpRequest({}) diff --git a/master/buildbot/test/unit/www/test_ldapuserinfo.py b/master/buildbot/test/unit/www/test_ldapuserinfo.py index 56031bf386e2..b27a95e03b79 100644 --- a/master/buildbot/test/unit/www/test_ldapuserinfo.py +++ b/master/buildbot/test/unit/www/test_ldapuserinfo.py @@ -186,7 +186,7 @@ class LdapAvatar(CommonTestCase, TestReactorMixin, WwwTestMixin): @defer.inlineCallbacks def setUp(self): CommonTestCase.setUp(self) - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() master = yield self.make_master(url='http://a/b/', avatar_methods=[self.userInfoProvider]) @@ -195,10 +195,6 @@ def setUp(self): yield self.master.startService() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeUserInfoProvider(self): self.userInfoProvider = ldapuserinfo.LdapUserInfo( uri="ldap://uri", diff --git a/master/buildbot/test/unit/www/test_oauth.py b/master/buildbot/test/unit/www/test_oauth.py index f4438c67bdd5..ad2a02ef140b 100644 --- a/master/buildbot/test/unit/www/test_oauth.py +++ b/master/buildbot/test/unit/www/test_oauth.py @@ -59,7 +59,7 @@ def raise_for_status(self): class OAuth2Auth(TestReactorMixin, www.WwwTestMixin, ConfigErrorsMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() if requests is None: raise unittest.SkipTest("Need to install requests to test oauth2") @@ -147,10 +147,6 @@ def setup_bitbucket_auth(self): auth.reconfigAuth(master, master.config) return auth - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_getGoogleLoginURL(self): auth = yield self.setup_google_auth() @@ -630,7 +626,7 @@ def _instantiateAuth(self, cls, config): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() if requests is None: raise unittest.SkipTest("Need to install requests to test oauth2") @@ -661,7 +657,6 @@ def tearDown(self): for reader in reactor.getReaders(): if isinstance(reader, Server): reader.connectionLost(f) - yield self.tear_down_test_reactor() @defer.inlineCallbacks def test_E2E(self): diff --git a/master/buildbot/test/unit/www/test_resource.py b/master/buildbot/test/unit/www/test_resource.py index 15c325d1680d..b0020ed93b3f 100644 --- a/master/buildbot/test/unit/www/test_resource.py +++ b/master/buildbot/test/unit/www/test_resource.py @@ -28,11 +28,7 @@ class ResourceSubclass(resource.Resource): class Resource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_base_url(self): @@ -49,11 +45,7 @@ def test_reconfigResource_registration(self): class RedirectResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) - - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() + self.setup_test_reactor() @defer.inlineCallbacks def test_redirect(self): diff --git a/master/buildbot/test/unit/www/test_rest.py b/master/buildbot/test/unit/www/test_rest.py index adf972f1caf0..cfb9ef21e979 100644 --- a/master/buildbot/test/unit/www/test_rest.py +++ b/master/buildbot/test/unit/www/test_rest.py @@ -37,13 +37,9 @@ class RestRootResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): maxVersion = 3 def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() _ = graphql # used for import side effect - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_render(self): master = yield self.make_master(url='h:/a/b/') @@ -75,16 +71,12 @@ def test_versions_limited(self): class V2RootResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield self.make_master(url='http://server/path/') self.master.data._scanModule(endpoint) self.rsrc = rest.V2RootResource(self.master) self.rsrc.reconfigResource(self.master.config) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertSimpleError(self, message, responseCode): content = json.dumps({'error': message}) self.assertRequest(content=unicode2bytes(content), responseCode=responseCode) @@ -148,7 +140,7 @@ def test_default_origin(self): class V2RootResource_CORS(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield self.make_master(url='h:/') self.master.data._scanModule(endpoint) self.rsrc = rest.V2RootResource(self.master) @@ -161,10 +153,6 @@ def renderRest(request): self.rsrc.renderRest = renderRest - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertOk(self, expectHeaders=True, content=b'ok', origin=b'h://good'): hdrs = ( { @@ -272,7 +260,7 @@ def test_cors_origin_preflight_bad_origin(self): class V2RootResource_REST(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield self.make_master(url='h:/') self.master.config.www['debug'] = True self.master.data._scanModule(endpoint) @@ -289,10 +277,6 @@ def allow(*args, **kw): endpoint.Test.kind = EndpointKind.COLLECTION endpoint.Test.rtype = endpoint.Test - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertRestCollection( self, typeName, items, total=None, contentType=None, orderSignificant=False ): @@ -769,7 +753,7 @@ def assertRestAuthError(self, message, responseCode=400): class V2RootResource_JSONRPC2(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield self.make_master(url='h:/') def allow(*args, **kw): @@ -781,10 +765,6 @@ def allow(*args, **kw): self.rsrc = rest.V2RootResource(self.master) self.rsrc.reconfigResource(self.master.config) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def assertJsonRpcError(self, message, responseCode=400, jsonrpccode=None): got = {} got['contentType'] = self.request.headers[b'content-type'] diff --git a/master/buildbot/test/unit/www/test_service.py b/master/buildbot/test/unit/www/test_service.py index 2bdd9bbae4ad..249a2c7cb891 100644 --- a/master/buildbot/test/unit/www/test_service.py +++ b/master/buildbot/test/unit/www/test_service.py @@ -59,15 +59,11 @@ def reconfigResource(self, new_config): class Test(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = yield self.make_master(url='h:/a/b/') self.svc = self.master.www = service.WWWService() yield self.svc.setServiceParent(self.master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def makeConfig(self, **kwargs): w = {"port": None, "auth": auth.NoAuth(), "logfileName": 'l'} w.update(kwargs) diff --git a/master/buildbot/test/unit/www/test_sse.py b/master/buildbot/test/unit/www/test_sse.py index d9180bc3c00d..02cc0a119f46 100644 --- a/master/buildbot/test/unit/www/test_sse.py +++ b/master/buildbot/test/unit/www/test_sse.py @@ -32,14 +32,10 @@ class EventResource(TestReactorMixin, www.WwwTestMixin, unittest.TestCase): @defer.inlineCallbacks def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.master = master = yield self.make_master(url=b'h:/a/b/') self.sse = sse.EventResource(master) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - def test_simpleapi(self): self.render_resource(self.sse, b'/changes/*/*') self.readUUID(self.request) diff --git a/master/buildbot/test/util/integration.py b/master/buildbot/test/util/integration.py index 2ce51d9ebcc5..09180d287e76 100644 --- a/master/buildbot/test/util/integration.py +++ b/master/buildbot/test/util/integration.py @@ -176,7 +176,7 @@ async def print_build(build, master: BuildMaster, out=sys.stdout, with_logs=Fals class RunFakeMasterTestCase(unittest.TestCase, TestReactorMixin, DebugIntegrationLogsMixin): def setUp(self): - self.setup_test_reactor(auto_tear_down=False) + self.setup_test_reactor() self.setupDebugIntegrationLogs() def cleanup(): @@ -184,10 +184,6 @@ def cleanup(): self.addCleanup(cleanup) - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def setup_master(self, config_dict): self.tested_master = TestedMaster() From 440f2a1da5f4dcd03fd20fc2794e676ec2c45e04 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 8 Dec 2024 20:03:46 +0200 Subject: [PATCH 18/18] test: Deprecate auto_tear_down=False of setup_test_reactor() --- master/buildbot/test/reactor.py | 4 ++++ master/buildbot/test/unit/steps/test_shellsequence.py | 2 +- master/buildbot/test/unit/steps/test_source_git.py | 4 ++-- master/docs/manual/configuration/tests/reactor.rst | 8 +++----- master/docs/manual/configuration/tests/steps.rst | 6 +----- newsfragments/tests_teardown.removal | 1 + 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/master/buildbot/test/reactor.py b/master/buildbot/test/reactor.py index 4fda2382b41d..feb76bfebd6e 100644 --- a/master/buildbot/test/reactor.py +++ b/master/buildbot/test/reactor.py @@ -23,6 +23,7 @@ from buildbot.test.fake.reactor import TestReactor from buildbot.util import twisted from buildbot.util.eventual import _setReactor +from buildbot.warnings import warn_deprecated class TestReactorMixin: @@ -32,6 +33,9 @@ class TestReactorMixin: """ def setup_test_reactor(self, use_asyncio=False, auto_tear_down=True): + if not auto_tear_down: + warn_deprecated('4.2.0', 'auto_tear_down=False is deprecated') + self.patch(threadpool, 'ThreadPool', NonThreadPool) self.patch(twisted, 'ThreadPool', NonThreadPool) self.reactor = TestReactor() diff --git a/master/buildbot/test/unit/steps/test_shellsequence.py b/master/buildbot/test/unit/steps/test_shellsequence.py index f4f046e1f1a2..bdaf0d7f8152 100644 --- a/master/buildbot/test/unit/steps/test_shellsequence.py +++ b/master/buildbot/test/unit/steps/test_shellsequence.py @@ -38,7 +38,7 @@ class TestOneShellCommand( TestBuildStepMixin, configmixin.ConfigErrorsMixin, TestReactorMixin, unittest.TestCase ): def setUp(self): - self.setup_test_reactor(auto_tear_down=True) + self.setup_test_reactor() return self.setup_test_build_step() def testShellArgInput(self): diff --git a/master/buildbot/test/unit/steps/test_source_git.py b/master/buildbot/test/unit/steps/test_source_git.py index 52d45af1456d..5045baa3b8f2 100644 --- a/master/buildbot/test/unit/steps/test_source_git.py +++ b/master/buildbot/test/unit/steps/test_source_git.py @@ -4178,7 +4178,7 @@ class TestGitPush( stepClass = git.GitPush def setUp(self): - self.setup_test_reactor(auto_tear_down=True) + self.setup_test_reactor() return self.setup_test_build_step() @parameterized.expand([ @@ -4656,7 +4656,7 @@ class TestGitTag(TestBuildStepMixin, config.ConfigErrorsMixin, TestReactorMixin, stepClass = git.GitTag def setUp(self): - self.setup_test_reactor(auto_tear_down=True) + self.setup_test_reactor() return self.setup_test_build_step() def test_tag_annotated(self): diff --git a/master/docs/manual/configuration/tests/reactor.rst b/master/docs/manual/configuration/tests/reactor.rst index 279183b831b7..7e5c8ba21ed2 100644 --- a/master/docs/manual/configuration/tests/reactor.rst +++ b/master/docs/manual/configuration/tests/reactor.rst @@ -18,14 +18,12 @@ TestReactorMixin .. py:method:: setup_test_reactor(use_asyncio=False, auto_tear_down=True) :param bool use_asyncio: Whether to enable asyncio integration. - :param bool auto_tear_down: Whether to automatically tear down the test reactor. This - option is deprecated in favor of ``tear_down_test_reactor()`` as the automatic tear - down can only run before ``tearDown()`` and thus in many tests the test reactor is - shut down prematurely. + :param bool auto_tear_down: Whether to automatically tear down the test reactor. + Setting it to ``False`` is deprecated. Call this function in the ``setUp()`` of the test case to setup fake reactor. .. py:method:: tear_down_test_reactor() Call this function in the ``tearDown()`` of the test case to tear down fake reactor. - The function returns a ``Deferred``. + This function is deprecated. The function returns a ``Deferred``. diff --git a/master/docs/manual/configuration/tests/steps.rst b/master/docs/manual/configuration/tests/steps.rst index e8ea94e16043..c1c787ae5694 100644 --- a/master/docs/manual/configuration/tests/steps.rst +++ b/master/docs/manual/configuration/tests/steps.rst @@ -18,13 +18,9 @@ TestBuildStepMixin @defer.inlineCallbacks def setUp(self): - yield self.setup_test_reactor(auto_tear_down=False) + yield self.setup_test_reactor() yield self.setup_test_build_step() - @defer.inlineCallbacks - def tearDown(self): - yield self.tear_down_test_reactor() - @defer.inlineCallbacks def test_run_ok(self): self.setup_step(python_twisted.RemovePYCs()) diff --git a/newsfragments/tests_teardown.removal b/newsfragments/tests_teardown.removal index 3ca1cee404a5..c38ac27249ac 100644 --- a/newsfragments/tests_teardown.removal +++ b/newsfragments/tests_teardown.removal @@ -1,6 +1,7 @@ The following test tear down functions have been deprecated: - ``TestBuildStepMixin.tear_down_test_build_step()`` + - ``TestReactorMixin.tear_down_test_reactor()`` The tear down is now run automatically. Any additional test tear down should be run using ``twisted.trial.TestCase.addCleanup`` to better control tear down ordering.