Commits

Stefano Rivera committed 201c71e

subprocess.check_call is prettier

  • Participants
  • Parent commits 5b20c98

Comments (0)

Files changed (1)

testing/test_zintegration.py

 
 def create_venv(name):
     tmpdir = udir.join(name)
-    subprocess.call(['virtualenv', '-p', sys.executable, str(tmpdir)])
+    subprocess.check_call(['virtualenv', '-p', sys.executable, str(tmpdir)])
     return tmpdir
 
 SNIPPET_DIR = py.path.local(__file__).join('..', 'snippets')
     python_f.write(py.code.Source(python_snippet))
     try:
         os.chdir(str(SNIPPET_DIR.join(dirname)))
-        venv = venv_dir.join('bin/activate')
-        p = subprocess.Popen(['bash', '-c', '. %(venv)s && '
-                              'python setup.py clean && '
-                              'python setup.py install && '
-                              'python %(python_f)s' % locals()])
-        p.communicate()
-        if p.returncode != 0:
-            raise Exception("crashed")
+        vp = str(venv_dir.join('bin/python'))
+        subprocess.check_call((vp, 'setup.py', 'clean'))
+        subprocess.check_call((vp, 'setup.py', 'install'))
+        subprocess.check_call((vp, str(python_f)))
     finally:
         os.chdir(olddir)