How to use copy_file_or_directory method in autotest

Best Python code snippet using autotest_python

test_filemanager.py

Source:test_filemanager.py Github

copy

Full Screen

...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# соответствие дня и его названия...

Full Screen

Full Screen

test_Leo.py

Source:test_Leo.py Github

copy

Full Screen

...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)...

Full Screen

Full Screen

filemanager.py

Source:filemanager.py Github

copy

Full Screen

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)

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