<s> import unittest <EOL> from depsolver . errors import DepSolverError <EOL> from depsolver . requirement import Requirement , RequirementParser <EOL> from depsolver . requirement_parser import Any , Equal , GEQ , LEQ <EOL> from depsolver . version import SemanticVersion <EOL> V = SemanticVersion . from_string <EOL> class TestRequirementParser ( unittest . TestCase ) : <EOL> def test_simple ( self ) : <EOL> parser = RequirementParser ( ) <EOL> r_requirements = [ Requirement ( "<STR_LIT>" , [ GEQ ( "<STR_LIT>" ) ] ) ] <EOL> requirements = parser . parse ( "<STR_LIT>" ) <EOL> self . assertEqual ( r_requirements , list ( requirements ) ) <EOL> r_requirements = [ Requirement ( "<STR_LIT>" , [ GEQ ( "<STR_LIT>" ) , <EOL> LEQ ( "<STR_LIT>" ) ] ) ] <EOL> requirements = parser . parse ( "<STR_LIT>" ) <EOL> self . assertEqual ( r_requirements , list ( requirements ) ) <EOL> r_requirements = [ Requirement ( "<STR_LIT>" , [ Equal ( "<STR_LIT>" ) ] ) ] <EOL> requirements = parser . parse ( "<STR_LIT>" ) <EOL> self . assertEqual ( r_requirements , list ( requirements ) ) <EOL> r_requirements = [ Requirement ( "<STR_LIT>" , [ Equal ( "<STR_LIT>" ) , <EOL> Equal ( "<STR_LIT>" ) ] ) ] <EOL> requirements = parser . parse ( "<STR_LIT>" ) <EOL> self . assertEqual ( r_requirements , list ( requirements ) ) <EOL> self . assertTrue ( requirements [ <NUM_LIT:0> ] . _cannot_match ) <EOL> r_requirements = [ Requirement ( "<STR_LIT>" , [ Any ( ) ] ) ] <EOL> requirements = parser . parse ( "<STR_LIT>" ) <EOL> self . assertEqual ( r_requirements , list ( requirements ) ) <EOL> def test_repr ( self ) : <EOL> parser = RequirementParser ( ) <EOL> requirement_string = "<STR_LIT>" <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( repr ( numpy_requirement ) , requirement_string ) <EOL> requirement_string = "<STR_LIT>" <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( repr ( numpy_requirement ) , "<STR_LIT>" ) <EOL> requirement_string = "<STR_LIT>" <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( repr ( numpy_requirement ) , "<STR_LIT>" ) <EOL> requirement_string = "<STR_LIT>" <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( repr ( numpy_requirement ) , "<STR_LIT>" ) <EOL> requirement_string = "<STR_LIT>" <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( repr ( numpy_requirement ) , "<STR_LIT>" ) <EOL> requirement_string = "<STR_LIT>" <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( repr ( numpy_requirement ) , "<STR_LIT>" ) <EOL> requirement_string = "<STR_LIT>" <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( repr ( numpy_requirement ) , "<STR_LIT>" ) <EOL> def test_from_string ( self ) : <EOL> requirement_string = "<STR_LIT>" <EOL> parser = RequirementParser ( ) <EOL> numpy_requirement = list ( parser . parse ( requirement_string ) ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( numpy_requirement , Requirement . from_string ( requirement_string ) ) <EOL> self . assertRaises ( DepSolverError , <EOL> lambda : Requirement . from_string ( "<STR_LIT>" ) ) <EOL> def test_matches_simple ( self ) : <EOL> R = Requirement . from_string <EOL> numpy_requirement = R ( "<STR_LIT>" ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> numpy_requirement = R ( "<STR_LIT>" ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> def test_match_strict ( self ) : <EOL> R = Requirement . from_string <EOL> numpy_requirement = R ( "<STR_LIT>" ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> def test_composite ( self ) : <EOL> R = Requirement . from_string <EOL> numpy_requirement = R ( "<STR_LIT>" ) <EOL> r_numpy_requirement = R ( "<STR_LIT>" ) <EOL> self . assertEqual ( numpy_requirement , r_numpy_requirement ) <EOL> def test_matches_nomatch ( self ) : <EOL> R = Requirement . from_string <EOL> numpy_requirement = R ( "<STR_LIT>" ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> def test_matches_strict ( self ) : <EOL> R = Requirement . from_string <EOL> numpy_requirement = R ( "<STR_LIT>" ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertTrue ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> self . assertFalse ( numpy_requirement . matches ( R ( "<STR_LIT>" ) ) ) <EOL> def test_from_package_string ( self ) : <EOL> R = Requirement . from_string <EOL> r_requirement = R ( "<STR_LIT>" ) <EOL> requirement = Requirement . from_package_string ( "<STR_LIT>" ) <EOL> self . assertEqual ( requirement , r_requirement ) </s>
