def setup_class(self): # It's not ideal that we make a virtualenv only once, # but I'd rather do this than use a fake virtualenv # or wait an hour for tests to finish most of the time self.parent = TempDir() self.venv = TempVenv(self.parent.path, "vex_tests", []) self.venv.open()
def test_remove(self): parent = TempDir() venv = TempVenv(parent.path, 'vex_tests', []) venv.open() assert os.path.exists(venv.path) assert os.path.exists(parent.path) env = {'WORKON_HOME': parent.path.decode('utf-8')} with Run(['--remove', venv.name, 'echo', '42'], env=env) as run: run.finish() assert run.out is not None assert b'42' in run.out assert run.command_found assert run.returned == 0 assert not run.err assert not os.path.exists(venv.path) assert os.path.exists(parent.path) venv.close() parent.close()
def test_remove(self): parent = TempDir() home = TempDir() env = {"HOME": home.path, "WORKON_HOME": parent.path.decode("utf-8")} venv = TempVenv(parent.path, "vex_tests", []) venv.open() assert os.path.exists(venv.path) assert os.path.exists(parent.path) run = Run(["--remove", venv.name, "echo", "42"], env=env) vexrc = TempVexrcFile(home.path, ) with home, vexrc, run: run.finish() assert run.out is not None assert b"42" in run.out assert run.command_found assert run.returned == 0 assert not run.err assert not os.path.exists(venv.path) assert os.path.exists(parent.path) venv.close() parent.close()
def test_find_with_HOME(): """vex venvname echo foo with HOME set to a path containing a .virtualenvs dir containing a directory named venvname, resolve venvname as that directory and run without error. """ # 1. Make a temp directory # 2. Point the HOME variable at that # 3. Make a .virtualenvs directory in it # 4. Make a tempvenv inside that (time-consuming though...) # 5. run vex, passing basename of the tempvenv home = TempDir() workon_home = os.path.join(home.path, b".virtualenvs") assert isinstance(workon_home, path_type) os.mkdir(workon_home) name = "vex_test_find_with_HOME" venv = TempVenv(workon_home, name, []) env = {"HOME": home.path} with home, venv, Run([name, "echo", "foo"], env=env) as run: run.finish() assert run.command_found assert run.returned == 0 assert run.out == b"foo\n"