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_none_activated(app, tmp_dir):
app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})
venv_name = EnvManager.generate_env_name(
"simple-project", str(app.poetry.file.parent)
)
(Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
(Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()
command = app.find("env list")
tester = CommandTester(command)
tester.execute()
expected = """\
{}-py3.6
{}-py3.7
""".format(
venv_name, venv_name
)
assert expected == tester.io.fetch_output()
def test_remove_by_python_version(app, tmp_dir, mocker):
app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})
venv_name = EnvManager.generate_env_name(
"simple-project", str(app.poetry.file.parent)
)
(Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
(Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()
check_output = mocker.patch(
"poetry.utils._compat.subprocess.check_output",
side_effect=check_output_wrapper(Version.parse("3.6.6")),
)
command = app.find("env remove")
tester = CommandTester(command)
tester.execute("3.6")
assert check_output.called
assert not (Path(tmp_dir) / "{}-py3.6".format(venv_name)).exists()
expected = "Deleted virtualenv: {}\n".format(
(Path(tmp_dir) / "{}-py3.6".format(venv_name))
)
assert expected == tester.io.fetch_output()
def test_explicit_multiple_argument():
command = MySecondCommand()
tester = CommandTester(command)
tester.execute("1 2 3")
assert "1,2,3\n" == tester.io.fetch_output()
def test_export_includes_extras_by_flag(app, repo):
repo.add_package(get_package("foo", "1.0.0"))
repo.add_package(get_package("bar", "1.1.0"))
command = app.find("lock")
tester = CommandTester(command)
tester.execute()
assert app.poetry.locker.lock.exists()
command = app.find("export")
tester = CommandTester(command)
tester.execute("--format requirements.txt --extras feature_bar")
expected = """\
bar==1.1.0
foo==1.0.0
"""
assert expected == tester.io.fetch_output()
def test_standardize_2(self):
table = [["A", "B", "C"], [1, 2, 3], [4, 5, 6]]
dialect = SimpleDialect(delimiter=";", quotechar="", escapechar="")
tmpfname = self._build_file(table, dialect)
tmpfd, tmpoutname = tempfile.mkstemp(prefix="ccsv_", suffix=".csv")
os.close(tmpfd)
application = build_application()
command = application.find("standardize")
tester = CommandTester(command)
tester.execute(f"-o {tmpoutname} {tmpfname}")
# Excel format (i.e. RFC4180) *requires* CRLF
crlf = "\r\n"
exp = crlf.join(["A,B,C", "1,2,3", "4,5,6", ""])
with open(tmpoutname, "r", newline="") as fp:
output = fp.read()
try:
self.assertEqual(exp, output)
finally:
os.unlink(tmpfname)
os.unlink(tmpoutname)
def test_add_constraint_with_extras(app, repo, installer):
command = app.find("add")
tester = CommandTester(command)
cachy1 = get_package("cachy", "0.1.0")
cachy1.extras = {"msgpack": [get_dependency("msgpack-python")]}
msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True)
cachy1.requires = [msgpack_dep]
repo.add_package(get_package("cachy", "0.2.0"))
repo.add_package(cachy1)
repo.add_package(get_package("msgpack-python", "0.5.3"))
tester.execute("cachy[msgpack]>=0.1.0,<0.2.0")
expected = """\
Updating dependencies
Resolving dependencies...
def test_show_latest_non_decorated(app, poetry, installed, repo):
command = app.find("show")
tester = CommandTester(command)
cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package"
pendulum_201 = get_package("pendulum", "2.0.1")
pendulum_201.description = "Pendulum package"
installed.add_package(cachy_010)
installed.add_package(pendulum_200)
repo.add_package(cachy_010)
repo.add_package(cachy_020)
def test_overwrite():
command = MyCommand()
tester = CommandTester(command)
tester.execute("overwrite", decorated=True)
expected = "Processing...{}Done! {}".format("\x08" * 13, "\x08" * 8)
assert expected == tester.io.fetch_output()
def test_show_hides_incompatible_package(app, poetry, installed, repo):
command = app.find("show")
tester = CommandTester(command)
cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package"
installed.add_package(pendulum_200)
poetry.locker.mock_lock_data(
{
"package": [
{
"name": "cachy",
"version": "0.1.0",
"description": "Cachy package",
def test_debug_resolve_tree_option_gives_the_dependency_tree(app, repo):
command = app.find("debug:resolve")
tester = CommandTester(command)
cachy2 = get_package("cachy", "0.2.0")
cachy2.add_dependency("msgpack-python", ">=0.5 <0.6")
repo.add_package(get_package("cachy", "0.1.0"))
repo.add_package(cachy2)
repo.add_package(get_package("msgpack-python", "0.5.3"))
tester.execute(
[("command", command.get_name()), ("package", ["cachy"]), ("--tree", True)]
)
expected = """\
Resolving dependencies...
Resolution results: