@@ -688,13 +688,7 @@ def test_specifiers_prereleases(
688688 # Test != with invalid versions (should not pass as versions are not valid)
689689 ("!=1.0" , None , None , ["invalid" , "foobar" ], []),
690690 ("!=1.0" , None , None , ["1.0" , "invalid" , "2.0" ], ["2.0" ]),
691- (
692- "!=2.0.*" ,
693- None ,
694- None ,
695- ["invalid" , "foobar" , "2.0" ],
696- []
697- ),
691+ ("!=2.0.*" , None , None , ["invalid" , "foobar" , "2.0" ], []),
698692 ("!=2.0.*" , None , None , ["1.0" , "invalid" , "2.0.0" ], ["1.0" ]),
699693 # Test that !== ignores prereleases parameter for non-PEP 440 versions
700694 ("!=1.0" , None , True , ["invalid" , "foobar" ], []),
@@ -803,15 +797,34 @@ def test_empty_specifier(self, version):
803797 assert spec .contains (parse (version ))
804798
805799 @pytest .mark .parametrize (
806- "prereleases" ,
807- [None , False , True ],
800+ ("prereleases" , "versions" , "expected" ),
801+ [
802+ # single arbitrary string
803+ (None , ["foobar" ], ["foobar" ]),
804+ (False , ["foobar" ], ["foobar" ]),
805+ (True , ["foobar" ], ["foobar" ]),
806+ # arbitrary string with a stable version present
807+ (None , ["foobar" , "1.0" ], ["foobar" , "1.0" ]),
808+ (False , ["foobar" , "1.0" ], ["foobar" , "1.0" ]),
809+ (True , ["foobar" , "1.0" ], ["foobar" , "1.0" ]),
810+ # arbitrary string with a prerelease only
811+ (None , ["foobar" , "1.0a1" ], ["foobar" , "1.0a1" ]),
812+ (False , ["foobar" , "1.0a1" ], ["foobar" ]),
813+ (True , ["foobar" , "1.0a1" ], ["foobar" , "1.0a1" ]),
814+ ],
808815 )
809- def test_empty_specifier_arbitrary_string (self , prereleases ):
816+ def test_empty_specifier_arbitrary_string (self , prereleases , versions , expected ):
810817 """Test empty SpecifierSet accepts arbitrary strings."""
811818
812819 spec = SpecifierSet ("" , prereleases = prereleases )
820+
821+ # basic behavior preserved
813822 assert spec .contains ("foobar" )
814823
824+ # check filter behavior (no override of prereleases passed to filter)
825+ kwargs = {}
826+ assert list (spec .filter (versions , ** kwargs )) == expected
827+
815828 def test_create_from_specifiers (self ):
816829 spec_strs = [">=1.0" , "!=1.1" , "!=1.2" , "<2.0" ]
817830 specs = [Specifier (s ) for s in spec_strs ]
0 commit comments