Best Python code snippet using avocado_python
test_new.py
Source:test_new.py  
1import os2import shutil3from os.path import join4sourcepath_in='/home/jam/Test_Folder/IN'5sourcefiles_in = os.listdir(sourcepath_in)6sourcepath_out_bus='/home/jam/Test_Folder/OUT_BUS'7sourcefiles_out_bus = os.listdir(sourcepath_out_bus)8sourcepath_out_nco='/home/jam/Test_Folder/OUT_BUS'9sourcefiles_out_nco = os.listdir(sourcepath_out_nco)10sourcepath_out_bo='/home/jam/Test_Folder/OUT_BO'11sourcefiles_out_bo = os.listdir(sourcepath_out_bo)12sourcepath_out_test='/home/jam/Test_Folder/OUT_TEST'13sourcefiles_out_test = os.listdir(sourcepath_out_test)14destinationpath_in_bus = '/home/jam/Test_Folder/IN_BUS'15destinationpath_in_nco = '/home/jam/Test_Folder/IN_NCO'16destinationpath_in_bo = '/home/jam/Test_Folder/IN_BO'17destinationpath_in_out = '/home/jam/Test_Folder/OUT'18destinationpath_in_test = '/home/jam/Test_Folder/IN_TEST'19suffixes_in_nco = ("Airi", "Reci", "Rcmi", "Siri", "Srai", "Srmi", "Ladi", "Lidi", "Lcdi", "Lmdi", "Lami", "Limi", "Tncc", "Rcmc", "Recc", "Oirc", "Srmc", "Srac", "Blni", "In1i", "In2i", "Gufi", "Pnli", "R02i", "R03i", "Riai", "Acti", "Dsri", "Rmri")20suffixes_in_bo = ("Erri", "Reji", "Trei", "Tnci", "Bavi", "Bini", "Dcti", "Mbri", "Crri", "Crfi", "Mafi", "Mfri", "Slai", "Trec", "Errc", "Rejc", "Crti", "Slci", "Slri", "Crli", "Stpi")21suffixes_in_bus = ("Oiri", "Frif", "Fris", "Frof", "Fros", "Fidr", "Fiwr", "Fimr", "Fiqr", "Fadr", "Fawr", "Famr", "Faqr")22suffixes_test=("_T_")23suffixes_prod=("_P_")24for file in sourcefiles_in:25    start_suffixes = 026    check_t = 027    if file.count( "_", 0 , 12) == 2:28        start_suffixes = 1029        test_check = 1430    elif file.count( "_", 0 , 12) == 3:31        start_suffixes = 532        test_check = 9 33    if file.startswith(suffixes_test, test_check):34        shutil.move(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_test,file)) 35    elif file.startswith(suffixes_prod, test_check):36        if file.startswith(suffixes_in_nco, start_suffixes):37            shutil.copy(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_bus,file))38            shutil.move(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_nco,file))39        elif file.startswith(suffixes_in_bo, start_suffixes):40            shutil.move(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_bo,file))41        elif file.startswith(suffixes_in_bus, start_suffixes):42            shutil.move(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_bus,file))43        else :44            shutil.copy(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_bus,file))45            shutil.copy(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_bo,file))46            shutil.move(os.path.join(sourcepath_in,file), os.path.join(destinationpath_in_nco,file))47for file in sourcefiles_out_test:48    start_suffixes = 049    check_t = 050    if file.count( "_", 0 , 12) == 2:51        start_suffixes = 1052        test_check = 1453    elif file.count( "_", 0 , 12) == 3:54        start_suffixes = 555        test_check = 956    if file.startswith(suffixes_test, test_check):57        shutil.move(os.path.join(sourcepath_out_test,file), os.path.join(destinationpath_out,file))58for file in sourcefiles_out_bus:59    start_suffixes = 060    check_t = 061    if file.count( "_", 0 , 12) == 2:62        start_suffixes = 1063        test_check = 1464    elif file.count( "_", 0 , 12) == 3:65        start_suffixes = 566        test_check = 967    if file.startswith(suffixes_prod, test_check):68        shutil.move(os.path.join(sourcepath_out_bus,file), os.path.join(destinationpath_out,file))69for file in sourcefiles_out_bo:70    start_suffixes = 071    check_t = 072    if file.count( "_", 0 , 12) == 2:73        start_suffixes = 1074        test_check = 1475    elif file.count( "_", 0 , 12) == 3:76        start_suffixes = 577        test_check = 978    if file.startswith(suffixes_prod, test_check):79        shutil.move(os.path.join(sourcepath_out_bo,file), os.path.join(destinationpath_out,file))80for file in sourcefiles_out_nco:81    start_suffixes = 082    check_t = 083    if file.count( "_", 0 , 12) == 2:84        start_suffixes = 1085        test_check = 1486    elif file.count( "_", 0 , 12) == 3:87        start_suffixes = 588        test_check = 989    if file.startswith(suffixes_prod, test_check):...test_environmemt.py
Source:test_environmemt.py  
1import bootstraparse.modules.environment as e2def test_wasInitialised():3    test_check = e.Environment()4    for k in test_check._wasInitialised.values():5        assert k is False6def test_integrity_check():7    test_check = e.Environment()8    custom_test_p = [p for p in test_check._mParams.keys()]9    custom_test_v = [False for _ in test_check._mParams.values()]10    # Test all False11    # rich.inspect(test_check)12    assert test_check.integrity_check() is False13    custom_test_v[0] = True14    test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))15    # Test first False16    # rich.inspect(test_check)17    assert test_check.integrity_check() is False18    custom_test_v[0] = False19    custom_test_v[-1] = True20    test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))21    # Test last False22    # rich.inspect(test_check)23    assert test_check.integrity_check() is False24    custom_test_v[-1] = False25    custom_test_v[len(custom_test_v)//2-1] = True26    test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))27    # Test middle False28    # rich.inspect(test_check)29    assert test_check.integrity_check() is False30    custom_test_v = [True for _ in test_check._mParams.values()]31    test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v))32    # Test all True33    # rich.inspect(test_check)34    assert test_check.integrity_check() is True35def test_getter():36    test_check = e.Environment()37    for p in test_check._mParams:38        assert test_check.__getattr__(p) == test_check._mParams[p]39    test_check._sParams = {40        "test_param": "test_value"41    }42    assert test_check.test_param == "test_value"43    try:44        test_check.purposefully_non_existing_parameter45    except AttributeError:46        pass47    except Exception:48        assert False  # Not AttributeError when getting non-existing parameter49    try:50        test_check._purposefully_non_existing_parameter51    except AttributeError:52        pass53    except Exception:54        assert False  # Not AttributeError when getting underscored non-existing parameter55def test_setter():56    test_check = e.Environment()57    for p in test_check._mParams:58        test_check.__setattr__(p, "test_value")59        assert test_check._mParams[p] == "test_value"60    test_check._sParams = {61        "test_param": "test_value"62    }63    test_check.test_param = "second_test_value"64    assert test_check.test_param == "second_test_value"65    try:66        test_check.purposefully_non_existing_parameter = "test_value"67    except AttributeError:68        pass69    except Exception:70        assert False  # Not AttributeError when getting non-existing parameter71    test_check._purposefully_non_existing_parameter = "test_value"72    assert test_check._purposefully_non_existing_parameter == "test_value"73if __name__ == "__main__":...test_auth.py
Source:test_auth.py  
...16        return C()17    def user_group_can_x(self, _x):18        return self.v19class TestAllowEditUser(TestCase):20    def test_check(self):21        sut = AllowEditUser()22        checker = StubChecker(True)23        self.assertEqual(sut.check(checker), True)24class TestAllowInEditGroup(TestCase):25    def test_check(self):26        sut = AllowInEditGroup()27        checker = StubChecker(True)28        self.assertEqual(sut.check(checker), True)29class TestAllowStandUser(TestCase):30    def test_check(self):31        sut = AllowStandUser()32        checker = StubChecker(True)33        self.assertEqual(sut.check(checker), True)34class TestAllowUserGroupCanView(TestCase):35    def test_check(self):36        sut = AllowUserGroupCanView()37        checker = StubChecker(True)38        self.assertEqual(sut.check(checker), True)39class TestAllowInAdminGroup(TestCase):40    def test_check(self):41        sut = AllowInAdminGroup()42        checker = StubChecker(True)43        self.assertEqual(sut.check(checker), True)44class TestAllowAdminUser(TestCase):45    def test_check(self):46        sut = AllowAdminUser()47        checker = StubChecker(True)48        self.assertEqual(sut.check(checker), True)49class StubStandUserSet(object):50    def filter(self, **kargs):51        class C(object):52            def count(self):53                return 254            def __getitem__(self, i):55                class D(object):56                    access = i57                return D()58        return C()59class StubStand(object):...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!!
