How to use test_finish method in autotest

Best Python code snippet using autotest_python

test.py

Source:test.py Github

copy

Full Screen

...10 print('Unmounting...')11 su.call('fusermount -u %s' % test_dir, shell=True)12def waiting():13 su.call('sleep 3', shell=True)14def test_finish():15 print('')16 print('Finishing test')17 print('Waiting for unmount')18 waiting()19 umount()20if __name__ == '__main__':21 test_dir = sys.argv[1] if len(sys.argv) > 1 else 'td'22 if test_dir[-1] != '/': test_dir += '/'23 print('Start test dir %s' % test_dir)24 umount()25 print('Creating fs')26 su.call('./createfs ', shell=True)27 print('Making') 28 su.call('make', shell=True)29 mount()30 print('') 31 print('Making new dir')32 su.call('mkdir %stestdir' % test_dir, shell=True)33 if not os.path.exists(test_dir + 'testdir'):34 print(' >Mkdir failed')35 test_finish()36 exit()37 else:38 print(' >Making dir sucsessfull')39 print('Test cp file')40 test_file_path = '%stestdir/fswork.c' % test_dir41 su.call('cp fswork.c %s' % test_file_path, shell=True)42 if not os.path.exists(test_file_path):43 print(' >cp file failed: file not exists')44 test_finish()45 exit()46 else:47 if not filecmp.cmp('fswork.c', test_file_path):48 print(' >cp file failed: bad data')49 test_finish()50 exit()51 else:52 print(' >cp file sucsessfull. Data valid')53 print('subdir test')54 su.call('mkdir %stestdir/d2' % test_dir, shell=True)55 if not os.path.exists(test_dir + 'testdir/d2'):56 print(' >Mk subdir failed')57 test_finish()58 exit()59 else:60 print(' >Making subdir sucsessfull')61 print('mv test')62 new_test_file_path = '%stestdir/d2/mvfile' % test_dir63 su.call('mv %s %s' % (test_file_path, new_test_file_path), shell=True)64 if os.path.exists(test_file_path):65 print(' >mv file failed: old file exists')66 test_finish()67 exit()68 else:69 if not os.path.exists(new_test_file_path):70 print(' >mv file failed: file not exists')71 test_finish()72 exit()73 else:74 if not filecmp.cmp('fswork.c', new_test_file_path):75 print(' >mv file failed: bad data')76 test_finish()77 exit()78 else:79 print(' >mv file sucsessfull. Data valid')80 print('Unmount test')81 print('Waiting for unmount')82 waiting()83 umount()84 mount()85 if os.path.exists(test_file_path):86 print(' >unmount failed: old file exists')87 test_finish()88 exit()89 else:90 if not os.path.exists(new_test_file_path):91 print(' >unmount failed: file not exists')92 test_finish()93 exit()94 else:95 if not filecmp.cmp('fswork.c', new_test_file_path):96 print(' >unmount failed: bad data')97 test_finish()98 exit()99 else:100 print(' >unmount sucsessfull. Data valid')101 print('many files cp test')102 for i in xrange(40):103 tmp_test_file_path = new_test_file_path + str(i)104 su.call('cp %s %s' % (new_test_file_path, tmp_test_file_path), shell=True)105 if not os.path.exists(tmp_test_file_path):106 print(' >cp file failed: file not exists')107 test_finish()108 exit()109 else:110 if not filecmp.cmp(new_test_file_path, tmp_test_file_path):111 print(' >cp file failed: bad data')112 test_finish()113 exit()114 print(' >many cp test passed!') 115 print('Unmount test2')116 print('Waiting for unmount')117 waiting()118 umount()119 mount()120 for i in xrange(40):121 tmp_test_file_path = new_test_file_path + str(i)122 if not os.path.exists(tmp_test_file_path):123 print(' >cp file failed: file not exists')124 test_finish()125 exit()126 else:127 if not filecmp.cmp(new_test_file_path, tmp_test_file_path):128 print(' >cp file failed: bad data')129 test_finish()130 exit()131 print(' >Unmount 2 test passed!') 132 print('Big data test')133 su.call('mkdir %sdtobg' % test_dir, shell=True)134 su.call('cp bg.tar.gz %sdtobg/bg.tar.gz' % test_dir, shell=True)135 test_file_path = '%sdtobg/bg.tar.gz' % test_dir136 if not os.path.exists(test_file_path):137 print(' >big data failed: file not exists')138 test_finish()139 exit()140 else:141 if not filecmp.cmp('bg.tar.gz', test_file_path):142 print(' >big data failed: bad data')143 test_finish()144 exit()145 else:146 print(' >big data sucsessfull. Data valid')147 print('remove test')148 test_file_path = '%stestdir/d2/mvfile' % test_dir149 su.call('rm %s' % test_file_path, shell=True)150 if os.path.exists(test_file_path):151 print('remove test failed')152 test_finish()153 exit()154 else:155 print(' >remove test sucsessfull')156 print('rmdir test')157 su.call('rmdir %stestdir' % test_dir, shell=True)158 if os.path.exists('%stestdir' % test_dir):159 print(' >rmdir test failed')160 test_finish()161 exit()162 else:163 print(' >rmdir sucsessfull')164 print('filework test')165 strforcheck = ''166 with open('%sfile' % test_dir, 'w') as f:167 s = 'hi!'168 s += '\n'169 strforcheck += s170 f.write(strforcheck)171 with open('%sfile' % test_dir) as f:172 tmp = f.read()173 if tmp != strforcheck:174 print(' >filework test failed')175 test_finish()176 exit()177 else:178 print(' >filework sucsessfull')179 with open('%sfile' % test_dir, 'a+') as f:180 s = ':)'181 s += '\n'182 strforcheck += s183 f.write(s)184 with open('%sfile' % test_dir) as f:185 tmp = f.read()186 if tmp != strforcheck:187 print(' >filework2 test failed')188 test_finish()189 exit()190 else:191 print(' >filework2 sucsessfull')192 print('symlink test')193 #su.call('cd %s' % test_dir, shell=True)194 os.chdir(os.path.abspath(test_dir))195 print('Creating symlink')196 su.call('ln -s file smlt', shell=True)197 with open('smlt') as f:198 tmp = f.read()199 if tmp != strforcheck:200 print(' >symlink1 test failed')201 test_finish()202 exit()203 else:204 print(' >symlink1 sucsessfull')205 with open('smlt', 'a+') as f:206 s = '(:'207 s += '\n'208 strforcheck += s209 f.write(s)210 with open('smlt') as f:211 tmp = f.read()212 if tmp != strforcheck:213 print(' >symlink2 test failed')214 test_finish()215 exit()216 else:217 print(' >symlink2 sucsessfull')218 219 os.chdir(os.path.abspath('..'))220 print('big data 2 test')221 print('copying 1gb, please wait')222 su.call('cp /home/kirill/m.tar.gz %sm.tar.gz' % test_dir, shell=True)223 print('Waiting for unmount')224 waiting()225 umount()226 mount()227 if not filecmp.cmp('/home/kirill/m.tar.gz', '%sm.tar.gz' % test_dir):228 print(' >big data 2 failed')229 test_finish()230 exit()231 else:232 print(' >big data 2 sucsessfull')233 print('\nAll tests passed!')...

Full Screen

Full Screen

test_plugin.py

Source:test_plugin.py Github

copy

Full Screen

1from typing import Dict, List, Tuple2import pytest3from werkzeug.wrappers import Response4def test_plugin__insufficient_args(testdir):5 # arrange6 testmodule = testdir.makepyfile(7 """8 def test_ok():9 pass10 """11 )12 # act13 result = testdir.runpytest(testmodule, "--report-enabled")14 # assert15 assert result.ret == 416 result.stderr.fnmatch_lines(17 [18 "*--report-enabled should be used with --report-base-url and --report-auth-token*"19 ]20 )21def test_plugin__calls_expected__expected_summary(22 httpserver,23 testdir,24 auth_token,25 testmodule,26 reporting_api,27):28 # act29 result = testdir.runpytest(30 testmodule,31 "--report-enabled",32 "--report-base-url",33 httpserver.url_for(""),34 "--report-auth-token",35 auth_token,36 )37 # assert38 httpserver.check()39 assert result.ret == 140 result.stdout.re_match_lines(41 [42 ".*test_run_start\tRun ID: 11",43 ".*test_start.*Report ID: 1.*test_examples.*",44 ".*test_finish.*Report ID: 1.*test_examples.*",45 ".*test_start.*Report ID: 2.*test_examples.*",46 ".*test_finish.*Report ID: 2.*test_examples.*",47 ".*test_start.*Report ID: 3.*test_examples.*",48 ".*test_finish.*Report ID: 3.*test_examples.*",49 ".*test_start.*Report ID: 4.*test_properties.*",50 ".*test_finish.*Report ID: 4.*test_properties.*",51 ".*test_start.*Report ID: 5.*test_error_at_setup.*",52 ".*test_finish.*Report ID: 5.*test_error_at_setup.*",53 ".*test_start.*Report ID: 6.*test_error_at_teardown.*",54 ".*test_finish.*Report ID: 6.*test_error_at_teardown.*",55 ".*test_run_finish\tRun ID: 11",56 ]57 )58def test_plugin__xdist_enabled__calls_expected__expected_summary(59 httpserver,60 testdir,61 auth_token,62 testmodule,63 reporting_api,64):65 # act66 result = testdir.runpytest(67 testmodule,68 "--report-enabled",69 "--report-base-url",70 httpserver.url_for(""),71 "--report-auth-token",72 auth_token,73 "-n",74 "2",75 )76 # assert77 httpserver.check()78 assert result.ret == 179 result.stdout.re_match_lines(80 [81 ".*test_run_start\tRun ID: 11",82 ".*test_run_finish\tRun ID: 11",83 ]84 )85 result.stdout.re_match_lines_random(86 [87 ".*test_start.*Report ID: 1.*test_examples.*",88 ".*test_finish.*Report ID: 1.*test_examples.*",89 ".*test_start.*Report ID: 2.*test_examples.*",90 ".*test_finish.*Report ID: 2.*test_examples.*",91 ".*test_start.*Report ID: 3.*test_examples.*",92 ".*test_finish.*Report ID: 3.*test_examples.*",93 ".*test_start.*Report ID: 4.*test_properties.*",94 ".*test_finish.*Report ID: 4.*test_properties.*",95 ".*test_start.*Report ID: 5.*test_error_at_setup.*",96 ".*test_finish.*Report ID: 5.*test_error_at_setup.*",97 ".*test_start.*Report ID: 6.*test_error_at_teardown.*",98 ".*test_finish.*Report ID: 6.*test_error_at_teardown.*",99 ]...

Full Screen

Full Screen

search_tests.py

Source:search_tests.py Github

copy

Full Screen

1from unittest import TestCase2import unittest3from selenium.webdriver.common.keys import Keys4__author__ = 'devgen'5from selenium import webdriver6#7# driver = webdriver.Firefox()8# # driver = None9#10# test_finish = 011# methods_count = 012#13#14# def close_firefox():15# if test_finish >= methods_count:16# driver.close()17#18#19# class MethodsCounter(type):20# def __new__(mcs, class_name, bases, class_dict):21# global methods_count22# for attrName, attr in class_dict.items():23# if attrName.startswith("test_"):24# methods_count += 125# print "Count of test methods:", methods_count26class LastTest(TestCase):27 def test_search_with_result(self):28 # global test_finish29 driver = webdriver.Firefox()30 driver.get("http://lastfm.ru")31 elem = driver.find_element_by_css_selector("input.js-search.search-box")32 elem.send_keys("tool")33 elem.send_keys(Keys.RETURN)34 driver.implicitly_wait(10)35 assert driver.find_element_by_css_selector("#resultsSummary")36 assert driver.find_element_by_css_selector("#topResult")37 # test_finish += 138 #39 # close_firefox()40 driver.close()41 def test_search_with_no_result(self):42 # global test_finish43 driver = webdriver.Firefox()44 driver.get("http://lastfm.ru")45 elem = driver.find_element_by_css_selector("input.js-search.search-box")46 elem.send_keys("ydf70h78234y78g43nh4uc34rg43rw34io34hu34cg4rh8g2nh")47 elem.send_keys(Keys.RETURN)48 driver.implicitly_wait(10)49 assert driver.find_element_by_css_selector("div.messageBox.errorMessage")50 # test_finish += 151 #52 # close_firefox()53 driver.close()54if __name__ == '__main__':...

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 autotest 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