Skip to content

Commit

Permalink
Conditionally import subprocess backport. Use context manager-style p…
Browse files Browse the repository at this point in the history
…open.
  • Loading branch information
audreyfeldroy committed Aug 29, 2013
1 parent 804f670 commit 4a3ab65
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/test_vcs.py
Expand Up @@ -26,6 +26,11 @@
input_str = '__builtin__.raw_input'
from cStringIO import StringIO

if sys.version_info[:2] < (2, 7):
import subprocess32 as subprocess
else:
import subprocess

from cookiecutter import vcs


Expand Down Expand Up @@ -53,12 +58,16 @@ def test_git_clone_checkout(self):
git_dir = 'cookiecutter-pypackage'
self.assertEqual(repo_dir, git_dir)
self.assertTrue(os.path.isfile(os.path.join('cookiecutter-pypackage', 'README.rst')))
symbolic_ref = subprocess.Popen(

with subprocess.Popen(
['git', 'symbolic-ref', 'HEAD'],
cwd=git_dir,
stdout=subprocess.PIPE).communicate()[0]
branch = symbolic_ref.decode(encoding).strip().split('/')[-1]
self.assertEqual('console-script', branch)
stdout=subprocess.PIPE
) as proc:
symbolic_ref = proc.communicate()[0]
branch = symbolic_ref.decode(encoding).strip().split('/')[-1]
self.assertEqual('console-script', branch)

if os.path.isdir(git_dir):
shutil.rmtree(git_dir)

Expand Down

0 comments on commit 4a3ab65

Please sign in to comment.