Best Python code snippet using autotest_python
test_selector.py
Source:test_selector.py
...91 c = Config()92 c.where = [absdir(os.path.join(os.path.dirname(__file__), 'support'))]93 base = c.where[0]94 s = Selector(c)95 assert not s.wantFile('setup.py')96 assert not s.wantFile('/some/path/to/setup.py')97 assert not s.wantFile('ez_setup.py')98 assert not s.wantFile('.test.py')99 assert not s.wantFile('_test.py')100 assert not s.wantFile('setup_something.py')101 102 assert s.wantFile('test.py')103 assert s.wantFile('foo/test_foo.py')104 assert s.wantFile('bar/baz/test.py')105 assert not s.wantFile('foo.py')106 assert not s.wantFile('test_data.txt')107 assert not s.wantFile('data.text')108 assert not s.wantFile('bar/baz/__init__.py')109 110 def test_want_function(self):111 def foo():112 pass113 def test_foo():114 pass115 def test_bar():116 pass117 118 s = Selector(Config())119 assert s.wantFunction(test_bar)120 assert s.wantFunction(test_foo)121 assert not s.wantFunction(foo)122 test_foo.__test__ = False...
Verbasizer.py
Source:Verbasizer.py
1def lookingForFile ():2 fileWanted = False3 wantFile = input ("Do you have a previous draft that you would like to continue? [Y/N]: ")4 wantFile = wantFile.upper()5 if len(wantFile) != 0:6 if "Y" in wantFile or "YES" in wantFile:7 fileWanted = True8 elif "N" in wantFile or "NO" in wantFile:9 fileWanted = False10 else:11 while "Y" not in wantFile and "YES" not in wantFile and "N" not in wantFile and "NO" not in wantFile:12 print("Error: Please only enter Y or N.")13 wantFile = input ("[Y/N]?: ")14 wantFile = wantFile.upper()15 if "Y" in wantFile or "YES" in wantFile:16 fileWanted = True17 else:18 while len(wantFile) == 0:19 print("Error: Please only enter Y or N.")20 wantFile = input ("[Y/N]?: ")21 wantFile = wantFile.upper()22 if len(wantFile) != 0:23 if "Y" in wantFile or "YES" in wantFile:24 fileWanted = True25 elif "N" in wantFile or "NO" in wantFile:26 fileWanted = False27 else:28 while "Y" not in wantFile and "YES" not in wantFile and "N" not in wantFile and "NO" not in wantFile:29 print("Error: Please only enter Y or N.")30 wantFile = input ("[Y/N]?: ")31 wantFile = wantFile.upper()32 if "Y" in wantFile or "YES" in wantFile:33 fileWanted = True34 return fileWanted35def promptForFile ():36 print("")37 fileName = input ("Please enter the file name of your previous draft: ")38 print("")39 if len(fileName) == 0:40 fileName = input("Please enter a file name: ")41 print("")42 while len(fileName) == 0:43 fileName = input("Please enter a file name: ")44 print("")45 return fileName46def readFile(file):47 fileObj = open(file, "r")48 lines = fileObj.read().splitlines()49 fileObj.close()50 return lines51def printList ():52 for x in list:53 print(x)54def correctDraft():55 draftWanted = False56 print("")57 response = input("Is this the correct draft? [Y/N]: ")58 response = response.upper()59 if len(response) != 0:60 if "Y" in response or "YES" in response:61 draftWanted = True62 print("")63 elif "N" in response or "NO" in response:64 draftWanted = False65 else:66 while "Y" not in response and "YES" not in response and "N" not in response and "NO" not in response:67 print("Error: Please only enter Y or N.")68 response = input ("[Y/N]?: ")69 response = response.upper()70 if "Y" in response or "YES" in response:71 draftWanted = True72 else:73 while "Y" not in response and "YES" not in response and "N" not in response and "NO" not in response:74 print("Error: Please only enter Y or N.")75 response = input ("[Y/N]?: ")76 response = response.upper()77 if "Y" in response or "YES" in response:78 draftWanted = True79 return draftWanted80def storeWords ():81 words = []82 userWord = input("Please enter any words you would like (enter a blank to exit): ")83 words.append(userWord)84 while len(userWord) != 0:85 userWord = input()86 if len(userWord) > 0:87 words.append(userWord)88 print("Your words:" + words)89 return words90def main ():91 print("Welcome to the Verbasizer.")...
test_selector_plugins.py
Source:test_selector_plugins.py
...5from nose.plugins.manager import PluginManager6class TestSelectorPlugins(unittest.TestCase):7 def test_rejection(self):8 class EvilSelector(Plugin):9 def wantFile(self, filename, package=None):10 if 'good' in filename:11 return False12 return None13 c = Config(plugins=PluginManager(plugins=[EvilSelector()]))14 s = nose.selector.Selector(c)15 s2 = nose.selector.Selector(Config())16 17 assert s.wantFile('test_neutral.py')18 assert s2.wantFile('test_neutral.py')19 20 assert s.wantFile('test_evil.py')21 assert s2.wantFile('test_evil.py')22 23 assert not s.wantFile('test_good.py')24 assert s2.wantFile('test_good.py')25 26if __name__ == '__main__':...
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!!