Skip to content

Commit

Permalink
fix (test_init): fix tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
finswimmer committed Jun 20, 2020
1 parent 3558f5f commit 99c007d
Showing 1 changed file with 67 additions and 75 deletions.
142 changes: 67 additions & 75 deletions tests/console/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,22 +450,19 @@ def test_predefined_dependency(app, repo, mocker, poetry):
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), ("--dependency", ["pendulum"])])
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("--dependency pendulum", inputs="\n".join(inputs))

output = tester.get_display(True)
expected = """\
[tool.poetry]
name = "my-package"
Expand All @@ -476,12 +473,12 @@ def test_predefined_dependency(app, repo, mocker, poetry):
[tool.poetry.dependencies]
python = "~2.7 || ^3.6"
pendulum = "^2.0"
pendulum = "^2.0.0"
[tool.poetry.dev-dependencies]
"""

assert expected in output
assert expected in tester.io.fetch_output()


def test_predefined_and_interactive_dependencies(app, repo, mocker, poetry):
Expand All @@ -496,26 +493,24 @@ def test_predefined_and_interactive_dependencies(app, repo, mocker, poetry):
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
"", # Interactive packages
"pyramid", # Search for package
"0", # First option
"", # Do not set constraint
"", # Stop searching for packages
"n", # Interactive dev packages
"\n", # Generate
]
)
tester.execute([("command", command.name), ("--dependency", ["pendulum"])])
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
"pyramid", # Search for package
"0", # First option
"", # Do not set constraint
"", # Stop searching for packages
"n", # Interactive dev packages
"\n", # Generate
]

tester.execute("--dependency pendulum", inputs="\n".join(inputs))

output = tester.get_display(True)
expected = """\
[tool.poetry]
name = "my-package"
Expand All @@ -527,9 +522,9 @@ def test_predefined_and_interactive_dependencies(app, repo, mocker, poetry):
[tool.poetry.dependencies]
python = "~2.7 || ^3.6"
"""

output = tester.io.fetch_output()
assert expected in output
assert 'pendulum = "^2.0"' in output
assert 'pendulum = "^2.0.0"' in output
assert 'pyramid = "^1.10"' in output


Expand All @@ -544,22 +539,20 @@ def test_predefined_dev_dependency(app, repo, mocker, poetry):
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), ("--dev-dependency", ["pytest"])])
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("--dev-dependency pytest", inputs="\n".join(inputs))

output = tester.get_display(True)
expected = """\
[tool.poetry]
name = "my-package"
Expand All @@ -572,10 +565,10 @@ def test_predefined_dev_dependency(app, repo, mocker, poetry):
python = "~2.7 || ^3.6"
[tool.poetry.dev-dependencies]
pytest = "^3.6"
pytest = "^3.6.0"
"""

assert expected in output
assert expected in tester.io.fetch_output()


def test_predefined_and_interactive_dev_dependencies(app, repo, mocker, poetry):
Expand All @@ -590,26 +583,24 @@ def test_predefined_and_interactive_dev_dependencies(app, repo, mocker, poetry):
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
"", # Interactive dev packages
"pytest-requests", # Search for package
"0", # Select first option
"", # Do not set constraint
"", # Stop searching for dev packages
"\n", # Generate
]
)
tester.execute([("command", command.name), ("--dev-dependency", ["pytest"])])
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
"", # Interactive dev packages
"pytest-requests", # Search for package
"0", # Select first option
"", # Do not set constraint
"", # Stop searching for dev packages
"\n", # Generate
]

tester.execute("--dev-dependency pytest", inputs="\n".join(inputs))

output = tester.get_display(True)
expected = """\
[tool.poetry]
name = "my-package"
Expand All @@ -624,6 +615,7 @@ def test_predefined_and_interactive_dev_dependencies(app, repo, mocker, poetry):
[tool.poetry.dev-dependencies]
"""

output = tester.io.fetch_output()
assert expected in output
assert 'pytest-requests = "^0.2.0"' in output
assert 'pytest = "^3.6"' in output
assert 'pytest = "^3.6.0"' in output

0 comments on commit 99c007d

Please sign in to comment.