From a157714f98c4d69bc0d354073475b63305bb5599 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Tue, 15 Mar 2022 11:02:17 +0000 Subject: [PATCH] Separate tests comparing objects to markers and requirements --- tests/test_markers.py | 6 ++++-- tests/test_requirements.py | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_markers.py b/tests/test_markers.py index cf09bd111..40445b378 100644 --- a/tests/test_markers.py +++ b/tests/test_markers.py @@ -241,11 +241,13 @@ def test_different_markers_different_hashes(self, example1, example2): marker1, marker2 = Marker(example1), Marker(example2) # Markers created from strings that are not equivalent should differ. assert marker1 != marker2 - # Markers should not be comparable with other kinds of objects. - assert marker1 != example1 # Different Marker objects should have different hashes. assert hash(marker1) != hash(marker2) + def test_compare_markers_to_other_objects(self): + # Markers should not be comparable to other kinds of objects. + assert Marker("os_name == 'nt'") != "os_name == 'nt'" + def test_extra_with_no_extra_in_environment(self): # We can't evaluate an extra if no extra is passed into the environment m = Marker("extra == 'security'") diff --git a/tests/test_requirements.py b/tests/test_requirements.py index 49e4c4608..ad07de760 100644 --- a/tests/test_requirements.py +++ b/tests/test_requirements.py @@ -243,8 +243,9 @@ def test_different_reqs_different_hashes(self, dep1, dep2): # Requirement objects created from non-equivalent strings should differ. req1, req2 = Requirement(dep1), Requirement(dep2) assert req1 != req2 - # Requirement objects should not be comparable with other kinds of objects. - assert req1 != dep1 - assert req2 != dep2 # Different Requirement objects should have different hashes. assert hash(req1) != hash(req2) + + def test_compare_reqs_to_other_objects(self): + # Requirement objects should not be comparable to other kinds of objects. + assert Requirement("packaging>=21.3") != "packaging>=21.3"