def test_whole_copy(self): base = path.dirname(rvirtualenv.__file__) os.chdir(path.join(base, 'template', 'venv')) a = list(store_directory_structure('.')) os.chdir(base) b = store_directory_structure('.') # filter only rvirtualenvinstall b = [ i for i in b if 'rvirtualenvinstall' in i[0] ] # extract not wanted b = [ i for i in b if 'template' not in i[0] ] os.chdir(path.join(base, 'template')) c = store_directory_structure('.') patrn = path.join('.', 'inst') repl = path.join('.', 'src', 'rvirtualenvkeep') c = [ (i.replace(patrn, repl),j) for (i,j) in c if patrn in i ] d = [(path.join('.', 'src'), None)] expected = sorted(a+b+c+d) # extract not wanted - aka those that are ignored expected = [ i for i in expected if '__pycache__' not in i[0] ] expected = [ i for i in expected if not i[0].endswith('pyc') ] copy(self.virtualenv) os.chdir(self.virtualenv) x = store_directory_structure('.') x = [ i for i in x if '__pycache__' not in i[0] ] got = sorted(x) self.failUnlessEqual([i for (i,j) in expected], [i for (i,j) in got]) self.failUnlessEqual(expected, got)
def create(name, sitepackages, prompt): ''' create rvirtualenv ''' venv = path.join(os.getcwd(), name) copy(venv) generate(venv, sitepackages=sitepackages, prompt=prompt)
def test_whole_copy(self): base = path.dirname(rvirtualenv.__file__) os.chdir(path.join(base, 'template', 'venv')) a = list(store_directory_structure('.')) os.chdir(base) b = store_directory_structure('.') # filter only rvirtualenvinstall b = [i for i in b if 'rvirtualenvinstall' in i[0]] # extract not wanted b = [i for i in b if 'template' not in i[0]] os.chdir(path.join(base, 'template')) c = store_directory_structure('.') patrn = path.join('.', 'inst') repl = path.join('.', 'src', 'rvirtualenvkeep') c = [(i.replace(patrn, repl), j) for (i, j) in c if patrn in i] d = [(path.join('.', 'src'), None)] expected = sorted(a + b + c + d) # extract not wanted - aka those that are ignored expected = [i for i in expected if '__pycache__' not in i[0]] expected = [i for i in expected if not i[0].endswith('pyc')] copy(self.virtualenv) os.chdir(self.virtualenv) x = store_directory_structure('.') x = [i for i in x if '__pycache__' not in i[0]] got = sorted(x) self.failUnlessEqual([i for (i, j) in expected], [i for (i, j) in got]) self.failUnlessEqual(expected, got)
def test_whole_copy(self): base = path.dirname(rvirtualenv.__file__) venv = path.join(base, 'template', 'venv') os.chdir(venv) expected = sorted(self.store_directory_structure('.')) copy(self.virtualenv) os.chdir(self.virtualenv) got = sorted(self.store_directory_structure('.')) self.failUnlessEqual(expected, got)
def main(argv=None): ''' main call for rvirtualenv command ''' if argv is None: argv = sys.argv if len(argv) < 2: raise NotImplementedError venv = argv[1] copy(venv) generate(venv)
def test_whole_generate(self, layout=None): copy(self.virtualenv) generate(self.virtualenv, layout=layout) structure = store_directory_structure(self.virtualenv, content='<file>') if layout is None: layout = guess_scheme() paths = set((i for i,j in structure)) vars = {'base': self.virtualenv} self.assertTrue(get_scheme(layout, 'purelib', vars=vars) in paths) self.assertTrue(get_scheme(layout, 'scripts', vars=vars) in paths) pybin = path.join(get_scheme(layout, 'scripts', vars=vars), 'python.py') self.assertTrue(path.exists(pybin)) pyrc = path.join(self.virtualenv, 'pythonrc.py') self.assertTrue(path.exists(pyrc)) content = open(pyrc, 'r').read() self.assertFalse("scheme = 'custom'" in content)
def test_whole_generate(self, layout=None): copy(self.virtualenv) generate(self.virtualenv, layout=layout) structure = store_directory_structure(self.virtualenv, content='<file>') if layout is None: layout = guess_scheme() paths = set((i for i, j in structure)) vars = {'base': self.virtualenv} self.assertTrue(get_scheme(layout, 'purelib', vars=vars) in paths) self.assertTrue(get_scheme(layout, 'scripts', vars=vars) in paths) pybin = path.join(get_scheme(layout, 'scripts', vars=vars), 'python.py') self.assertTrue(path.exists(pybin)) pyrc = path.join(self.virtualenv, 'pythonrc.py') self.assertTrue(path.exists(pyrc)) content = open(pyrc, 'r').read() self.assertFalse("scheme = 'custom'" in content)