How to use prepare_report_dirs method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

test_reportdir.py

Source:test_reportdir.py Github

copy

Full Screen

1import os.path as osp2import glob3import re4from lemoncheesecake.reporting.reportdir import create_report_dir_with_rotation5def prepare_report_dirs(top_dir, has_current=False, archive_nums=None):6 if has_current:7 top_dir.join("report").mkdir()8 if archive_nums is not None:9 top_dir.join("reports").mkdir()10 for num in archive_nums:11 top_dir.join("reports").mkdir("report-%d" % num)12def get_report_nums_in_dir(top_dir):13 for dirname in glob.glob(osp.join(top_dir, "report-*")):14 m = re.compile(r"report-(\d+)$").search(dirname)15 if m is not None:16 yield int(m.group(1))17def check_report_dirs(top_dir, has_current=False, archive_nums=None):18 assert osp.exists(top_dir.join("report").strpath) == has_current19 if archive_nums is not None:20 assert osp.exists(top_dir.join("reports").strpath)21 assert sorted(get_report_nums_in_dir(top_dir.join("reports").strpath)) == sorted(archive_nums)22 else:23 assert not osp.exists(top_dir.join("reports").strpath)24def test_first_report(tmpdir):25 path = create_report_dir_with_rotation(tmpdir.strpath)26 assert osp.exists(path)27 check_report_dirs(tmpdir, has_current=True, archive_nums=None)28def test_first_archiving(tmpdir):29 prepare_report_dirs(tmpdir, has_current=True)30 create_report_dir_with_rotation(tmpdir.strpath)31 check_report_dirs(tmpdir, has_current=True, archive_nums=[1])32def test_first_rotation(tmpdir):33 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[1])34 create_report_dir_with_rotation(tmpdir.strpath)35 check_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2])36def test_first_removal(tmpdir):37 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2])38 create_report_dir_with_rotation(tmpdir.strpath, archiving_limit=2)39 check_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2])40def test_no_archiving_limit(tmpdir):41 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2])42 create_report_dir_with_rotation(tmpdir.strpath, archiving_limit=None)43 check_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2, 3])44def test_report_1_missing(tmpdir):45 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[2, 3])46 create_report_dir_with_rotation(tmpdir.strpath)47 check_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2, 3])48def test_report_2_missing(tmpdir):49 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[1, 3])50 create_report_dir_with_rotation(tmpdir.strpath)51 check_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2, 3])52def test_report_1_and_2_missing(tmpdir):53 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[3])54 create_report_dir_with_rotation(tmpdir.strpath)55 check_report_dirs(tmpdir, has_current=True, archive_nums=[1, 3])56def test_report_num_slots_free_1(tmpdir):57 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[2, 3])58 create_report_dir_with_rotation(tmpdir.strpath, archiving_limit=3)59 check_report_dirs(tmpdir, has_current=True, archive_nums=[1, 2, 3])60def test_report_num_slots_free_2(tmpdir):61 prepare_report_dirs(tmpdir, has_current=True, archive_nums=[1, 3, 4])62 create_report_dir_with_rotation(tmpdir.strpath, archiving_limit=3)...

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