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_make_sure_path_exists():
if sys.platform.startswith('win'):
existing_directory = os.path.abspath(os.curdir)
uncreatable_directory = 'a*b'
else:
existing_directory = '/usr/'
uncreatable_directory = '/this-doesnt-exist-and-cant-be-created/'
assert utils.make_sure_path_exists(existing_directory)
assert utils.make_sure_path_exists('tests/blah')
assert utils.make_sure_path_exists('tests/trailingslash/')
assert not utils.make_sure_path_exists(uncreatable_directory)
utils.rmtree('tests/blah/')
utils.rmtree('tests/trailingslash/')
def fin_remove_additional_folders():
if os.path.exists('inputpizzä'):
utils.rmtree('inputpizzä')
if os.path.exists('inputgreen'):
utils.rmtree('inputgreen')
if os.path.exists('inputbinary_files'):
utils.rmtree('inputbinary_files')
if os.path.exists('tests/custom_output_dir'):
utils.rmtree('tests/custom_output_dir')
if os.path.exists('inputpermissions'):
utils.rmtree('inputpermissions')
request.addfinalizer(fin_remove_additional_folders)
def tearDown(self):
with utils.work_in(config.DEFAULT_CONFIG['cookiecutters_dir']):
if os.path.isdir('cookiecutter-pypackage'):
utils.rmtree('cookiecutter-pypackage')
if os.path.isdir('boilerplate'):
utils.rmtree('boilerplate')
super(TestGitBranch, self).tearDown()
def fin_remove_additional_folders():
if os.path.exists('tests/test-pyhooks/inputpyhooks'):
utils.rmtree('tests/test-pyhooks/inputpyhooks')
if os.path.exists('inputpyhooks'):
utils.rmtree('inputpyhooks')
if os.path.exists('tests/test-shellhooks'):
utils.rmtree('tests/test-shellhooks')
request.addfinalizer(fin_remove_additional_folders)
def fin_remove_additional_folders():
if os.path.exists('tests/test-pyhooks/inputpyhooks'):
utils.rmtree('tests/test-pyhooks/inputpyhooks')
if os.path.exists('inputpyhooks'):
utils.rmtree('inputpyhooks')
if os.path.exists('tests/test-shellhooks'):
utils.rmtree('tests/test-shellhooks')
request.addfinalizer(fin_remove_additional_folders)
def fin_remove_additional_folders():
if os.path.isdir('cookiecutter-pypackage'):
utils.rmtree('cookiecutter-pypackage')
if os.path.isdir('boilerplate'):
utils.rmtree('boilerplate')
if os.path.isdir('cookiecutter-trytonmodule'):
utils.rmtree('cookiecutter-trytonmodule')
if os.path.isdir('module_name'):
utils.rmtree('module_name')
request.addfinalizer(fin_remove_additional_folders)
def fin_remove_additional_dirs():
with utils.work_in(config.DEFAULT_CONFIG['cookiecutters_dir']):
if os.path.isdir('cookiecutter-pypackage'):
utils.rmtree('cookiecutter-pypackage')
if os.path.isdir('boilerplate'):
utils.rmtree('boilerplate')
request.addfinalizer(fin_remove_additional_dirs)
def fin_remove_additional_dirs():
if os.path.isdir('cookiecutter-pypackage'):
utils.rmtree('cookiecutter-pypackage')
if os.path.isdir('boilerplate'):
utils.rmtree('boilerplate')
request.addfinalizer(fin_remove_additional_dirs)
# conditions.
if self.cookiecutters_dir_found:
# Delete the created ~/.cookiecutters dir as long as a backup exists
if os.path.isdir(self.cookiecutters_dir) and os.path.isdir(self.cookiecutters_dir_backup):
utils.rmtree(self.cookiecutters_dir)
else:
# Delete the created ~/.cookiecutters dir.
# There's no backup because it never existed
if os.path.isdir(self.cookiecutters_dir):
utils.rmtree(self.cookiecutters_dir)
# Restore the user's default cookiecutters_dir contents
if os.path.isdir(self.cookiecutters_dir_backup):
shutil.copytree(self.cookiecutters_dir_backup, self.cookiecutters_dir)
if os.path.isdir(self.cookiecutters_dir):
utils.rmtree(self.cookiecutters_dir_backup)
def fin_remove_additional_dirs():
if os.path.isdir('cookiecutter-pypackage'):
utils.rmtree('cookiecutter-pypackage')
if os.path.isdir('boilerplate'):
utils.rmtree('boilerplate')
request.addfinalizer(fin_remove_additional_dirs)