Skip to content

Commit 0d4fc3a

Browse files
committed
use parametrized, merge tests
1 parent d8c1281 commit 0d4fc3a

File tree

1 file changed

+11
-65
lines changed

1 file changed

+11
-65
lines changed

tests/console/commands/test_show.py

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,15 +1981,13 @@ def test_show_required_by_deps(
19811981
assert actual == expected
19821982

19831983

1984-
def test_show_entire_description_with_no_truncate(
1985-
tester: CommandTester, poetry: Poetry, installed: Repository
1984+
@pytest.mark.parametrize("truncate", [False, True])
1985+
def test_show_entire_description_truncate(
1986+
tester: CommandTester, poetry: Poetry, installed: Repository, truncate: str
19861987
) -> None:
19871988
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0"))
19881989

19891990
cachy2 = get_package("cachy", "0.2.0")
1990-
cachy2.description = (
1991-
"This is a veeeeeeeery long description that should not be truncated."
1992-
)
19931991
cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6"))
19941992

19951993
installed.add_package(cachy2)
@@ -2001,7 +1999,7 @@ def test_show_entire_description_with_no_truncate(
20011999
{
20022000
"name": "cachy",
20032001
"version": "0.2.0",
2004-
"description": "This is a veeeeeeeery long description that should not be truncated.",
2002+
"description": "This is a veeeeeeeery long description that might be truncated.",
20052003
"category": "main",
20062004
"optional": False,
20072005
"platform": "*",
@@ -2029,67 +2027,15 @@ def test_show_entire_description_with_no_truncate(
20292027
}
20302028
)
20312029

2032-
tester.execute("--no-truncate")
2030+
tester.execute("" if truncate else "--no-truncate")
20332031

2034-
expected = """\
2035-
cachy 0.2.0 This is a veeeeeeeery long description that should not be truncated.
2032+
if truncate:
2033+
expected = """\
2034+
cachy 0.2.0 This is a veeeeeeeery long description that might ...
20362035
msgpack-python (!) 0.5.1"""
2037-
2038-
assert tester.io.fetch_output().strip() == expected
2039-
2040-
2041-
def test_show_entire_description_with_truncate(
2042-
tester: CommandTester, poetry: Poetry, installed: Repository
2043-
) -> None:
2044-
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0"))
2045-
2046-
cachy2 = get_package("cachy", "0.2.0")
2047-
cachy2.description = (
2048-
"This is a veeeeeeeery long description that should be truncated."
2049-
)
2050-
cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.6"))
2051-
2052-
installed.add_package(cachy2)
2053-
2054-
assert isinstance(poetry.locker, TestLocker)
2055-
poetry.locker.mock_lock_data(
2056-
{
2057-
"package": [
2058-
{
2059-
"name": "cachy",
2060-
"version": "0.2.0",
2061-
"description": "This is a veeeeeeeery long description that should be truncated.",
2062-
"category": "main",
2063-
"optional": False,
2064-
"platform": "*",
2065-
"python-versions": "*",
2066-
"checksum": [],
2067-
"dependencies": {"msgpack-python": ">=0.5 <0.6"},
2068-
},
2069-
{
2070-
"name": "msgpack-python",
2071-
"version": "0.5.1",
2072-
"description": "",
2073-
"category": "main",
2074-
"optional": False,
2075-
"platform": "*",
2076-
"python-versions": "*",
2077-
"checksum": [],
2078-
},
2079-
],
2080-
"metadata": {
2081-
"python-versions": "*",
2082-
"platform": "*",
2083-
"content-hash": "123456789",
2084-
"files": {"cachy": [], "msgpack-python": []},
2085-
},
2086-
}
2087-
)
2088-
2089-
tester.execute()
2090-
2091-
expected = """\
2092-
cachy 0.2.0 This is a veeeeeeeery long description that should...
2036+
else:
2037+
expected = """\
2038+
cachy 0.2.0 This is a veeeeeeeery long description that might be truncated.
20932039
msgpack-python (!) 0.5.1"""
20942040

20952041
assert tester.io.fetch_output().strip() == expected

0 commit comments

Comments
 (0)