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_create_project_without_pre_commit(tmpfolder):
# Given options without the pre-commit extension,
opts = dict(project="proj")
# when the project is created,
create_project(opts)
# then pre-commit files should not exist
assert not path_exists("proj/.pre-commit-config.yaml")
assert not path_exists("proj/.isort.cfg")
def _generate(self):
putup([self.name])
with chdir(self.name):
demoapp_src_dir = path_join(__location__, self.name)
demoapp_dst_root = self.pkg_path
demoapp_dst_pkg = path_join(demoapp_dst_root, "src", self.name)
copyfile(
path_join(demoapp_src_dir, "runner.py"),
path_join(demoapp_dst_pkg, "runner.py"),
)
git("add", path_join(demoapp_dst_pkg, "runner.py"))
copyfile(
path_join(demoapp_src_dir, "setup.cfg"),
path_join(demoapp_dst_root, "setup.cfg"),
)
copyfile(
path_join(demoapp_src_dir, "setup.py"),
path_join(demoapp_dst_root, "setup.py"),
)
def make_commit(self):
with chdir(self.pkg_path):
git("commit", "-a", "-m", "message")
return self
def tag(self, name, message):
with chdir(self.pkg_path):
git("tag", "-a", name, "-m", message)
return self
def test_get_git_root_with_nogit(tmpfolder, nogit_mock):
project = "my_project"
struct = {
project: {
"my_file": "Some other content",
"my_dir": {"my_file": "Some more content"},
}
}
structure.create_structure(struct, {})
with utils.chdir(project):
git_root = repo.get_git_root(default=".")
assert git_root == "."
def tag(self, name, message):
with chdir(self.pkg_path):
git("tag", "-a", name, "-m", message)
return self
def test_is_git_repo(tmpfolder):
assert not repo.is_git_repo("/a-folder/that-not/exist")
newdir = tmpfolder.join("new").ensure_dir()
assert not repo.is_git_repo(str(newdir))
newdir.chdir()
shell.git("init")
tmpfolder.chdir()
assert repo.is_git_repo(str(newdir))
def make_commit(self):
with chdir(self.pkg_path):
git("commit", "-a", "-m", "message")
return self
copyfile(
path_join(demoapp_src_dir, "setup.py"),
path_join(demoapp_dst_root, "setup.py"),
)
git("add", path_join(demoapp_dst_root, "setup.cfg"))
git("add", path_join(demoapp_dst_root, "setup.py"))
if self.data:
data_src_dir = path_join(demoapp_src_dir, "data")
data_dst_dir = path_join(demoapp_dst_pkg, "data")
os.mkdir(data_dst_dir)
copyfile(
path_join(data_src_dir, "hello_world.txt"),
path_join(data_dst_dir, "hello_world.txt"),
)
git("add", path_join(data_dst_dir, "hello_world.txt"))
git("commit", "-m", "Added basic application logic")
# this is needed for Windows 10 which lacks some certificats
self.run("pip", "install", "-q", "certifi")
def test_get_default_opts_with_nogit(nogit_mock):
with pytest.raises(GitNotInstalled):
get_default_options({}, dict(project="my-project"))