Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Unified Diff: unittests/package_test.py

Issue 1849903002: Perform Git operations without changing CWD. (Closed) Base URL: https://github.com/luci/recipes-py@master
Patch Set: Cleaner. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/package.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unittests/package_test.py
diff --git a/unittests/package_test.py b/unittests/package_test.py
index 019ede44d7c7bf31666ae0baeb323d90deb73506..e2f0aaef5599387137135e523b66f4eaa556dc58 100755
--- a/unittests/package_test.py
+++ b/unittests/package_test.py
@@ -5,6 +5,7 @@
import doctest
import os
+import subprocess
import sys
import unittest
@@ -25,9 +26,11 @@ class MockIOThings(object):
self.mock_os.path.dirname = os.path.dirname
self.mock_os.sep = os.sep
+ self.orig_subprocess = subprocess
self.mock_subprocess_patcher = mock.patch(
'recipe_engine.package.subprocess')
self.mock_subprocess = self.mock_subprocess_patcher.start()
+ self.mock_subprocess.PIPE = self.orig_subprocess.PIPE
def tearDown(self):
self.mock_subprocess_patcher.stop()
@@ -59,13 +62,13 @@ class TestGitRepoSpec(MockIOThings, unittest.TestCase):
self.repo_spec.checkout(self.context)
- self.mock_subprocess.check_call.assert_any_call(
+ self.mock_subprocess.check_output.assert_any_call(
['git', 'clone', self.REPO_URL,
- os.path.join(self.context.package_dir, 'funny_recipes')],
- cwd=None)
- self.mock_subprocess.check_call.assert_any_call(
- ['git', 'reset', '-q', '--hard', 'deadbeef'],
- cwd='repo/root/recipes/.recipe_deps/funny_recipes')
+ os.path.join(self.context.package_dir, 'funny_recipes')])
+ self.mock_subprocess.check_output.assert_any_call(
+ ['git',
+ '--git-dir', 'repo/root/recipes/.recipe_deps/funny_recipes/.git',
+ 'reset', '-q', '--hard', 'deadbeef'])
class MockProtoFile(package.ProtoFile):
« no previous file with comments | « recipe_engine/package.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698