Skip to content

Commit

Permalink
Prefer actual-expected to expected-actual in assertions (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
radoering authored Feb 3, 2022
1 parent 98793c8 commit 16a07f5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tests/packages/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def test_to_pep_508_with_patch_python_version(python_versions: str, marker: str)

expected = f"Django (>=1.23,<2.0); {marker}"

assert expected == dependency.to_pep_508()
assert marker == str(dependency.marker)
assert dependency.to_pep_508() == expected
assert str(dependency.marker) == marker


def test_to_pep_508_tilde():
Expand Down
4 changes: 2 additions & 2 deletions tests/packages/test_url_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_to_pep_508():
"pytorch @"
" https://download.pytorch.org/whl/cpu/torch-1.5.1%2Bcpu-cp38-cp38-linux_x86_64.whl"
)
assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected


def test_to_pep_508_with_marker():
Expand All @@ -27,4 +27,4 @@ def test_to_pep_508_with_marker():
" https://download.pytorch.org/whl/cpu/torch-1.5.1%2Bcpu-cp38-cp38-linux_x86_64.whl"
' ; sys_platform == "linux"'
)
assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected
12 changes: 6 additions & 6 deletions tests/packages/test_vcs_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def test_to_pep_508():

expected = "poetry @ git+https://github.com/python-poetry/poetry.git"

assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected


def test_to_pep_508_ssh():
dependency = VCSDependency("poetry", "git", "[email protected]:sdispater/poetry.git")

expected = "poetry @ git+ssh://[email protected]/sdispater/poetry.git"

assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected


def test_to_pep_508_with_extras():
Expand All @@ -30,7 +30,7 @@ def test_to_pep_508_with_extras():

expected = "poetry[foo] @ git+https://github.com/python-poetry/poetry.git"

assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected


def test_to_pep_508_in_extras():
Expand All @@ -42,7 +42,7 @@ def test_to_pep_508_in_extras():
expected = (
'poetry @ git+https://github.com/python-poetry/poetry.git ; extra == "foo"'
)
assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected

dependency = VCSDependency(
"poetry", "git", "https://github.com/python-poetry/poetry.git", extras=["bar"]
Expand All @@ -53,7 +53,7 @@ def test_to_pep_508_in_extras():
'poetry[bar] @ git+https://github.com/python-poetry/poetry.git ; extra == "foo"'
)

assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected

dependency = VCSDependency(
"poetry", "git", "https://github.com/python-poetry/poetry.git", "b;ar;"
Expand All @@ -65,7 +65,7 @@ def test_to_pep_508_in_extras():
' "foo;"'
)

assert expected == dependency.to_pep_508()
assert dependency.to_pep_508() == expected


@pytest.mark.parametrize("groups", [["main"], ["dev"]])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_create_poetry_fails_on_invalid_configuration():
The Poetry configuration is invalid:
- 'description' is a required property
"""
assert expected == str(e.value)
assert str(e.value) == expected


def test_create_poetry_omits_dev_dependencies_iff_with_dev_is_false():
Expand Down
8 changes: 4 additions & 4 deletions tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def test_marker_union_intersect_marker_union_drops_unnecessary_markers():
'python_version >= "2.7" and python_version < "2.8" '
'or python_version >= "3.4" and python_version < "4.0"'
)
assert expected == str(intersection)
assert str(intersection) == expected


def test_marker_union_intersect_multi_marker():
Expand Down Expand Up @@ -669,7 +669,7 @@ def test_parse_version_like_markers(marker: str, env: Dict[str, str]):
def test_without_extras(marker: str, expected: str):
m = parse_marker(marker)

assert expected == str(m.without_extras())
assert str(m.without_extras()) == expected


@pytest.mark.parametrize(
Expand Down Expand Up @@ -713,7 +713,7 @@ def test_exclude(marker: str, excluded: str, expected: str):
if expected == "*":
assert m.exclude(excluded).is_any()
else:
assert expected == str(m.exclude(excluded))
assert str(m.exclude(excluded)) == expected


@pytest.mark.parametrize(
Expand Down Expand Up @@ -759,7 +759,7 @@ def test_exclude(marker: str, excluded: str, expected: str):
def test_only(marker: str, only: List[str], expected: str):
m = parse_marker(marker)

assert expected == str(m.only(*only))
assert str(m.only(*only)) == expected


def test_union_of_a_single_marker_is_the_single_marker():
Expand Down

0 comments on commit 16a07f5

Please sign in to comment.