From f56e719ec94bca67938bedd8f35046e80c44be77 Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Fri, 1 Jun 2018 15:07:07 +0100 Subject: [PATCH] Selectively mock requests_kerberos import To ensure consistent test behaviour need to mock the import of requests_kerberos to be None only for the test classes based off of the default JenkinsTestBase Change-Id: I79903a6b3e4a1677fa1a1980af9f73c84b385828 Depends-On: I56c9580be9a90f5cda7349a148d467e6ff4e9270 --- tests/base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/base.py b/tests/base.py index 4105bbd..06f2b11 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,5 +1,6 @@ import sys +import mock from testscenarios import TestWithScenarios import jenkins @@ -24,11 +25,17 @@ class JenkinsTestBase(TestWithScenarios, unittest.TestCase): def setUp(self): super(JenkinsTestBase, self).setUp() - # TODO(darragh) would be useful if this could be mocked - jenkins.requests_kerberos = None + + self.request_kerberos_module_patcher = mock.patch( + 'jenkins.requests_kerberos', None) + self.request_kerberos_module_patcher.start() self.j = jenkins.Jenkins(self.base_url, 'test', 'test') + def tearDown(self): + + self.request_kerberos_module_patcher.stop() + def make_url(self, path): return u'{0}/{1}'.format(self.base_url, path)