Commits

Marc Abramowitz committed 579d9b3

Add test_pip_install and make slight modification to how
PYTHONIOENCODING environment variable is set (so that it's more easily testable)

Comments (0)

Files changed (2)

tests/test_venv.py

     assert len(l) == 1
     assert '-U' in l[0].args
     assert '--no-deps' in l[0].args
+
+def test_pip_install(newmocksession):
+    mocksession = newmocksession([], "")
+    venv = mocksession.getenv('python')
+    venv.just_created = True
+    venv.envconfig.envdir.ensure(dir=1)
+    venv.pip_install(args=["whatever"])
+    l = mocksession._pcalls
+    assert len(l) == 1
+    assert 'pip' in l[0].args[0]
+    assert 'install' in l[0].args
+    env = l[0].env
+    assert env is not None
+    assert 'PYTHONIOENCODING' in env
+    assert env['PYTHONIOENCODING'] == 'utf_8'
         except KeyError:
             pass
         argv += args
-        os.environ['PYTHONIOENCODING'] = 'utf_8'
-        self._pcall(argv, cwd=self.envconfig.envlogdir)
+        env = os.environ.copy()
+        env['PYTHONIOENCODING'] = 'utf_8'
+        self._pcall(argv, cwd=self.envconfig.envlogdir, env=env)
 
     def _install(self, deps):
         if not deps: