Index: tests/bot_update_coverage_test.py |
diff --git a/tests/bot_update_coverage_test.py b/tests/bot_update_coverage_test.py |
index f055a9ba64b64c296420cf64bfa3ca39cbda4347..851c8523fc88df19725d66608059de7350279776 100755 |
--- a/tests/bot_update_coverage_test.py |
+++ b/tests/bot_update_coverage_test.py |
@@ -7,6 +7,7 @@ import codecs |
import copy |
import json |
import os |
+import subprocess |
import sys |
import unittest |
@@ -162,6 +163,15 @@ def fake_git(*args, **kwargs): |
return bot_update.call('git', *args, **kwargs) |
+class MockSubprocess(): |
+ def __init__(self): |
+ self.calls = [] |
+ |
+ def call(self, command): |
+ self.calls.append(command) |
+ return 0 |
+ |
+ |
class BotUpdateUnittests(unittest.TestCase): |
def setUp(self): |
self.filesystem = FakeFilesystem() |
@@ -180,11 +190,17 @@ class BotUpdateUnittests(unittest.TestCase): |
self.old_codecs_open = codecs.open |
setattr(codecs, 'open', self.filesystem.open) |
+ self.subprocess = MockSubprocess() |
+ self.old_sp_call = subprocess.call |
+ setattr(subprocess, 'call', self.subprocess.call) |
+ |
def tearDown(self): |
setattr(bot_update, 'call', self.old_call) |
setattr(os, 'getcwd', self.old_os_cwd) |
delattr(bot_update, 'open') |
setattr(codecs, 'open', self.old_codecs_open) |
+ delattr(subprocess, 'call') |
+ setattr(subprocess, 'call', self.old_sp_call) |
def testBasic(self): |
bot_update.ensure_checkout(**self.params) |
@@ -195,6 +211,16 @@ class BotUpdateUnittests(unittest.TestCase): |
bot_update.ensure_checkout(**self.params) |
return self.call.records |
+ def testMaybeRemoveWinLockfile(self): |
+ git_lockfile_err = ''' |
+ fatal: Unable to create 'E:/b/c/b/win/src/.git/index.lock': File exists. |
+ ''' |
+ bot_update.maybe_remove_win_lockfile('win32', git_lockfile_err) |
+ self.assertEqual( |
+ self.subprocess.calls, |
+ [['cmd.exe', '/c', 'del', '/f', |
+ '/q', 'E:/b/c/b/win/src/.git/index.lock']]) |
+ |
if __name__ == '__main__': |
unittest.main() |