<s> from contextlib import contextmanager <EOL> from optparse import OptionParser <EOL> from pex . bin . pex import configure_clp , configure_clp_pex_resolution <EOL> from pex . fetcher import PyPIFetcher <EOL> from pex . package import SourcePackage , WheelPackage <EOL> from pex . resolver_options import ResolverOptionsBuilder <EOL> from pex . sorter import Sorter <EOL> @ contextmanager <EOL> def parser_pair ( ) : <EOL> builder = ResolverOptionsBuilder ( ) <EOL> parser = OptionParser ( ) <EOL> yield builder , parser <EOL> def test_clp_no_pypi_option ( ) : <EOL> with parser_pair ( ) as ( builder , parser ) : <EOL> configure_clp_pex_resolution ( parser , builder ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:1> <EOL> options , _ = parser . parse_args ( args = [ '<STR_LIT>' ] ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:0> , '<STR_LIT>' <EOL> assert options . repos == builder . _fetchers <EOL> def test_clp_pypi_option_duplicate ( ) : <EOL> with parser_pair ( ) as ( builder , parser ) : <EOL> configure_clp_pex_resolution ( parser , builder ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:1> <EOL> options , _ = parser . parse_args ( args = [ '<STR_LIT>' ] ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:1> <EOL> assert options . repos == builder . _fetchers <EOL> def test_clp_repo_option ( ) : <EOL> with parser_pair ( ) as ( builder , parser ) : <EOL> configure_clp_pex_resolution ( parser , builder ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:1> <EOL> options , _ = parser . parse_args ( args = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:2> <EOL> assert builder . _fetchers == options . repos <EOL> def test_clp_index_option ( ) : <EOL> with parser_pair ( ) as ( builder , parser ) : <EOL> configure_clp_pex_resolution ( parser , builder ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:1> <EOL> options , _ = parser . parse_args ( args = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> assert len ( builder . _fetchers ) == <NUM_LIT:2> <EOL> assert builder . _fetchers == options . repos <EOL> assert builder . _fetchers [ <NUM_LIT:1> ] == PyPIFetcher ( '<STR_LIT>' ) <EOL> def test_clp_build_precedence ( ) : <EOL> with parser_pair ( ) as ( builder , parser ) : <EOL> configure_clp_pex_resolution ( parser , builder ) <EOL> assert builder . _precedence == Sorter . DEFAULT_PACKAGE_PRECEDENCE <EOL> parser . parse_args ( args = [ '<STR_LIT>' ] ) <EOL> assert SourcePackage not in builder . _precedence <EOL> parser . parse_args ( args = [ '<STR_LIT>' ] ) <EOL> assert SourcePackage in builder . _precedence <EOL> options , _ = parser . parse_args ( args = [ '<STR_LIT>' ] ) <EOL> assert WheelPackage not in builder . _precedence <EOL> assert not options . use_wheel <EOL> options , _ = parser . parse_args ( args = [ '<STR_LIT>' ] ) <EOL> assert WheelPackage in builder . _precedence <EOL> assert options . use_wheel <EOL> def test_clp_requirements_txt ( ) : <EOL> parser , builder = configure_clp ( ) <EOL> options , _ = parser . parse_args ( args = '<STR_LIT>' . split ( ) ) <EOL> assert options . requirement_files == [ '<STR_LIT>' , '<STR_LIT>' ] </s>
