def test_add_constraint_dependencies(app, repo, installer): command = app.find('add') tester = CommandTester(command) cachy2 = get_package('cachy', '0.2.0') msgpack_dep = get_dependency('msgpack-python', '>=0.5 <0.6') cachy2.requires = [ msgpack_dep, ] 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()), ('name', ['cachy=0.2.0'])]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing msgpack-python (0.5.3) - Installing cachy (0.2.0) """ assert tester.get_display() == expected assert len(installer.installs) == 2
def test_add_file_constraint_sdist(app, repo, installer): command = app.find('add') tester = CommandTester(command) repo.add_package(get_package('pendulum', '1.4.4')) tester.execute([('command', command.get_name()), ('name', ['demo']), ('--path', '../distributions/demo-0.1.0.tar.gz')]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing pendulum (1.4.4) - Installing demo (0.1.0) """ assert tester.get_display() == expected assert len(installer.installs) == 2 content = app.poetry.file.read(raw=True)['tool']['poetry'] assert 'demo' in content['dependencies'] assert content['dependencies']['demo'] == { 'path': '../distributions/demo-0.1.0.tar.gz' }
def test_add_constraint(app, repo, installer): command = app.find('add') tester = CommandTester(command) repo.add_package(get_package('cachy', '0.1.0')) repo.add_package(get_package('cachy', '0.2.0')) tester.execute([('command', command.get_name()), ('name', ['cachy=0.1.0'])]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 1 install, 0 updates, 0 removals Writing lock file - Installing cachy (0.1.0) """ assert tester.get_display() == expected assert len(installer.installs) == 1
def test_add_git_constraint(app, repo, installer): command = app.find('add') tester = CommandTester(command) repo.add_package(get_package('pendulum', '1.4.4')) tester.execute([('command', command.get_name()), ('name', ['demo']), ('--git', 'https://github.com/demo/demo.git')]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing pendulum (1.4.4) - Installing demo (0.1.2 9cf87a2) """ assert tester.get_display() == expected assert len(installer.installs) == 2 content = app.poetry.file.read(raw=True)['tool']['poetry'] assert 'demo' in content['dependencies'] assert content['dependencies']['demo'] == { 'git': 'https://github.com/demo/demo.git' }
def test_add_git_constraint_with_poetry(app, repo, installer): command = app.find('add') tester = CommandTester(command) repo.add_package(get_package('pendulum', '1.4.4')) tester.execute([('command', command.get_name()), ('name', ['demo']), ('--git', 'https://github.com/demo/pyproject-demo.git')]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing pendulum (1.4.4) - Installing demo (0.1.2 9cf87a2) """ assert tester.get_display() == expected assert len(installer.installs) == 2
def test_add_constraint_dependencies(app, repo, installer): command = app.find("add") tester = CommandTester(command) cachy2 = get_package("cachy", "0.2.0") msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6") cachy2.requires = [msgpack_dep] 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()), ("name", ["cachy=0.2.0"])]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing msgpack-python (0.5.3) - Installing cachy (0.2.0) """ assert tester.get_display(True) == expected assert len(installer.installs) == 2
def test_debug_resolve_git_dependency(app, repo): repo.add_package(get_package("pendulum", "2.0.3")) repo.add_package(get_package("cleo", "0.6.5")) command = app.find("debug:resolve") tester = CommandTester(command) tester.execute( [ ("command", command.get_name()), ("package", ["git+https://github.com/demo/demo.git"]), ] ) expected = """\ Resolving dependencies... Resolution results: - pendulum (2.0.3) - cleo (0.6.5) - demo (0.1.2) """ assert tester.get_display(True) == expected
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: cachy 0.2.0 `-- msgpack-python >=0.5 <0.6 """ assert tester.get_display(True) == expected
def test_add_no_constraint(app, repo, installer): command = app.find('add') tester = CommandTester(command) repo.add_package(get_package('cachy', '0.1.0')) repo.add_package(get_package('cachy', '0.2.0')) tester.execute([('command', command.get_name()), ('name', ['cachy'])]) expected = """\ Using version ^0.2.0 for cachy Updating dependencies Resolving dependencies... Package operations: 1 install, 0 updates, 0 removals Writing lock file - Installing cachy (0.2.0) """ assert tester.get_display() == expected assert len(installer.installs) == 1 content = app.poetry.file.read(raw=True)['tool']['poetry'] assert 'cachy' in content['dependencies'] assert content['dependencies']['cachy'] == '^0.2.0'
def test_add_no_constraint(app, repo, installer): command = app.find("add") tester = CommandTester(command) repo.add_package(get_package("cachy", "0.1.0")) repo.add_package(get_package("cachy", "0.2.0")) tester.execute([("command", command.get_name()), ("name", ["cachy"])]) expected = """\ Using version ^0.2.0 for cachy Updating dependencies Resolving dependencies... Package operations: 1 install, 0 updates, 0 removals Writing lock file - Installing cachy (0.2.0) """ assert tester.get_display(True) == expected assert len(installer.installs) == 1 content = app.poetry.file.read()["tool"]["poetry"] assert "cachy" in content["dependencies"] assert content["dependencies"]["cachy"] == "^0.2.0"
def test_show_outdated(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' installed.add_package(cachy_010) installed.add_package(pendulum_200) repo.add_package(cachy_010) repo.add_package(cachy_020) repo.add_package(pendulum_200) poetry.locker.mock_lock_data({ 'package': [{ 'name': 'cachy', 'version': '0.1.0', 'description': 'Cachy package', 'category': 'main', 'optional': False, 'platform': '*', 'python-versions': '*', 'checksum': [] }, { 'name': 'pendulum', 'version': '2.0.0', 'description': 'Pendulum package', 'category': 'main', 'optional': False, 'platform': '*', 'python-versions': '*', 'checksum': [] }], 'metadata': { 'python-versions': '*', 'platform': '*', 'content-hash': '123456789', 'hashes': { 'cachy': [], 'pendulum': [], } } }) tester.execute([ ('command', command.get_name()), ('--outdated', True), ]) expected = """\ cachy 0.1.0 0.2.0 Cachy package """ assert tester.get_display() == expected
def test_execute_for_command_alias(self): command = HelpCommand() command.set_application(Application()) tester = CommandTester(command) tester.execute([('command_name', 'li')], {'decorated': False}) self.assertIn('list [options] [--] [<namespace>]', tester.get_display())
def test_add_should_not_select_prereleases(app, repo, installer): command = app.find("add") tester = CommandTester(command) repo.add_package(get_package("pyyaml", "3.13")) repo.add_package(get_package("pyyaml", "4.2b2")) tester.execute([("command", command.get_name()), ("name", ["pyyaml"])]) expected = """\ Using version ^3.13 for pyyaml Updating dependencies Resolving dependencies... Package operations: 1 install, 0 updates, 0 removals Writing lock file - Installing pyyaml (3.13) """ assert tester.get_display(True) == expected assert len(installer.installs) == 1 content = app.poetry.file.read()["tool"]["poetry"] assert "pyyaml" in content["dependencies"] assert content["dependencies"]["pyyaml"] == "^3.13"
def test_add_git_constraint_with_poetry(app, repo, installer): command = app.find("add") tester = CommandTester(command) repo.add_package(get_package("pendulum", "1.4.4")) tester.execute( [ ("command", command.get_name()), ("name", ["demo"]), ("--git", "https://github.com/demo/pyproject-demo.git"), ] ) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing pendulum (1.4.4) - Installing demo (0.1.2 9cf87a2) """ assert tester.get_display(True) == expected assert len(installer.installs) == 2
def test_execute_for_command(self): command = HelpCommand() tester = CommandTester(command) command.set_command(ListCommand()) tester.execute([]) self.assertIn('list [options] [--] [<namespace>]', tester.get_display())
def test_add_constraint(app, repo, installer): command = app.find("add") tester = CommandTester(command) repo.add_package(get_package("cachy", "0.1.0")) repo.add_package(get_package("cachy", "0.2.0")) tester.execute([("command", command.get_name()), ("name", ["cachy=0.1.0"])]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 1 install, 0 updates, 0 removals Writing lock file - Installing cachy (0.1.0) """ assert tester.get_display(True) == expected assert len(installer.installs) == 1
def test_show_outdated(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" installed.add_package(cachy_010) installed.add_package(pendulum_200) repo.add_package(cachy_010) repo.add_package(cachy_020) repo.add_package(pendulum_200) poetry.locker.mock_lock_data({ "package": [ { "name": "cachy", "version": "0.1.0", "description": "Cachy package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, { "name": "pendulum", "version": "2.0.0", "description": "Pendulum package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, ], "metadata": { "python-versions": "*", "platform": "*", "content-hash": "123456789", "hashes": { "cachy": [], "pendulum": [] }, }, }) tester.execute([("command", command.get_name()), ("--outdated", True)]) expected = """\ cachy 0.1.0 0.2.0 Cachy package """ assert tester.get_display(True) == expected
def test_add_git_constraint_with_poetry(app, repo, installer): command = app.find("add") tester = CommandTester(command) repo.add_package(get_package("pendulum", "1.4.4")) tester.execute([ ("command", command.get_name()), ("name", ["demo"]), ("--git", "https://github.com/demo/pyproject-demo.git"), ]) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing pendulum (1.4.4) - Installing demo (0.1.2 9cf87a2) """ assert tester.get_display(True) == expected assert len(installer.installs) == 2
def test_show_outdated(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" installed.add_package(cachy_010) installed.add_package(pendulum_200) repo.add_package(cachy_010) repo.add_package(cachy_020) repo.add_package(pendulum_200) poetry.locker.mock_lock_data( { "package": [ { "name": "cachy", "version": "0.1.0", "description": "Cachy package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, { "name": "pendulum", "version": "2.0.0", "description": "Pendulum package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, ], "metadata": { "python-versions": "*", "platform": "*", "content-hash": "123456789", "hashes": {"cachy": [], "pendulum": []}, }, } ) tester.execute([("command", command.get_name()), ("--outdated", True)]) expected = """\ cachy 0.1.0 0.2.0 Cachy package """ assert tester.get_display(True) == expected
def test_execute_for_application_command(self): application = Application() tester = CommandTester(application.get('help')) tester.execute([('command_name', 'list')]) self.assertRegex( tester.get_display(), 'list \[--raw\] \[namespace\]' )
def test_execute_for_command_alias(self): command = HelpCommand() command.set_application(Application()) tester = CommandTester(command) tester.execute([('command_name', 'li')]) self.assertRegex( tester.get_display(), 'list \[--raw\] \[namespace\]' )
def test_run_non_interactive(self): tester = CommandTester(SomeCommand()) tester.execute([], {'interactive': False}) self.assertEqual( 'execute called\n', tester.get_display() )
def test_execute_for_command(self): command = HelpCommand() tester = CommandTester(command) command.set_command(ListCommand()) tester.execute([]) self.assertRegex( tester.get_display(), 'list \[--raw\] \[namespace\]' )
def test_run_non_interactive(self): tester = CommandTester(TestCommand()) tester.execute([], {'interactive': False}) self.assertEqual( 'execute called\n', tester.get_display() )
def test_run_interactive(self): tester = CommandTester(TestCommand()) tester.execute([], {'interactive': True}) self.assertEqual( 'interact called\nexecute called\n', tester.get_display() )
def test_about(app): command = app.find("check") tester = CommandTester(command) tester.execute([("command", command.get_name())]) expected = """\ All set! """ assert tester.get_display(True) == expected
def test_set_code(self): command = SomeCommand() ret = command.set_code(lambda c: c.line('from the code...')) self.assertEqual(ret, command) tester = CommandTester(command) tester.execute([]) self.assertEqual( 'interact called\nfrom the code...\n', tester.get_display() ) command = SomeCommand() command.set_code(self.callable_method) tester = CommandTester(command) tester.execute([]) self.assertEqual( 'interact called\nfrom the code...\n', tester.get_display() )
def test_set_code(self): command = TestCommand() ret = command.set_code(lambda in_, out_: out_.writeln('from the code...')) self.assertEqual(ret, command) tester = CommandTester(command) tester.execute([]) self.assertEqual( 'interact called\nfrom the code...\n', tester.get_display() ) command = TestCommand() command.set_code(self.callable_method) tester = CommandTester(command) tester.execute([]) self.assertEqual( 'interact called\nfrom the code...\n', tester.get_display() )
def test_about(app): command = app.find('check') tester = CommandTester(command) tester.execute([('command', command.get_name())]) expected = """\ All set! """ assert tester.get_display() == expected
def test_show_basic_with_not_installed_packages_decorated( app, poetry, installed): 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(cachy_010) poetry.locker.mock_lock_data({ "package": [ { "name": "cachy", "version": "0.1.0", "description": "Cachy package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, { "name": "pendulum", "version": "2.0.0", "description": "Pendulum package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, ], "metadata": { "python-versions": "*", "platform": "*", "content-hash": "123456789", "hashes": { "cachy": [], "pendulum": [] }, }, }) tester.execute([("command", command.get_name())], {"decorated": True}) expected = """\ \033[32mcachy \033[0m \033[36m0.1.0\033[0m Cachy package \033[31mpendulum\033[0m \033[36m2.0.0\033[0m Pendulum package """ assert tester.get_display(True) == expected
def test_display_single_setting(app, config): command = app.find("config") command._config = Config(config.file) tester = CommandTester(command) tester.execute([("command", command.get_name()), ("key", "settings.virtualenvs.create")]) expected = """true """ assert tester.get_display(True) == expected
def test_interactive_with_dependencies(app, repo, mocker, poetry): repo.add_package(get_package("pendulum", "2.0.0")) repo.add_package(get_package("pytest", "3.6.0")) command = app.find("init") command._pool = poetry.pool mocker.patch("poetry.utils._compat.Path.open") p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__).parent tester = CommandTester(command) tester.set_inputs( [ "my-package", # Package name "1.2.3", # Version "This is a description", # Description "n", # Author "MIT", # License "~2.7 || ^3.6", # Python "", # Interactive packages "pendulum", # Search for package "0", # First option "", # Do not set constraint "", # Stop searching for packages "", # Interactive dev packages "pytest", # Search for package "0", "", "", "\n", # Generate ] ) tester.execute([("command", command.name)]) output = tester.get_display(True) expected = """\ [tool.poetry] name = "my-package" version = "1.2.3" description = "This is a description" authors = ["Your Name <*****@*****.**>"] license = "MIT" [tool.poetry.dependencies] python = "~2.7 || ^3.6" pendulum = "^2.0" [tool.poetry.dev-dependencies] pytest = "^3.6" """ assert expected in output
def test_show_basic_with_not_installed_packages_decorated(app, poetry, installed): 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(cachy_010) poetry.locker.mock_lock_data({ 'package': [{ 'name': 'cachy', 'version': '0.1.0', 'description': 'Cachy package', 'category': 'main', 'optional': False, 'platform': '*', 'python-versions': '*', 'checksum': [] }, { 'name': 'pendulum', 'version': '2.0.0', 'description': 'Pendulum package', 'category': 'main', 'optional': False, 'platform': '*', 'python-versions': '*', 'checksum': [] }], 'metadata': { 'python-versions': '*', 'platform': '*', 'content-hash': '123456789', 'hashes': { 'cachy': [], 'pendulum': [], } } }) tester.execute([ ('command', command.get_name()), ], {'decorated': True}) expected = """\ \033[32mcachy \033[0m 0.1.0 Cachy package \033[31mpendulum\033[0m 2.0.0 Pendulum package """ assert tester.get_display() == expected
def test_show_basic_with_not_installed_packages_decorated(app, poetry, installed): 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(cachy_010) poetry.locker.mock_lock_data( { "package": [ { "name": "cachy", "version": "0.1.0", "description": "Cachy package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, { "name": "pendulum", "version": "2.0.0", "description": "Pendulum package", "category": "main", "optional": False, "platform": "*", "python-versions": "*", "checksum": [], }, ], "metadata": { "python-versions": "*", "platform": "*", "content-hash": "123456789", "hashes": {"cachy": [], "pendulum": []}, }, } ) tester.execute([("command", command.get_name())], {"decorated": True}) expected = """\ \033[32mcachy \033[0m \033[36m0.1.0\033[0m Cachy package \033[31mpendulum\033[0m \033[36m2.0.0\033[0m Pendulum package """ assert tester.get_display(True) == expected
def test_display_single_setting(app, config): command = app.find("config") command._config = Config(config.file) tester = CommandTester(command) tester.execute( [("command", command.get_name()), ("key", "settings.virtualenvs.create")] ) expected = """true """ assert tester.get_display(True) == expected
def test_interactive_with_dependencies(app, repo, mocker, poetry): repo.add_package(get_package("pendulum", "2.0.0")) repo.add_package(get_package("pytest", "3.6.0")) command = app.find("init") command._pool = poetry.pool mocker.patch("poetry.utils._compat.Path.open") p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__).parent tester = CommandTester(command) tester.set_inputs([ "my-package", # Package name "1.2.3", # Version "This is a description", # Description "n", # Author "MIT", # License "~2.7 || ^3.6", # Python "", # Interactive packages "pendulum", # Search for package "0", # First option "", # Do not set constraint "", # Stop searching for packages "", # Interactive dev packages "pytest", # Search for package "0", "", "", "\n", # Generate ]) tester.execute([("command", command.name)]) output = tester.get_display(True) expected = """\ [tool.poetry] name = "my-package" version = "1.2.3" description = "This is a description" authors = ["Your Name <*****@*****.**>"] license = "MIT" [tool.poetry.dependencies] python = "~2.7 || ^3.6" pendulum = "^2.0" [tool.poetry.dev-dependencies] pytest = "^3.6" """ assert expected in output
def test_list_displays_default_value_if_not_set(app, config): command = app.find("config") command._config = Config(config.file) tester = CommandTester(command) tester.execute([("command", command.get_name()), ("--list", True)]) expected = """settings.virtualenvs.create = true settings.virtualenvs.in-project = false settings.virtualenvs.path = "." repositories = {} """ assert tester.get_display(True) == expected
def test_about(app): command = app.find("about") tester = CommandTester(command) tester.execute([("command", command.get_name())]) expected = """\ Poetry - Package Management for Python Poetry is a dependency manager tracking local dependencies of your projects and libraries. See https://github.com/sdispater/poetry for more information. """ assert tester.get_display(True) == expected
def test_about(app): command = app.find('about') tester = CommandTester(command) tester.execute([('command', command.get_name())]) expected = """\ Poetry - Package Management for Python Poetry is a dependency manager tracking local dependencies of your projects and libraries. See https://github.com/sdispater/poetry for more information. """ assert tester.get_display() == expected
def test_add_constraint_with_extras(app, repo, installer): command = app.find("add") tester = CommandTester(command) cachy2 = get_package("cachy", "0.2.0") cachy2.extras = {"msgpack": [get_dependency("msgpack-python")]} msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True) cachy2.requires = [msgpack_dep] 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()), ("name", ["cachy=0.2.0"]), ("--extras", ["msgpack"]), ] ) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing msgpack-python (0.5.3) - Installing cachy (0.2.0) """ assert tester.get_display(True) == expected assert len(installer.installs) == 2 content = app.poetry.file.read()["tool"]["poetry"] assert "cachy" in content["dependencies"] assert content["dependencies"]["cachy"] == { "version": "0.2.0", "extras": ["msgpack"], }
def test_add_constraint_with_platform(app, repo, installer): platform = sys.platform command = app.find("add") tester = CommandTester(command) cachy2 = get_package("cachy", "0.2.0") repo.add_package(get_package("cachy", "0.1.0")) repo.add_package(cachy2) tester.execute( [ ("command", command.get_name()), ("name", ["cachy=0.2.0"]), ("--platform", platform), ] ) expected = """\ Updating dependencies Resolving dependencies... Package operations: 1 install, 0 updates, 0 removals Writing lock file - Installing cachy (0.2.0) """ assert tester.get_display(True) == expected assert len(installer.installs) == 1 content = app.poetry.file.read()["tool"]["poetry"] assert "cachy" in content["dependencies"] assert content["dependencies"]["cachy"] == { "version": "0.2.0", "platform": platform, }
def test_basic_interactive(app, mocker, poetry): command = app.find("init") command._pool = poetry.pool mocker.patch("poetry.utils._compat.Path.open") p = mocker.patch("poetry.utils._compat.Path.cwd") p.return_value = Path(__file__) tester = CommandTester(command) tester.set_inputs( [ "my-package", # Package name "1.2.3", # Version "This is a description", # Description "n", # Author "MIT", # License "~2.7 || ^3.6", # Python "n", # Interactive packages "n", # Interactive dev packages "\n", # Generate ] ) tester.execute([("command", command.name)]) output = tester.get_display(True) expected = """\ [tool.poetry] name = "my-package" version = "1.2.3" description = "This is a description" authors = ["Your Name <*****@*****.**>"] license = "MIT" [tool.poetry.dependencies] python = "~2.7 || ^3.6" [tool.poetry.dev-dependencies] """ assert expected in output
def test_add_file_constraint_sdist(app, repo, installer): command = app.find("add") tester = CommandTester(command) repo.add_package(get_package("pendulum", "1.4.4")) tester.execute( [ ("command", command.get_name()), ("name", ["demo"]), ("--path", "../distributions/demo-0.1.0.tar.gz"), ] ) expected = """\ Updating dependencies Resolving dependencies... Package operations: 2 installs, 0 updates, 0 removals Writing lock file - Installing pendulum (1.4.4) - Installing demo (0.1.0) """ assert tester.get_display(True) == expected assert len(installer.installs) == 2 content = app.poetry.file.read()["tool"]["poetry"] assert "demo" in content["dependencies"] assert content["dependencies"]["demo"] == { "path": "../distributions/demo-0.1.0.tar.gz" }