Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 test_project_without_args(tmpfolder):
old_args = [
"my_project",
"-u",
"http://www.blue-yonder.com/",
"-d",
"my description",
]
cli.main(old_args)
args = ["my_project"]
opts = cli.parse_args(args)
opts = cli.process_opts(opts)
new_opts = info.project(opts)
assert new_opts["url"] == "http://www.blue-yonder.com/"
assert new_opts["package"] == "my_project"
assert new_opts["license"] == "mit"
assert new_opts["description"] == "my description"
def test_main_with_old_setuptools(old_setuptools_mock):
args = ["my-project"]
with pytest.raises(OldSetuptools):
cli.main(args)
def test_project_with_args(tmpfolder):
old_args = [
"my_project",
"-u",
"http://www.blue-yonder.com/",
"-d",
"my description",
]
cli.main(old_args)
args = ["my_project", "-u", "http://www.google.com/", "-d", "other description"]
opts = cli.parse_args(args)
opts = cli.process_opts(opts)
new_opts = info.project(opts)
assert new_opts["url"] == "http://www.google.com/"
assert new_opts["package"] == "my_project"
assert new_opts["description"] == "other description"
def test_main_when_updating(tmpfolder, capsys, git_mock):
args = ["my-project"]
cli.main(args)
args = ["--update", "my-project"]
cli.main(args)
assert os.path.exists(args[1])
out, _ = capsys.readouterr()
assert "Update accomplished!" in out
def test_pretend_main(tmpfolder, git_mock, caplog):
for flag in ["--pretend", "-P"]:
args = ["my-project", flag]
cli.main(args)
assert not os.path.exists(args[0])
# Check for some log messages
assert find_report(caplog, "invoke", "get_default_options")
assert find_report(caplog, "invoke", "verify_options_consistency")
assert find_report(caplog, "invoke", "define_structure")
assert find_report(caplog, "invoke", "create_structure")
assert find_report(caplog, "create", "setup.py")
assert find_report(caplog, "create", "requirements.txt")
assert find_report(caplog, "create", lp("my_project/__init__.py"))
assert find_report(caplog, "run", "git init")
assert find_report(caplog, "run", "git add")
def test_verbose_main(tmpfolder, git_mock, caplog):
args = ["my-project", "--verbose"]
cli.main(args)
assert os.path.exists(args[0])
# Check for some log messages
assert find_report(caplog, "invoke", "get_default_options")
assert find_report(caplog, "invoke", "verify_options_consistency")
assert find_report(caplog, "invoke", "define_structure")
assert find_report(caplog, "invoke", "create_structure")
assert find_report(caplog, "create", "setup.py")
assert find_report(caplog, "create", "requirements.txt")
assert find_report(caplog, "create", lp("my_project/__init__.py"))
assert find_report(caplog, "run", "git init")
assert find_report(caplog, "run", "git add")
def test_main_with_list_actions(capsys, isolated_logger):
# When putup is called with --list-actions,
args = ["my-project", "--tox", "--list-actions"]
cli.main(args)
# then the action list should be printed,
out, _ = capsys.readouterr()
assert "Planned Actions" in out
assert "pyscaffold.api:get_default_options" in out
assert "pyscaffold.structure:define_structure" in out
assert "pyscaffold.extensions.tox:add_files" in out
assert "pyscaffold.structure:create_structure" in out
assert "pyscaffold.api:init_git" in out
# but no project should be created
assert not os.path.exists(args[0])