[gerrit_util] Fix unstopped mocks.

R=ayatane, yiwzhang

Bug: b/335483238
Change-Id: I9df8c754f25de2ad51cac78eecc2ede08eff5fa1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5646325
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Allen Li <ayatane@chromium.org>
changes/25/5646325/2
Robert Iannucci 8 months ago committed by LUCI CQ
parent 2517f89cdf
commit e5490cc303

@ -607,21 +607,20 @@ class SSOAuthenticatorTest(unittest.TestCase):
def _input_dir(self) -> Path:
return Path(__file__).with_suffix('.inputs') / self._testMethodName
def testCmdAssemblyFound(self):
mock.patch('shutil.which', return_value='/fake/git-remote-sso').start()
@mock.patch('shutil.which', return_value='/fake/git-remote-sso')
def testCmdAssemblyFound(self, _):
self.assertEqual(self.sso._resolve_sso_cmd(),
('/fake/git-remote-sso', '-print_config',
'sso://*.git.corp.google.com'))
self.assertTrue(self.sso.is_applicable())
def testCmdAssemblyNotFound(self):
mock.patch('shutil.which', return_value=None).start()
@mock.patch('shutil.which', return_value=None)
def testCmdAssemblyNotFound(self, _):
self.assertEqual(self.sso._resolve_sso_cmd(), ())
self.assertFalse(self.sso.is_applicable())
def testCmdAssemblyCached(self):
which = mock.patch('shutil.which',
return_value='/fake/git-remote-sso').start()
@mock.patch('shutil.which', return_value='/fake/git-remote-sso')
def testCmdAssemblyCached(self, which):
self.sso._resolve_sso_cmd()
self.sso._resolve_sso_cmd()
self.assertEqual(which.called, 1)

Loading…
Cancel
Save