Best Python code snippet using avocado_python
test_bdist_msi.py
Source:test_bdist_msi.py  
...129: class BDistMSITestCase(support.TempdirManager,1310:                        support.LoggingSilencer,1411:                        unittest.TestCase):1512: 1613:     def test_minimal(self):1714:         # minimal test XXX need more tests1815:         from distutils.command.bdist_msi import bdist_msi1916:         project_dir, dist = self.create_dist()2017:         cmd = bdist_msi(dist)2118:         cmd.ensure_finalized()2219: 2320: 2421: def test_suite():2522:     return unittest.makeSuite(BDistMSITestCase)2623: 2724: if __name__ == '__main__':2825:     run_unittest(test_suite())2926: 30"""31# Import the stypy library necessary elements32from stypy.type_inference_programs.type_inference_programs_imports import *33# Create the module type store34module_type_store = Context(None, __file__)35# ################# Begin of the type inference program ##################36str_30407 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 1, 0), 'str', 'Tests for distutils.command.bdist_msi.')37stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 2, 0))38# 'import sys' statement (line 2)39import sys40import_module(stypy.reporting.localization.Localization(__file__, 2, 0), 'sys', sys, module_type_store)41stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 3, 0))42# 'import unittest' statement (line 3)43import unittest44import_module(stypy.reporting.localization.Localization(__file__, 3, 0), 'unittest', unittest, module_type_store)45stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 4, 0))46# 'from test.test_support import run_unittest' statement (line 4)47update_path_to_current_file_folder('C:/Python27/lib/distutils/tests/')48import_30408 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 4, 0), 'test.test_support')49if (type(import_30408) is not StypyTypeError):50    if (import_30408 != 'pyd_module'):51        __import__(import_30408)52        sys_modules_30409 = sys.modules[import_30408]53        import_from_module(stypy.reporting.localization.Localization(__file__, 4, 0), 'test.test_support', sys_modules_30409.module_type_store, module_type_store, ['run_unittest'])54        nest_module(stypy.reporting.localization.Localization(__file__, 4, 0), __file__, sys_modules_30409, sys_modules_30409.module_type_store, module_type_store)55    else:56        from test.test_support import run_unittest57        import_from_module(stypy.reporting.localization.Localization(__file__, 4, 0), 'test.test_support', None, module_type_store, ['run_unittest'], [run_unittest])58else:59    # Assigning a type to the variable 'test.test_support' (line 4)60    module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 4, 0), 'test.test_support', import_30408)61remove_current_file_folder_from_path('C:/Python27/lib/distutils/tests/')62stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 5, 0))63# 'from distutils.tests import support' statement (line 5)64update_path_to_current_file_folder('C:/Python27/lib/distutils/tests/')65import_30410 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 5, 0), 'distutils.tests')66if (type(import_30410) is not StypyTypeError):67    if (import_30410 != 'pyd_module'):68        __import__(import_30410)69        sys_modules_30411 = sys.modules[import_30410]70        import_from_module(stypy.reporting.localization.Localization(__file__, 5, 0), 'distutils.tests', sys_modules_30411.module_type_store, module_type_store, ['support'])71        nest_module(stypy.reporting.localization.Localization(__file__, 5, 0), __file__, sys_modules_30411, sys_modules_30411.module_type_store, module_type_store)72    else:73        from distutils.tests import support74        import_from_module(stypy.reporting.localization.Localization(__file__, 5, 0), 'distutils.tests', None, module_type_store, ['support'], [support])75else:76    # Assigning a type to the variable 'distutils.tests' (line 5)77    module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 5, 0), 'distutils.tests', import_30410)78remove_current_file_folder_from_path('C:/Python27/lib/distutils/tests/')79# Declaration of the 'BDistMSITestCase' class80# Getting the type of 'support' (line 9)81support_30412 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 9, 23), 'support')82# Obtaining the member 'TempdirManager' of a type (line 9)83TempdirManager_30413 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 9, 23), support_30412, 'TempdirManager')84# Getting the type of 'support' (line 10)85support_30414 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 10, 23), 'support')86# Obtaining the member 'LoggingSilencer' of a type (line 10)87LoggingSilencer_30415 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 10, 23), support_30414, 'LoggingSilencer')88# Getting the type of 'unittest' (line 11)89unittest_30416 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 11, 23), 'unittest')90# Obtaining the member 'TestCase' of a type (line 11)91TestCase_30417 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 11, 23), unittest_30416, 'TestCase')92class BDistMSITestCase(TempdirManager_30413, LoggingSilencer_30415, TestCase_30417, ):93    @norecursion94    def test_minimal(type_of_self, localization, *varargs, **kwargs):95        global module_type_store96        # Assign values to the parameters with defaults97        defaults = []98        # Create a new context for function 'test_minimal'99        module_type_store = module_type_store.open_function_context('test_minimal', 13, 4, False)100        # Assigning a type to the variable 'self' (line 14)101        module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 14, 4), 'self', type_of_self)102        103        # Passed parameters checking function104        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_localization', localization)105        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_type_of_self', type_of_self)106        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_type_store', module_type_store)107        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_function_name', 'BDistMSITestCase.test_minimal')108        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_param_names_list', [])109        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_varargs_param_name', None)110        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_kwargs_param_name', None)111        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_call_defaults', defaults)112        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_call_varargs', varargs)113        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_call_kwargs', kwargs)114        BDistMSITestCase.test_minimal.__dict__.__setitem__('stypy_declared_arg_number', 1)115        arguments = process_argument_values(localization, type_of_self, module_type_store, 'BDistMSITestCase.test_minimal', [], None, None, defaults, varargs, kwargs)116        if is_error_type(arguments):117            # Destroy the current context118            module_type_store = module_type_store.close_function_context()119            return arguments120        # Initialize method data121        init_call_information(module_type_store, 'test_minimal', localization, [], arguments)122        123        # Default return type storage variable (SSA)124        # Assigning a type to the variable 'stypy_return_type'125        module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)126        127        128        # ################# Begin of 'test_minimal(...)' code ##################129        stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 15, 8))130        131        # 'from distutils.command.bdist_msi import bdist_msi' statement (line 15)132        update_path_to_current_file_folder('C:/Python27/lib/distutils/tests/')133        import_30418 = generate_type_inference_code_for_module(stypy.reporting.localization.Localization(__file__, 15, 8), 'distutils.command.bdist_msi')134        if (type(import_30418) is not StypyTypeError):135            if (import_30418 != 'pyd_module'):136                __import__(import_30418)137                sys_modules_30419 = sys.modules[import_30418]138                import_from_module(stypy.reporting.localization.Localization(__file__, 15, 8), 'distutils.command.bdist_msi', sys_modules_30419.module_type_store, module_type_store, ['bdist_msi'])139                nest_module(stypy.reporting.localization.Localization(__file__, 15, 8), __file__, sys_modules_30419, sys_modules_30419.module_type_store, module_type_store)140            else:141                from distutils.command.bdist_msi import bdist_msi142                import_from_module(stypy.reporting.localization.Localization(__file__, 15, 8), 'distutils.command.bdist_msi', None, module_type_store, ['bdist_msi'], [bdist_msi])143        else:144            # Assigning a type to the variable 'distutils.command.bdist_msi' (line 15)145            module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 15, 8), 'distutils.command.bdist_msi', import_30418)146        remove_current_file_folder_from_path('C:/Python27/lib/distutils/tests/')147        148        149        # Assigning a Call to a Tuple (line 16):150        151        # Assigning a Subscript to a Name (line 16):152        153        # Obtaining the type of the subscript154        int_30420 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 16, 8), 'int')155        156        # Call to create_dist(...): (line 16)157        # Processing the call keyword arguments (line 16)158        kwargs_30423 = {}159        # Getting the type of 'self' (line 16)160        self_30421 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 16, 28), 'self', False)161        # Obtaining the member 'create_dist' of a type (line 16)162        create_dist_30422 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 16, 28), self_30421, 'create_dist')163        # Calling create_dist(args, kwargs) (line 16)164        create_dist_call_result_30424 = invoke(stypy.reporting.localization.Localization(__file__, 16, 28), create_dist_30422, *[], **kwargs_30423)165        166        # Obtaining the member '__getitem__' of a type (line 16)167        getitem___30425 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 16, 8), create_dist_call_result_30424, '__getitem__')168        # Calling the subscript (__getitem__) to obtain the elements type (line 16)169        subscript_call_result_30426 = invoke(stypy.reporting.localization.Localization(__file__, 16, 8), getitem___30425, int_30420)170        171        # Assigning a type to the variable 'tuple_var_assignment_30405' (line 16)172        module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 16, 8), 'tuple_var_assignment_30405', subscript_call_result_30426)173        174        # Assigning a Subscript to a Name (line 16):175        176        # Obtaining the type of the subscript177        int_30427 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 16, 8), 'int')178        179        # Call to create_dist(...): (line 16)180        # Processing the call keyword arguments (line 16)181        kwargs_30430 = {}182        # Getting the type of 'self' (line 16)183        self_30428 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 16, 28), 'self', False)184        # Obtaining the member 'create_dist' of a type (line 16)185        create_dist_30429 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 16, 28), self_30428, 'create_dist')186        # Calling create_dist(args, kwargs) (line 16)187        create_dist_call_result_30431 = invoke(stypy.reporting.localization.Localization(__file__, 16, 28), create_dist_30429, *[], **kwargs_30430)188        189        # Obtaining the member '__getitem__' of a type (line 16)190        getitem___30432 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 16, 8), create_dist_call_result_30431, '__getitem__')191        # Calling the subscript (__getitem__) to obtain the elements type (line 16)192        subscript_call_result_30433 = invoke(stypy.reporting.localization.Localization(__file__, 16, 8), getitem___30432, int_30427)193        194        # Assigning a type to the variable 'tuple_var_assignment_30406' (line 16)195        module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 16, 8), 'tuple_var_assignment_30406', subscript_call_result_30433)196        197        # Assigning a Name to a Name (line 16):198        # Getting the type of 'tuple_var_assignment_30405' (line 16)199        tuple_var_assignment_30405_30434 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 16, 8), 'tuple_var_assignment_30405')200        # Assigning a type to the variable 'project_dir' (line 16)201        module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 16, 8), 'project_dir', tuple_var_assignment_30405_30434)202        203        # Assigning a Name to a Name (line 16):204        # Getting the type of 'tuple_var_assignment_30406' (line 16)205        tuple_var_assignment_30406_30435 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 16, 8), 'tuple_var_assignment_30406')206        # Assigning a type to the variable 'dist' (line 16)207        module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 16, 21), 'dist', tuple_var_assignment_30406_30435)208        209        # Assigning a Call to a Name (line 17):210        211        # Assigning a Call to a Name (line 17):212        213        # Call to bdist_msi(...): (line 17)214        # Processing the call arguments (line 17)215        # Getting the type of 'dist' (line 17)216        dist_30437 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 17, 24), 'dist', False)217        # Processing the call keyword arguments (line 17)218        kwargs_30438 = {}219        # Getting the type of 'bdist_msi' (line 17)220        bdist_msi_30436 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 17, 14), 'bdist_msi', False)221        # Calling bdist_msi(args, kwargs) (line 17)222        bdist_msi_call_result_30439 = invoke(stypy.reporting.localization.Localization(__file__, 17, 14), bdist_msi_30436, *[dist_30437], **kwargs_30438)223        224        # Assigning a type to the variable 'cmd' (line 17)225        module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 17, 8), 'cmd', bdist_msi_call_result_30439)226        227        # Call to ensure_finalized(...): (line 18)228        # Processing the call keyword arguments (line 18)229        kwargs_30442 = {}230        # Getting the type of 'cmd' (line 18)231        cmd_30440 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 18, 8), 'cmd', False)232        # Obtaining the member 'ensure_finalized' of a type (line 18)233        ensure_finalized_30441 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 18, 8), cmd_30440, 'ensure_finalized')234        # Calling ensure_finalized(args, kwargs) (line 18)235        ensure_finalized_call_result_30443 = invoke(stypy.reporting.localization.Localization(__file__, 18, 8), ensure_finalized_30441, *[], **kwargs_30442)236        237        238        # ################# End of 'test_minimal(...)' code ##################239        # Teardown call information240        teardown_call_information(localization, arguments)241        242        # Storing the return type of function 'test_minimal' in the type store243        # Getting the type of 'stypy_return_type' (line 13)244        stypy_return_type_30444 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 13, 4), 'stypy_return_type')245        module_type_store.store_return_type_of_current_context(stypy_return_type_30444)246        247        # Destroy the current context248        module_type_store = module_type_store.close_function_context()249        250        # Return type of the function 'test_minimal'251        return stypy_return_type_30444252    @norecursion...options.py
Source:options.py  
1import os2from zaf.component.decorator import requires3@requires(zk2='Zk2')4def test_missing_optional_config_options(zk2):5    zk2(6        ['runcommand', 'testfinder', 'withoptionalconfigoptions'],7        'run systest.data.suites.test_minimal',8        plugin_path=os.path.join('systest', 'data', 'plugins'))9@requires(zk2='Zk2')10def test_missing_required_config_options(zk2):11    zk2(12        ['runcommand', 'testfinder', 'withrequiredconfigoptions'],13        'run systest.data.suites.test_minimal',14        2,15        plugin_path=os.path.join('systest', 'data', 'plugins'))16@requires(zk2='Zk2')17def test_available_required_config_options(zk2):18    zk2(19        ['runcommand', 'testfinder', 'withrequiredconfigoptions'],20        'run systest.data.suites.test_minimal --req-option1 a --req-option2 b',21        plugin_path=os.path.join('systest', 'data', 'plugins'))22@requires(zk2='Zk2')23def test_typed_str_option(zk2):24    zk2(25        ['runcommand', 'testfinder', 'withtypedconfigoptions'],26        'run systest.data.suites.test_minimal --str-option a',27        plugin_path=os.path.join('systest', 'data', 'plugins'))28@requires(zk2='Zk2')29def test_typed_int_option(zk2):30    zk2(31        ['runcommand', 'testfinder', 'withtypedconfigoptions'],32        'run systest.data.suites.test_minimal --int-option 1',33        plugin_path=os.path.join('systest', 'data', 'plugins'))34@requires(zk2='Zk2')35def test_typed_int_option_can_not_be_parsed(zk2):36    zk2(37        ['runcommand', 'testfinder', 'withtypedconfigoptions'],38        'run systest.data.suites.test_minimal --int-option a',39        2,40        plugin_path=os.path.join('systest', 'data', 'plugins'))41@requires(zk2='Zk2')42def test_typed_float_option(zk2):43    zk2(44        ['runcommand', 'testfinder', 'withtypedconfigoptions'],45        'run systest.data.suites.test_minimal --float-option 1.23',46        plugin_path=os.path.join('systest', 'data', 'plugins'))47@requires(zk2='Zk2')48def test_typed_float_option_can_not_be_parsed(zk2):49    zk2(50        ['runcommand', 'testfinder', 'withtypedconfigoptions'],51        'run systest.data.suites.test_minimal --float-option a',52        2,53        plugin_path=os.path.join('systest', 'data', 'plugins'))54@requires(zk2='Zk2')55def test_typed_path_option_exists(zk2):56    zk2(57        ['runcommand', 'testfinder', 'withtypedconfigoptions'],58        'run systest.data.suites.test_minimal --path-option systest',59        plugin_path=os.path.join('systest', 'data', 'plugins'))60@requires(zk2='Zk2')61def test_typed_path_option_does_not_exist(zk2):62    zk2(63        ['runcommand', 'testfinder', 'withtypedconfigoptions'],64        'run systest.data.suites.test_minimal --path-option /a/b/c',65        2,66        plugin_path=os.path.join('systest', 'data', 'plugins'))67@requires(zk2='Zk2')68def test_typed_choice_option(zk2):69    zk2(70        ['runcommand', 'testfinder', 'withtypedconfigoptions'],71        'run systest.data.suites.test_minimal --choice-option b',72        plugin_path=os.path.join('systest', 'data', 'plugins'))73@requires(zk2='Zk2')74def test_typed_choice_option_not_valid_choice(zk2):75    zk2(76        ['runcommand', 'testfinder', 'withtypedconfigoptions'],77        'run systest.data.suites.test_minimal --choice-option d',78        2,79        plugin_path=os.path.join('systest', 'data', 'plugins'))80@requires(zk2='Zk2')81def test_typed_bool_option(zk2):82    zk2(83        ['runcommand', 'testfinder', 'withtypedconfigoptions'],84        'run systest.data.suites.test_minimal --bool-option true',85        plugin_path=os.path.join('systest', 'data', 'plugins'))86# TODO: ZMT-639587# Default values and transform doesn't work correctly. The transformed value88# is passed to click instead of the raw value. Hence, the transform-choice89# option will be blocked by click if the default value is used.90# As a temporary work-around, --transform-choice-option A is passed91# in test cases that doesn't care about it, to avoid the default value-problem.92@requires(zk2='Zk2')93def test_multiple_options(zk2):94    result = zk2(95        ['runcommand', 'testfinder', 'withconfigoptionfeatures'],96        'run systest.data.suites.test_minimal '97        '--transform-choice-option A '  # TODO: ZMT-6395: Remove, see above.98        '--multiple-option 1 --multiple-option 2 --multiple-option 3',99        plugin_path=os.path.join('systest', 'data', 'plugins'))100    assert 'multiple.option: (1, 2, 3)' in result.stdout101@requires(zk2='Zk2')102def test_default_option(zk2):103    result = zk2(104        ['runcommand', 'testfinder', 'withconfigoptionfeatures'],105        'run systest.data.suites.test_minimal '106        '--transform-choice-option A ',  # TODO: ZMT-6395: Remove, see above.107        plugin_path=os.path.join('systest', 'data', 'plugins'))108    assert 'default.option: default' in result.stdout109@requires(zk2='Zk2')110def test_transform_option(zk2):111    result = zk2(112        ['runcommand', 'testfinder', 'withconfigoptionfeatures'],113        'run systest.data.suites.test_minimal '114        '--transform-choice-option A '  # TODO: ZMT-6395: Remove, see above.115        '--transform-option t',116        plugin_path=os.path.join('systest', 'data', 'plugins'))117    assert 'transform.option: transformed t' in result.stdout118@requires(zk2='Zk2')119def test_transform_choice_option(zk2):120    result = zk2(121        ['runcommand', 'testfinder', 'withconfigoptionfeatures'],122        'run systest.data.suites.test_minimal '123        '--transform-choice-option B',124        plugin_path=os.path.join('systest', 'data', 'plugins'))...test_releasehook.py
Source:test_releasehook.py  
...9from sentry.models import Commit, Release10from sentry.plugins import ReleaseHook11from sentry.testutils import TestCase12class StartReleaseTest(TestCase):13    def test_minimal(self):14        project = self.create_project()15        version = 'bbee5b51f84611e4b14834363b8514c2'16        hook = ReleaseHook(project)17        hook.start_release(version)18        release = Release.objects.get(19            project=project,20            version=version,21        )22        assert release.date_started23class FinishReleaseTest(TestCase):24    def test_minimal(self):25        project = self.create_project()26        version = 'bbee5b51f84611e4b14834363b8514c2'27        hook = ReleaseHook(project)28        hook.finish_release(version)29        release = Release.objects.get(30            project=project,31            version=version,32        )33        assert release.date_released34class SetCommitsTest(TestCase):35    def test_minimal(self):36        project = self.create_project()37        version = 'bbee5b51f84611e4b14834363b8514c2'38        data_list = [39            {40                'id': 'c7155651831549cf8a5e47889fce17eb',41                'message': 'foo',42                'author_email': 'jane@example.com',43            },44            {45                'id': 'bbee5b51f84611e4b14834363b8514c2',46                'message': 'bar',47                'author_name': 'Joe^^',48            },49        ]...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
