<s> from spec import Spec , eq_ , skip , ok_ , raises <EOL> from invoke . parser import Argument <EOL> class Argument_ ( Spec ) : <EOL> class init : <EOL> "<STR_LIT>" <EOL> def may_take_names_list ( self ) : <EOL> names = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> a = Argument ( names = names ) <EOL> for name in names : <EOL> assert name in a . names <EOL> def may_take_name_arg ( self ) : <EOL> assert '<STR_LIT>' in Argument ( name = '<STR_LIT>' ) . names <EOL> @ raises ( TypeError ) <EOL> def must_get_at_least_one_name ( self ) : <EOL> Argument ( ) <EOL> def default_arg_is_name_not_names ( self ) : <EOL> assert '<STR_LIT:b>' in Argument ( '<STR_LIT:b>' ) . names <EOL> def can_declare_positional ( self ) : <EOL> eq_ ( Argument ( name = '<STR_LIT:foo>' , positional = True ) . positional , True ) <EOL> def positional_is_False_by_default ( self ) : <EOL> eq_ ( Argument ( name = '<STR_LIT:foo>' ) . positional , False ) <EOL> def can_set_attr_name_to_control_name_attr ( self ) : <EOL> a = Argument ( '<STR_LIT:foo>' , attr_name = '<STR_LIT:bar>' ) <EOL> eq_ ( a . name , '<STR_LIT:bar>' ) <EOL> class string : <EOL> "<STR_LIT>" <EOL> def shows_useful_info ( self ) : <EOL> eq_ ( <EOL> str ( Argument ( names = ( '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' ) ) ) , <EOL> "<STR_LIT>" . format ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> ) <EOL> def does_not_show_nickname_parens_if_no_nicknames ( self ) : <EOL> eq_ ( <EOL> str ( Argument ( '<STR_LIT:name>' ) ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> def shows_positionalness ( self ) : <EOL> eq_ ( <EOL> str ( Argument ( '<STR_LIT:name>' , positional = True ) ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> class repr : <EOL> "<STR_LIT>" <EOL> def just_aliases_dunder_str ( self ) : <EOL> a = Argument ( names = ( '<STR_LIT:name>' , '<STR_LIT>' ) ) <EOL> eq_ ( str ( a ) , repr ( a ) ) <EOL> class kind_kwarg : <EOL> "<STR_LIT>" <EOL> def is_optional ( self ) : <EOL> Argument ( name = '<STR_LIT:a>' ) <EOL> Argument ( name = '<STR_LIT:b>' , kind = int ) <EOL> def defaults_to_str ( self ) : <EOL> eq_ ( Argument ( '<STR_LIT:a>' ) . kind , str ) <EOL> def non_bool_implies_value_needed ( self ) : <EOL> assert Argument ( name = '<STR_LIT:a>' , kind = int ) . takes_value <EOL> def bool_implies_no_value_needed ( self ) : <EOL> assert not Argument ( name = '<STR_LIT:a>' , kind = bool ) . takes_value <EOL> def bool_implies_default_False_not_None ( self ) : <EOL> skip ( ) <EOL> @ raises ( ValueError ) <EOL> def may_validate_on_set ( self ) : <EOL> Argument ( '<STR_LIT:a>' , kind = int ) . value = '<STR_LIT>' <EOL> class names : <EOL> def returns_tuple_of_all_names ( self ) : <EOL> eq_ ( Argument ( names = ( '<STR_LIT>' , '<STR_LIT>' ) ) . names , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> eq_ ( Argument ( name = '<STR_LIT>' ) . names , ( '<STR_LIT>' , ) ) <EOL> def is_normalized_to_a_tuple ( self ) : <EOL> ok_ ( isinstance ( Argument ( names = ( '<STR_LIT:a>' , '<STR_LIT:b>' ) ) . names , tuple ) ) <EOL> class name : <EOL> def returns_first_name ( self ) : <EOL> eq_ ( Argument ( names = ( '<STR_LIT:a>' , '<STR_LIT:b>' ) ) . name , '<STR_LIT:a>' ) <EOL> class nicknames : <EOL> def returns_rest_of_names ( self ) : <EOL> eq_ ( Argument ( names = ( '<STR_LIT:a>' , '<STR_LIT:b>' ) ) . nicknames , ( '<STR_LIT:b>' , ) ) <EOL> class takes_value : <EOL> def True_by_default ( self ) : <EOL> assert Argument ( name = '<STR_LIT:a>' ) . takes_value <EOL> def False_if_kind_is_bool ( self ) : <EOL> assert not Argument ( name = '<STR_LIT>' , kind = bool ) . takes_value <EOL> class value_set : <EOL> "<STR_LIT>" <EOL> def available_as_dot_raw_value ( self ) : <EOL> "<STR_LIT>" <EOL> a = Argument ( '<STR_LIT:a>' ) <EOL> a . value = '<STR_LIT:foo>' <EOL> eq_ ( a . raw_value , '<STR_LIT:foo>' ) <EOL> def untransformed_appears_as_dot_value ( self ) : <EOL> "<STR_LIT>" <EOL> a = Argument ( '<STR_LIT:a>' , kind = str ) <EOL> a . value = '<STR_LIT:foo>' <EOL> eq_ ( a . value , '<STR_LIT:foo>' ) <EOL> def transformed_appears_as_dot_value_with_original_as_raw_value ( self ) : <EOL> "<STR_LIT>" <EOL> a = Argument ( '<STR_LIT:a>' , kind = int ) <EOL> a . value = '<STR_LIT:5>' <EOL> eq_ ( a . value , <NUM_LIT:5> ) <EOL> eq_ ( a . raw_value , '<STR_LIT:5>' ) <EOL> class value : <EOL> def returns_default_if_not_set ( self ) : <EOL> a = Argument ( '<STR_LIT:a>' , default = <NUM_LIT> ) <EOL> eq_ ( a . value , <NUM_LIT> ) <EOL> class raw_value : <EOL> def is_None_when_no_value_was_actually_seen ( self ) : <EOL> a = Argument ( '<STR_LIT:a>' , kind = int ) <EOL> eq_ ( a . raw_value , None ) <EOL> class set_value : <EOL> def casts_by_default ( self ) : <EOL> a = Argument ( '<STR_LIT:a>' , kind = int ) <EOL> a . set_value ( '<STR_LIT:5>' ) <EOL> eq_ ( a . value , <NUM_LIT:5> ) <EOL> def allows_setting_value_without_casting ( self ) : <EOL> a = Argument ( '<STR_LIT:a>' , kind = int ) <EOL> a . set_value ( '<STR_LIT:5>' , cast = False ) <EOL> eq_ ( a . value , '<STR_LIT:5>' ) </s>
