Best Python code snippet using autotest_python
test_filemanager.py
Source:test_filemanager.py
...8 for item in os.listdir():9 if os.path.isfile(item):10 result.append(item)11 return result12def copy_file_or_directory(name, new_name):13 if os.path.isdir(name):14 shutil.copytree(name, new_name)15 else:16 shutil.copyfile(name, new_name)17#ТеÑÑиÑÑем не ЧÐСТУЮ ÑÑнкÑиÑ:18def test_copy_file_or_directory():19 file_list = filenames()20 file_name = str(file_list[0])21 copy_file_or_directory(file_name,file_name+"01")22 file_list = filenames()23 assert file_name+"01" in file_list24def author_info():25 return 'Leonid Orlov'26#ТеÑÑиÑÑем ЧÐСТУЮ ÑÑнкÑиÑ:27def test_author_info():28 assert author_info() == 'Leonid Orlov'29# ÑооÑвеÑÑÑвие меÑÑÑа и его названиÑ30months = {31 '01': 'ÑнваÑÑ',32 '02': 'ÑевÑалÑ',33 '06': 'иÑнÑ'34}35# ÑооÑвеÑÑÑвие Ð´Ð½Ñ Ð¸ его названиÑ...
test_Leo.py
Source:test_Leo.py
...6 assert date_to_str("01.01.1999") == "пеÑвое ÑнваÑÑ 1999 года"7 assert date_to_str("26.02.1990") == "двадÑаÑÑ ÑеÑÑое ÑевÑÐ°Ð»Ñ 1990 года"8def test_is_correct_choice():9 assert is_correct_choice("2") == True10def test_copy_file_or_directory():11 WeirdFileName1 = "sfdjkhOYUIO9879.py"12 WeirdFileName2 = "sfdjkhOYUIO98792.py"13 WeirdDirName1 = "sfdjkhOYUIO98793"14 WeirdDirName2 = "sfdjkhOYUIO98794"15 if not os.path.exists(WeirdFileName1) and not os.path.exists(WeirdFileName2):16 f1 = open(WeirdFileName1, "w")17 f1.write("hello")18 f1.close()19 copy_file_or_directory(WeirdFileName1, WeirdFileName2)20 assert os.path.exists(WeirdFileName2) == True21 os.remove(WeirdFileName1)22 os.remove(WeirdFileName2)23 if not os.path.exists(WeirdDirName1) and not os.path.exists(WeirdDirName2):24 os.mkdir(WeirdDirName1)25 copy_file_or_directory(WeirdDirName1, WeirdDirName2)26 assert os.path.exists(WeirdDirName2) == True27 os.rmdir(WeirdDirName1)...
filemanager.py
Source:filemanager.py
1import shutil2import os3import sys4def copy_file_or_directory(name, new_name):5 if os.path.isdir(name):6 shutil.copytree(name, new_name)7 else:8 shutil.copyfile(name, new_name)9def filenames():10 result = []11 for item in os.listdir():12 if os.path.isfile(item):13 result.append(item)14 return result15def author_info():16 return 'Leonid Orlov'17def quit():18 sys.exit(0)
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!!