How to use add_defaults method in localstack

Best Python code snippet using localstack_python

sdist.py

Source:sdist.py Github

copy

Full Screen

...1310: 1411: class sdist(old_sdist):1512: 1613: def add_defaults (self):1714: old_sdist.add_defaults(self)1815: 1916: dist = self.distribution2017: 2118: if dist.has_data_files():2219: for data in dist.data_files:2320: self.filelist.extend(get_data_files(data))2421: 2522: if dist.has_headers():2623: headers = []2724: for h in dist.headers:2825: if isinstance(h, str): headers.append(h)2926: else: headers.append(h[1])3027: self.filelist.extend(headers)3128: 3229: return3330: 34"""35# Import the stypy library necessary elements36from stypy.type_inference_programs.type_inference_programs_imports import *37# Create the module type store38module_type_store = Context(None, __file__)39# ################# Begin of the type inference program ##################40stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 3, 0))41# 'import sys' statement (line 3)42import sys43import_module(stypy.reporting.localization.Localization(__file__, 3, 0), 'sys', sys, module_type_store)44str_59722 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 4, 3), 'str', 'setuptools')45# Getting the type of 'sys' (line 4)46sys_59723 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 4, 19), 'sys')47# Obtaining the member 'modules' of a type (line 4)48modules_59724 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 4, 19), sys_59723, 'modules')49# Applying the binary operator 'in' (line 4)50result_contains_59725 = python_operator(stypy.reporting.localization.Localization(__file__, 4, 3), 'in', str_59722, modules_59724)51# Testing the type of an if condition (line 4)52if_condition_59726 = is_suitable_condition(stypy.reporting.localization.Localization(__file__, 4, 0), result_contains_59725)53# Assigning a type to the variable 'if_condition_59726' (line 4)54module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 4, 0), 'if_condition_59726', if_condition_59726)55# SSA begins for if statement (line 4)56module_type_store = SSAContext.create_ssa_context(module_type_store, 'if')57stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 5, 4))58# 'from setuptools.command.sdist import old_sdist' statement (line 5)59update_path_to_current_file_folder('C:/Python27/lib/site-packages/numpy/distutils/command/')60import_59727 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 5, 4), 'setuptools.command.sdist')61if (type(import_59727) is not StypyTypeError):62 if (import_59727 != 'pyd_module'):63 __import__(import_59727)64 sys_modules_59728 = sys.modules[import_59727]65 import_from_module(stypy.reporting.localization.Localization(__file__, 5, 4), 'setuptools.command.sdist', sys_modules_59728.module_type_store, module_type_store, ['sdist'])66 nest_module(stypy.reporting.localization.Localization(__file__, 5, 4), __file__, sys_modules_59728, sys_modules_59728.module_type_store, module_type_store)67 else:68 from setuptools.command.sdist import sdist as old_sdist69 import_from_module(stypy.reporting.localization.Localization(__file__, 5, 4), 'setuptools.command.sdist', None, module_type_store, ['sdist'], [old_sdist])70else:71 # Assigning a type to the variable 'setuptools.command.sdist' (line 5)72 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 5, 4), 'setuptools.command.sdist', import_59727)73# Adding an alias74module_type_store.add_alias('old_sdist', 'sdist')75remove_current_file_folder_from_path('C:/Python27/lib/site-packages/numpy/distutils/command/')76# SSA branch for the else part of an if statement (line 4)77module_type_store.open_ssa_branch('else')78stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 7, 4))79# 'from distutils.command.sdist import old_sdist' statement (line 7)80update_path_to_current_file_folder('C:/Python27/lib/site-packages/numpy/distutils/command/')81import_59729 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 7, 4), 'distutils.command.sdist')82if (type(import_59729) is not StypyTypeError):83 if (import_59729 != 'pyd_module'):84 __import__(import_59729)85 sys_modules_59730 = sys.modules[import_59729]86 import_from_module(stypy.reporting.localization.Localization(__file__, 7, 4), 'distutils.command.sdist', sys_modules_59730.module_type_store, module_type_store, ['sdist'])87 nest_module(stypy.reporting.localization.Localization(__file__, 7, 4), __file__, sys_modules_59730, sys_modules_59730.module_type_store, module_type_store)88 else:89 from distutils.command.sdist import sdist as old_sdist90 import_from_module(stypy.reporting.localization.Localization(__file__, 7, 4), 'distutils.command.sdist', None, module_type_store, ['sdist'], [old_sdist])91else:92 # Assigning a type to the variable 'distutils.command.sdist' (line 7)93 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 7, 4), 'distutils.command.sdist', import_59729)94# Adding an alias95module_type_store.add_alias('old_sdist', 'sdist')96remove_current_file_folder_from_path('C:/Python27/lib/site-packages/numpy/distutils/command/')97# SSA join for if statement (line 4)98module_type_store = module_type_store.join_ssa_context()99stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 9, 0))100# 'from numpy.distutils.misc_util import get_data_files' statement (line 9)101update_path_to_current_file_folder('C:/Python27/lib/site-packages/numpy/distutils/command/')102import_59731 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 9, 0), 'numpy.distutils.misc_util')103if (type(import_59731) is not StypyTypeError):104 if (import_59731 != 'pyd_module'):105 __import__(import_59731)106 sys_modules_59732 = sys.modules[import_59731]107 import_from_module(stypy.reporting.localization.Localization(__file__, 9, 0), 'numpy.distutils.misc_util', sys_modules_59732.module_type_store, module_type_store, ['get_data_files'])108 nest_module(stypy.reporting.localization.Localization(__file__, 9, 0), __file__, sys_modules_59732, sys_modules_59732.module_type_store, module_type_store)109 else:110 from numpy.distutils.misc_util import get_data_files111 import_from_module(stypy.reporting.localization.Localization(__file__, 9, 0), 'numpy.distutils.misc_util', None, module_type_store, ['get_data_files'], [get_data_files])112else:113 # Assigning a type to the variable 'numpy.distutils.misc_util' (line 9)114 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 9, 0), 'numpy.distutils.misc_util', import_59731)115remove_current_file_folder_from_path('C:/Python27/lib/site-packages/numpy/distutils/command/')116# Declaration of the 'sdist' class117# Getting the type of 'old_sdist' (line 11)118old_sdist_59733 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 11, 12), 'old_sdist')119class sdist(old_sdist_59733, ):120 @norecursion121 def add_defaults(type_of_self, localization, *varargs, **kwargs):122 global module_type_store123 # Assign values to the parameters with defaults124 defaults = []125 # Create a new context for function 'add_defaults'126 module_type_store = module_type_store.open_function_context('add_defaults', 13, 4, False)127 # Assigning a type to the variable 'self' (line 14)128 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 14, 4), 'self', type_of_self)129 130 # Passed parameters checking function131 sdist.add_defaults.__dict__.__setitem__('stypy_localization', localization)132 sdist.add_defaults.__dict__.__setitem__('stypy_type_of_self', type_of_self)133 sdist.add_defaults.__dict__.__setitem__('stypy_type_store', module_type_store)134 sdist.add_defaults.__dict__.__setitem__('stypy_function_name', 'sdist.add_defaults')135 sdist.add_defaults.__dict__.__setitem__('stypy_param_names_list', [])136 sdist.add_defaults.__dict__.__setitem__('stypy_varargs_param_name', None)137 sdist.add_defaults.__dict__.__setitem__('stypy_kwargs_param_name', None)138 sdist.add_defaults.__dict__.__setitem__('stypy_call_defaults', defaults)139 sdist.add_defaults.__dict__.__setitem__('stypy_call_varargs', varargs)140 sdist.add_defaults.__dict__.__setitem__('stypy_call_kwargs', kwargs)141 sdist.add_defaults.__dict__.__setitem__('stypy_declared_arg_number', 1)142 arguments = process_argument_values(localization, type_of_self, module_type_store, 'sdist.add_defaults', [], None, None, defaults, varargs, kwargs)143 if is_error_type(arguments):144 # Destroy the current context145 module_type_store = module_type_store.close_function_context()146 return arguments147 # Initialize method data148 init_call_information(module_type_store, 'add_defaults', localization, [], arguments)149 150 # Default return type storage variable (SSA)151 # Assigning a type to the variable 'stypy_return_type'152 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)153 154 155 # ################# Begin of 'add_defaults(...)' code ##################156 157 # Call to add_defaults(...): (line 14)158 # Processing the call arguments (line 14)159 # Getting the type of 'self' (line 14)160 self_59736 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 14, 31), 'self', False)161 # Processing the call keyword arguments (line 14)162 kwargs_59737 = {}163 # Getting the type of 'old_sdist' (line 14)164 old_sdist_59734 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 14, 8), 'old_sdist', False)165 # Obtaining the member 'add_defaults' of a type (line 14)166 add_defaults_59735 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 14, 8), old_sdist_59734, 'add_defaults')167 # Calling add_defaults(args, kwargs) (line 14)168 add_defaults_call_result_59738 = invoke(stypy.reporting.localization.Localization(__file__, 14, 8), add_defaults_59735, *[self_59736], **kwargs_59737)169 170 171 # Assigning a Attribute to a Name (line 16):172 # Getting the type of 'self' (line 16)173 self_59739 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 16, 15), 'self')174 # Obtaining the member 'distribution' of a type (line 16)175 distribution_59740 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 16, 15), self_59739, 'distribution')176 # Assigning a type to the variable 'dist' (line 16)177 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 16, 8), 'dist', distribution_59740)178 179 180 # Call to has_data_files(...): (line 18)181 # Processing the call keyword arguments (line 18)182 kwargs_59743 = {}183 # Getting the type of 'dist' (line 18)184 dist_59741 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 18, 11), 'dist', False)185 # Obtaining the member 'has_data_files' of a type (line 18)186 has_data_files_59742 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 18, 11), dist_59741, 'has_data_files')187 # Calling has_data_files(args, kwargs) (line 18)188 has_data_files_call_result_59744 = invoke(stypy.reporting.localization.Localization(__file__, 18, 11), has_data_files_59742, *[], **kwargs_59743)189 190 # Testing the type of an if condition (line 18)191 if_condition_59745 = is_suitable_condition(stypy.reporting.localization.Localization(__file__, 18, 8), has_data_files_call_result_59744)192 # Assigning a type to the variable 'if_condition_59745' (line 18)193 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 18, 8), 'if_condition_59745', if_condition_59745)194 # SSA begins for if statement (line 18)195 module_type_store = SSAContext.create_ssa_context(module_type_store, 'if')196 197 # Getting the type of 'dist' (line 19)198 dist_59746 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 19, 24), 'dist')199 # Obtaining the member 'data_files' of a type (line 19)200 data_files_59747 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 19, 24), dist_59746, 'data_files')201 # Testing the type of a for loop iterable (line 19)202 is_suitable_for_loop_condition(stypy.reporting.localization.Localization(__file__, 19, 12), data_files_59747)203 # Getting the type of the for loop variable (line 19)204 for_loop_var_59748 = get_type_of_for_loop_variable(stypy.reporting.localization.Localization(__file__, 19, 12), data_files_59747)205 # Assigning a type to the variable 'data' (line 19)206 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 19, 12), 'data', for_loop_var_59748)207 # SSA begins for a for statement (line 19)208 module_type_store = SSAContext.create_ssa_context(module_type_store, 'for loop')209 210 # Call to extend(...): (line 20)211 # Processing the call arguments (line 20)212 213 # Call to get_data_files(...): (line 20)214 # Processing the call arguments (line 20)215 # Getting the type of 'data' (line 20)216 data_59753 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 20, 52), 'data', False)217 # Processing the call keyword arguments (line 20)218 kwargs_59754 = {}219 # Getting the type of 'get_data_files' (line 20)220 get_data_files_59752 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 20, 37), 'get_data_files', False)221 # Calling get_data_files(args, kwargs) (line 20)222 get_data_files_call_result_59755 = invoke(stypy.reporting.localization.Localization(__file__, 20, 37), get_data_files_59752, *[data_59753], **kwargs_59754)223 224 # Processing the call keyword arguments (line 20)225 kwargs_59756 = {}226 # Getting the type of 'self' (line 20)227 self_59749 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 20, 16), 'self', False)228 # Obtaining the member 'filelist' of a type (line 20)229 filelist_59750 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 20, 16), self_59749, 'filelist')230 # Obtaining the member 'extend' of a type (line 20)231 extend_59751 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 20, 16), filelist_59750, 'extend')232 # Calling extend(args, kwargs) (line 20)233 extend_call_result_59757 = invoke(stypy.reporting.localization.Localization(__file__, 20, 16), extend_59751, *[get_data_files_call_result_59755], **kwargs_59756)234 235 # SSA join for a for statement236 module_type_store = module_type_store.join_ssa_context()237 238 # SSA join for if statement (line 18)239 module_type_store = module_type_store.join_ssa_context()240 241 242 243 # Call to has_headers(...): (line 22)244 # Processing the call keyword arguments (line 22)245 kwargs_59760 = {}246 # Getting the type of 'dist' (line 22)247 dist_59758 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 22, 11), 'dist', False)248 # Obtaining the member 'has_headers' of a type (line 22)249 has_headers_59759 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 22, 11), dist_59758, 'has_headers')250 # Calling has_headers(args, kwargs) (line 22)251 has_headers_call_result_59761 = invoke(stypy.reporting.localization.Localization(__file__, 22, 11), has_headers_59759, *[], **kwargs_59760)252 253 # Testing the type of an if condition (line 22)254 if_condition_59762 = is_suitable_condition(stypy.reporting.localization.Localization(__file__, 22, 8), has_headers_call_result_59761)255 # Assigning a type to the variable 'if_condition_59762' (line 22)256 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 22, 8), 'if_condition_59762', if_condition_59762)257 # SSA begins for if statement (line 22)258 module_type_store = SSAContext.create_ssa_context(module_type_store, 'if')259 260 # Assigning a List to a Name (line 23):261 262 # Obtaining an instance of the builtin type 'list' (line 23)263 list_59763 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 23, 22), 'list')264 # Adding type elements to the builtin type 'list' instance (line 23)265 266 # Assigning a type to the variable 'headers' (line 23)267 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 23, 12), 'headers', list_59763)268 269 # Getting the type of 'dist' (line 24)270 dist_59764 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 24, 21), 'dist')271 # Obtaining the member 'headers' of a type (line 24)272 headers_59765 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 24, 21), dist_59764, 'headers')273 # Testing the type of a for loop iterable (line 24)274 is_suitable_for_loop_condition(stypy.reporting.localization.Localization(__file__, 24, 12), headers_59765)275 # Getting the type of the for loop variable (line 24)276 for_loop_var_59766 = get_type_of_for_loop_variable(stypy.reporting.localization.Localization(__file__, 24, 12), headers_59765)277 # Assigning a type to the variable 'h' (line 24)278 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 24, 12), 'h', for_loop_var_59766)279 # SSA begins for a for statement (line 24)280 module_type_store = SSAContext.create_ssa_context(module_type_store, 'for loop')281 282 # Type idiom detected: calculating its left and rigth part (line 25)283 # Getting the type of 'str' (line 25)284 str_59767 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 25, 33), 'str')285 # Getting the type of 'h' (line 25)286 h_59768 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 25, 30), 'h')287 288 (may_be_59769, more_types_in_union_59770) = may_be_subtype(str_59767, h_59768)289 if may_be_59769:290 if more_types_in_union_59770:291 # Runtime conditional SSA (line 25)292 module_type_store = SSAContext.create_ssa_context(module_type_store, 'idiom if')293 else:294 module_type_store = module_type_store295 # Assigning a type to the variable 'h' (line 25)296 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 25, 16), 'h', remove_not_subtype_from_union(h_59768, str))297 298 # Call to append(...): (line 25)299 # Processing the call arguments (line 25)300 # Getting the type of 'h' (line 25)301 h_59773 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 25, 54), 'h', False)302 # Processing the call keyword arguments (line 25)303 kwargs_59774 = {}304 # Getting the type of 'headers' (line 25)305 headers_59771 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 25, 39), 'headers', False)306 # Obtaining the member 'append' of a type (line 25)307 append_59772 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 25, 39), headers_59771, 'append')308 # Calling append(args, kwargs) (line 25)309 append_call_result_59775 = invoke(stypy.reporting.localization.Localization(__file__, 25, 39), append_59772, *[h_59773], **kwargs_59774)310 311 if more_types_in_union_59770:312 # Runtime conditional SSA for else branch (line 25)313 module_type_store.open_ssa_branch('idiom else')314 if ((not may_be_59769) or more_types_in_union_59770):315 # Assigning a type to the variable 'h' (line 25)316 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 25, 16), 'h', remove_subtype_from_union(h_59768, str))317 318 # Call to append(...): (line 26)319 # Processing the call arguments (line 26)320 321 # Obtaining the type of the subscript322 int_59778 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 26, 39), 'int')323 # Getting the type of 'h' (line 26)324 h_59779 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 26, 37), 'h', False)325 # Obtaining the member '__getitem__' of a type (line 26)326 getitem___59780 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 26, 37), h_59779, '__getitem__')327 # Calling the subscript (__getitem__) to obtain the elements type (line 26)328 subscript_call_result_59781 = invoke(stypy.reporting.localization.Localization(__file__, 26, 37), getitem___59780, int_59778)329 330 # Processing the call keyword arguments (line 26)331 kwargs_59782 = {}332 # Getting the type of 'headers' (line 26)333 headers_59776 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 26, 22), 'headers', False)334 # Obtaining the member 'append' of a type (line 26)335 append_59777 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 26, 22), headers_59776, 'append')336 # Calling append(args, kwargs) (line 26)337 append_call_result_59783 = invoke(stypy.reporting.localization.Localization(__file__, 26, 22), append_59777, *[subscript_call_result_59781], **kwargs_59782)338 339 if (may_be_59769 and more_types_in_union_59770):340 # SSA join for if statement (line 25)341 module_type_store = module_type_store.join_ssa_context()342 343 # SSA join for a for statement344 module_type_store = module_type_store.join_ssa_context()345 346 347 # Call to extend(...): (line 27)348 # Processing the call arguments (line 27)349 # Getting the type of 'headers' (line 27)350 headers_59787 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 27, 33), 'headers', False)351 # Processing the call keyword arguments (line 27)352 kwargs_59788 = {}353 # Getting the type of 'self' (line 27)354 self_59784 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 27, 12), 'self', False)355 # Obtaining the member 'filelist' of a type (line 27)356 filelist_59785 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 27, 12), self_59784, 'filelist')357 # Obtaining the member 'extend' of a type (line 27)358 extend_59786 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 27, 12), filelist_59785, 'extend')359 # Calling extend(args, kwargs) (line 27)360 extend_call_result_59789 = invoke(stypy.reporting.localization.Localization(__file__, 27, 12), extend_59786, *[headers_59787], **kwargs_59788)361 362 # SSA join for if statement (line 22)363 module_type_store = module_type_store.join_ssa_context()364 365 # Assigning a type to the variable 'stypy_return_type' (line 29)366 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 29, 8), 'stypy_return_type', types.NoneType)367 368 # ################# End of 'add_defaults(...)' code ##################369 # Teardown call information370 teardown_call_information(localization, arguments)371 372 # Storing the return type of function 'add_defaults' in the type store373 # Getting the type of 'stypy_return_type' (line 13)374 stypy_return_type_59790 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 13, 4), 'stypy_return_type')375 module_type_store.store_return_type_of_current_context(stypy_return_type_59790)376 377 # Destroy the current context378 module_type_store = module_type_store.close_function_context()379 380 # Return type of the function 'add_defaults'381 return stypy_return_type_59790382 @norecursion...

Full Screen

Full Screen

gt_argument_tests.py

Source:gt_argument_tests.py Github

copy

Full Screen

1#!/usr/bin/env python2.72#3# Copyright (c) 2012, Regents of the University of California4# All rights reserved.5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions are met:8# * Redistributions of source code must retain the above copyright9# notice, this list of conditions and the following disclaimer.10# * Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13# * Neither the name of the University of California nor the14# names of its contributors may be used to endorse or promote products15# derived from this software without specific prior written permission.16#17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED19# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE20# DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR23# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER24# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,25# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27#28''' Unit tests for command line arguments feature '''29import unittest30import sys31import os32import time33import logging34import sys35from utils.gttestcase import GTTestCase, StreamToLogger36from utils.genetorrent import GeneTorrentInstance, InstanceType37class TestGeneTorrentArguments(GTTestCase):38 """39 Test various features related to GeneTorrent's40 command line argument processing41 """42 create_credential = True43 resourcedir = '-R . '44 def test_short_multiple_modes(self):45 """46 Test multiple mode options to Gene Torrent (-d, -s, -u)47 """48 gt = GeneTorrentInstance(self.resourcedir + "-d xxx -s %s -u xxx" % (os.getcwd()),49 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)50 (sout, serr) = gt.communicate()51 self.assertTrue("unknown option" in serr or "unrecognised option" in serr)52 self.assertEqual(gt.returncode, 9)53 gt = GeneTorrentInstance(self.resourcedir + "-d xxx -s %s" % (os.getcwd()),54 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)55 (sout, serr) = gt.communicate()56 self.assertTrue("unknown option" in serr or "unrecognised option" in serr)57 self.assertEqual(gt.returncode, 9)58 gt = GeneTorrentInstance(self.resourcedir + "-s '%s' -u xxx" % (os.getcwd()),59 instance_type=InstanceType.GT_SERVER, add_defaults=False)60 (sout, serr) = gt.communicate()61 self.assertTrue("unknown option" in serr or "unrecognised option" in serr)62 self.assertEqual(gt.returncode, 9)63 gt = GeneTorrentInstance(self.resourcedir + "-d xxx -u xxx",64 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)65 (sout, serr) = gt.communicate()66 self.assertTrue("unknown option" in serr or "unrecognised option" in serr)67 self.assertEqual(gt.returncode, 9)68 def test_long_multiple_modes(self):69 """70 Test multiple mode options to Gene Torrent (-d, -s, -u)71 """72 gt = GeneTorrentInstance(self.resourcedir + "--download xxx --server %s --upload xxx -c %s" % (os.getcwd(), self.cred_filename),73 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)74 (sout, serr) = gt.communicate()75 self.assertTrue("unknown option" in serr or "unrecognised option" in serr)76 self.assertEqual(gt.returncode, 9)77 gt = GeneTorrentInstance(self.resourcedir + "--download xxx --server %s -c %s" % (os.getcwd(), self.cred_filename),78 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)79 (sout, serr) = gt.communicate()80 self.assertIn("too short", serr)81 self.assertEqual(gt.returncode, 201)82 gt = GeneTorrentInstance(self.resourcedir + "--server %s -q %s --download xxx -c %s" % (os.getcwd(), os.getcwd(), self.cred_filename),83 instance_type=InstanceType.GT_SERVER, add_defaults=False)84 (sout, serr) = gt.communicate()85 self.assertTrue("unknown option" in serr or "unrecognised option" in serr)86 self.assertEqual(gt.returncode, 9)87 gt = GeneTorrentInstance(self.resourcedir + "--download xxx --upload xxx",88 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)89 (sout, serr) = gt.communicate()90 self.assertTrue("unknown option" in serr or "unrecognised option" in serr)91 self.assertEqual(gt.returncode, 9)92 def test_short_upload_options(self):93 """94 Test upload mode options to Gene Torrent (-u)95 """96 gt = GeneTorrentInstance(self.resourcedir + "-u",97 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)98 (sout, serr) = gt.communicate()99 self.assertIn("required", serr)100 self.assertIn("missing", serr)101 self.assertIn("upload", serr)102 self.assertEqual(gt.returncode, 9)103 gt = GeneTorrentInstance(self.resourcedir + "-u xxx",104 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)105 (sout, serr) = gt.communicate()106 self.assertIn("manifest file not found", serr)107 self.assertEqual(gt.returncode, 9)108 gt = GeneTorrentInstance(self.resourcedir + "-u %s" % (self.cred_filename),109 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)110 (sout, serr) = gt.communicate()111 self.assertIn("include a credential file", serr)112 self.assertEqual(gt.returncode, 9)113 gt = GeneTorrentInstance(self.resourcedir + "-u %s -c %s" % (self.cred_filename, self.cred_filename),114 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)115 (sout, serr) = gt.communicate()116 self.assertIn("error attempting to process the file", serr)117 self.assertEqual(gt.returncode, 97)118 gt = GeneTorrentInstance(self.resourcedir + "-u %s -c %s -p /does/not/exit" % (self.cred_filename, self.cred_filename),119 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)120 (sout, serr) = gt.communicate()121 self.assertIn("unable to opening directory", serr)122 self.assertEqual(gt.returncode, 9)123 def test_long_upload_options(self):124 """125 Test upload mode options to Gene Torrent (-u)126 """127 gt = GeneTorrentInstance(self.resourcedir + "--upload",128 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)129 (sout, serr) = gt.communicate()130 self.assertIn("required", serr)131 self.assertIn("missing", serr)132 self.assertIn("upload", serr)133 self.assertEqual(gt.returncode, 9)134 gt = GeneTorrentInstance(self.resourcedir + "--upload xxx",135 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)136 (sout, serr) = gt.communicate()137 self.assertIn("manifest file not found", serr)138 self.assertEqual(gt.returncode, 9)139 gt = GeneTorrentInstance(self.resourcedir + "--upload %s" % (self.cred_filename),140 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)141 (sout, serr) = gt.communicate()142 self.assertIn("include a credential file", serr)143 self.assertEqual(gt.returncode, 9)144 gt = GeneTorrentInstance(self.resourcedir + "--upload %s --credential-file %s" % (self.cred_filename, self.cred_filename),145 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)146 (sout, serr) = gt.communicate()147 self.assertIn("error attempting to process the file", serr)148 self.assertEqual(gt.returncode, 97)149 gt = GeneTorrentInstance(self.resourcedir + "--upload %s --credential-file %s --path /does/not/exit" % (self.cred_filename, self.cred_filename),150 instance_type=InstanceType.GT_UPLOAD, add_defaults=False)151 (sout, serr) = gt.communicate()152 self.assertIn("unable to opening directory", serr)153 self.assertEqual(gt.returncode, 9)154 def test_short_download_options(self):155 """156 Test download mode options to Gene Torrent (-d)157 """158 gt = GeneTorrentInstance(self.resourcedir + "-d",159 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)160 (sout, serr) = gt.communicate()161 self.assertIn("required", serr)162 self.assertIn("missing", serr)163 self.assertIn("download", serr)164 self.assertEqual(gt.returncode, 9)165 gt = GeneTorrentInstance(self.resourcedir + "-d xxx",166 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)167 (sout, serr) = gt.communicate()168 self.assertIn("include a credential file", serr)169 self.assertEqual(gt.returncode, 9)170 gt = GeneTorrentInstance(self.resourcedir + "-d xxx -c /file/does/not/exist",171 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)172 (sout, serr) = gt.communicate()173 self.assertIn("credentials file not found", serr)174 self.assertEqual(gt.returncode, 55)175 gt = GeneTorrentInstance(self.resourcedir + "-d xxx -c %s" % (self.cred_filename),176 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)177 (sout, serr) = gt.communicate()178 self.assertIn("'xxx' is too short", serr)179 self.assertEqual(gt.returncode, 201)180 gt = GeneTorrentInstance(self.resourcedir + "-c %s -p /path/does/not/exist -d xxx" % (self.cred_filename),181 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)182 (sout, serr) = gt.communicate()183 self.assertIn("unable to opening directory", serr)184 self.assertEqual(gt.returncode, 9)185 def test_long_download_options(self):186 """187 Test download mode options to Gene Torrent (-d)188 """189 gt = GeneTorrentInstance(self.resourcedir + "--download",190 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)191 (sout, serr) = gt.communicate()192 self.assertIn("required", serr)193 self.assertIn("missing", serr)194 self.assertIn("download", serr)195 self.assertEqual(gt.returncode, 9)196 gt = GeneTorrentInstance(self.resourcedir + "--download xxx",197 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)198 (sout, serr) = gt.communicate()199 self.assertIn("include a credential file", serr)200 self.assertEqual(gt.returncode, 9)201 gt = GeneTorrentInstance(self.resourcedir + "--download xxx -c /file/does/not/exist",202 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)203 (sout, serr) = gt.communicate()204 self.assertIn("credentials file not found", serr)205 self.assertEqual(gt.returncode, 55)206 gt = GeneTorrentInstance(self.resourcedir + "--download xxx --credential-file %s" % (self.cred_filename),207 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)208 (sout, serr) = gt.communicate()209 self.assertIn("'xxx' is too short", serr)210 self.assertEqual(gt.returncode, 201)211 gt = GeneTorrentInstance(self.resourcedir + "--credential-file %s --path /path/does/not/exist --download xxx" % (self.cred_filename),212 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)213 (sout, serr) = gt.communicate()214 self.assertIn("unable to opening directory", serr)215 self.assertEqual(gt.returncode, 9)216 gt = GeneTorrentInstance(self.resourcedir + "--credential-file %s --download xxx --security-api=aaa" % (self.cred_filename),217 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)218 (sout, serr) = gt.communicate()219 self.assertIn("Invalid URI for '--security-api", serr)220 self.assertEqual(gt.returncode, 9)221 gt = GeneTorrentInstance(self.resourcedir + "--download xxx --max-children=0",222 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)223 (sout, serr) = gt.communicate()224 self.assertIn("must be greater than 0", serr)225 self.assertEqual(gt.returncode, 9)226 def test_usage_and_invalid_options(self):227 """228 Test usage and invalid options for GeneTorrent229 """230 gt = GeneTorrentInstance(self.resourcedir + "--help",231 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)232 (sout, serr) = gt.communicate()233 self.assertIn("Usage", sout)234 self.assertEqual(gt.returncode, 0)235 gt = GeneTorrentInstance(self.resourcedir + "--this-option-does-not-exist",236 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)237 (sout, serr) = gt.communicate()238 self.assertIn("this-option-does-not-exist", serr)239 self.assertEqual(gt.returncode, 9)240 gt = GeneTorrentInstance(self.resourcedir + "-z",241 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)242 (sout, serr) = gt.communicate()243 self.assertIn("option", serr)244 self.assertIn("-z", serr)245 self.assertEqual(gt.returncode, 9)246 gt = GeneTorrentInstance(self.resourcedir + "-c foo --credential-file=bar",247 instance_type=InstanceType.GT_DOWNLOAD, add_defaults=False)248 (sout, serr) = gt.communicate()249 result = "multiple occurrences" in serr or "specified more than once" \250 in serr251 self.assertTrue(result)252 self.assertEqual(gt.returncode, 9)253if __name__ == '__main__':254 sys.stdout = StreamToLogger(logging.getLogger('stdout'), logging.INFO)255 sys.stderr = StreamToLogger(logging.getLogger('stderr'), logging.WARN)256 suite = unittest.TestLoader().loadTestsFromTestCase(TestGeneTorrentArguments)257 result = unittest.TextTestRunner(stream=sys.stderr, verbosity=2).run(suite)258 if not result.wasSuccessful():...

Full Screen

Full Screen

decorator_syntax_test.py

Source:decorator_syntax_test.py Github

copy

Full Screen

...15print(f"5 + 7 = {add(5, 7)}")16print(f"2 + 3 = {add(a=2, b=3)}")17print(f"2 + 3 = {add(2, b=3)}")18print(f"2 + 3 = {add(2, 3)}")19def add_defaults(a=None, b=None):20 if a and b:21 return a + b22 else:23 return None24print("=== Second example ===")25print(f"2 + 3 = {add_defaults(a=2, b=3)}")26print(f"2 + 3 = {add_defaults(2, b=3)}")27print(f"2 + 3 = {add_defaults(2, 3)}")28print(f"None + None = {add_defaults(None, None)}")29print(f"default + default = {add_defaults()}")30print(f"2 + default = {add_defaults(2)}")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful