<s> from pypy . config . config import * <EOL> from pypy . config . makerestdoc import make_cmdline_overview <EOL> from py . __ . misc . rest import process as restcheck <EOL> tempdir = py . test . ensuretemp ( '<STR_LIT>' ) <EOL> try : <EOL> import docutils <EOL> except ImportError : <EOL> py . test . skip ( "<STR_LIT>" ) <EOL> def checkrest ( rest , filename ) : <EOL> tempfile = tempdir . join ( filename ) <EOL> tempfile . write ( rest ) <EOL> restcheck ( tempfile ) <EOL> return tempfile . new ( ext = '<STR_LIT>' ) . read ( ) <EOL> def generate_html ( descr ) : <EOL> config = Config ( descr ) <EOL> txt = descr . make_rest_doc ( ) . text ( ) <EOL> result = { "<STR_LIT>" : checkrest ( txt , descr . _name + "<STR_LIT>" ) } <EOL> for path in config . getpaths ( include_groups = True ) : <EOL> subconf , step = config . _cfgimpl_get_home_by_path ( path ) <EOL> fullpath = ( descr . _name + "<STR_LIT:.>" + path ) <EOL> prefix = fullpath . rsplit ( "<STR_LIT:.>" , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> txt = getattr ( subconf . _cfgimpl_descr , step ) . make_rest_doc ( <EOL> prefix ) . text ( ) <EOL> result [ path ] = checkrest ( txt , fullpath + "<STR_LIT>" ) <EOL> return result <EOL> def test_simple ( ) : <EOL> descr = OptionDescription ( "<STR_LIT:foo>" , "<STR_LIT>" , [ <EOL> ChoiceOption ( "<STR_LIT:bar>" , "<STR_LIT>" , [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" ] ) , <EOL> OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT:d>" , "<STR_LIT:f>" ] ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False , <EOL> cmdline = "<STR_LIT>" ) <EOL> ] ) , <EOL> StrOption ( "<STR_LIT:str>" , "<STR_LIT>" , default = "<STR_LIT>" ) , <EOL> IntOption ( "<STR_LIT:int>" , "<STR_LIT>" , default = <NUM_LIT> ) , <EOL> FloatOption ( "<STR_LIT:float>" , "<STR_LIT>" , default = py . std . math . pi ) , <EOL> ArbitraryOption ( "<STR_LIT>" , "<STR_LIT>" , defaultfactory = int ) , <EOL> ] ) <EOL> generate_html ( descr ) <EOL> def test_choice_requires ( ) : <EOL> descr = OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False ) , <EOL> ChoiceOption ( "<STR_LIT:bar>" , "<STR_LIT>" , [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" ] , <EOL> default = "<STR_LIT:a>" , <EOL> requires = { "<STR_LIT:a>" : [ ( "<STR_LIT>" , True ) , <EOL> ( "<STR_LIT>" , False ) ] , <EOL> "<STR_LIT:b>" : [ ( "<STR_LIT>" , False ) ] } ) <EOL> ] ) <EOL> generate_html ( descr ) <EOL> def test_bool_requires_suggests ( ) : <EOL> descr = OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False , <EOL> suggests = [ ( "<STR_LIT>" , True ) ] ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False , <EOL> requires = [ ( "<STR_LIT>" , "<STR_LIT:c>" ) , ( "<STR_LIT>" , True ) ] ) , <EOL> ChoiceOption ( "<STR_LIT:bar>" , "<STR_LIT>" , [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" ] , <EOL> default = "<STR_LIT:a>" ) ] ) <EOL> result = generate_html ( descr ) <EOL> assert "<STR_LIT>" in result [ "<STR_LIT>" ] <EOL> def test_cmdline_overview ( ) : <EOL> descr = OptionDescription ( "<STR_LIT:foo>" , "<STR_LIT>" , [ <EOL> ChoiceOption ( "<STR_LIT:bar>" , "<STR_LIT>" , [ "<STR_LIT:a>" , "<STR_LIT:b>" , "<STR_LIT:c>" ] ) , <EOL> OptionDescription ( "<STR_LIT>" , "<STR_LIT>" , [ <EOL> ChoiceOption ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT:d>" , "<STR_LIT:f>" ] ) , <EOL> BoolOption ( "<STR_LIT>" , "<STR_LIT>" , default = False , <EOL> cmdline = "<STR_LIT>" ) <EOL> ] ) , <EOL> StrOption ( "<STR_LIT:str>" , "<STR_LIT>" , default = "<STR_LIT>" ) , <EOL> IntOption ( "<STR_LIT:int>" , "<STR_LIT>" , default = <NUM_LIT> ) , <EOL> FloatOption ( "<STR_LIT:float>" , "<STR_LIT>" , default = py . std . math . pi ) , <EOL> ArbitraryOption ( "<STR_LIT>" , "<STR_LIT>" , defaultfactory = int ) , <EOL> ] ) <EOL> generate_html ( descr ) <EOL> c = make_cmdline_overview ( descr ) <EOL> checkrest ( c . text ( ) , "<STR_LIT>" ) </s>
