Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_dirs_differance(self, bin_diff, package_diff, expected):
flexmock(DirsContent).should_receive('__sub__').and_return(
DirsContent(bin_diff, package_diff))
self.venv.get_dirs_differance()
assert ((self.venv.data['packages'],
self.venv.data['py_modules'],
self.venv.data['scripts'],
self.venv.data['has_pth']) == expected)
def test_get_dirs_differance(self, bin_diff, package_diff, expected):
flexmock(DirsContent).should_receive('__sub__').and_return(
DirsContent(bin_diff, package_diff))
self.venv.get_dirs_differance()
assert ((self.venv.data['packages'],
self.venv.data['py_modules'],
self.venv.data['scripts'],
self.venv.data['has_pth']) == expected)
def test_sub_sitepackages(self, before, after, expected):
result = DirsContent(lib_sitepackages=after, bindir=set([])) -\
DirsContent(lib_sitepackages=before, bindir=set([]))
assert result.lib_sitepackages == expected
def test_sub_bin(self, before, after, expected):
result = DirsContent(bindir=after, lib_sitepackages=set([])) -\
DirsContent(bindir=before, lib_sitepackages=set([]))
assert result.bindir == expected
def __sub__(self, other):
'''
Makes differance of DirsContents objects attributes
'''
if any([self.bindir is None, self.lib_sitepackages is None,
other.bindir is None, other.lib_sitepackages is None]):
raise ValueError("Some of the attributes is uninicialized")
result = DirsContent(
self.bindir - other.bindir,
self.lib_sitepackages - other.lib_sitepackages)
return result
base_python_version):
self.name = name
self.version = version
self.temp_dir = temp_dir
self.name_convertor = name_convertor
if not base_python_version:
base_python_version = DEFAULT_PYTHON_VERSION
python_version = 'python' + base_python_version
self.env = VirtualEnvironment(temp_dir + '/venv',
python=python_version)
try:
self.env.open_or_create()
except (ve.VirtualenvCreationException,
ve.VirtualenvReadonlyException):
raise VirtualenvFailException('Failed to create virtualenv')
self.dirs_before_install = DirsContent()
self.dirs_after_install = DirsContent()
self.dirs_before_install.fill(temp_dir + '/venv/')
self.data = {}
self.name = name
self.version = version
self.temp_dir = temp_dir
self.name_convertor = name_convertor
if not base_python_version:
base_python_version = DEFAULT_PYTHON_VERSION
python_version = 'python' + base_python_version
self.env = VirtualEnvironment(temp_dir + '/venv',
python=python_version)
try:
self.env.open_or_create()
except (ve.VirtualenvCreationException,
ve.VirtualenvReadonlyException):
raise VirtualenvFailException('Failed to create virtualenv')
self.dirs_before_install = DirsContent()
self.dirs_after_install = DirsContent()
self.dirs_before_install.fill(temp_dir + '/venv/')
self.data = {}