Best Python code snippet using avocado_python
compile-flares-plan.py
Source:compile-flares-plan.py
...16 # TEST*$flare_plan_item_is_run_indef17 fcs.flare_plan_item_is_run_indef(name, 0, 0);18 # TEST*$flare_plan_item_is_checkpoint19 fcs.flare_plan_item_is_checkpoint(name + " No. 1", 1);20def test_empty_plan():21 fcs = FC_Solve()22 name = "empty string plan"23 # TEST*$compile_flares_plan_ok24 fcs.compile_flares_plan_ok(name, "")25 # TEST26 fcs.flare_plan_num_items_is(name, 2);27 # TEST*$flare_plan_item_is_run_indef28 fcs.flare_plan_item_is_run_indef(name, 0, 0);29 # TEST*$flare_plan_item_is_checkpoint30 fcs.flare_plan_item_is_checkpoint(name + " No. 1", 1);31def test_two_runs():32 # Create a fresh instance33 fcs = FC_Solve()34 name = "Two Run's"35 # TEST*$input_cmd_line36 fcs.input_cmd_line("Input Flares",37 ["--flare-name", "dfs", "-nf",38 "--flare-name", "befs", "--method", "a-star"])39 # TEST*$compile_flares_plan_ok40 fcs.compile_flares_plan_ok(name, "Run:500@befs,Run:1500@dfs")41 # 2 runs and then the implicit checkpoint.42 # TEST43 fcs.flare_plan_num_items_is(name, 3);44 # TEST*$flare_plan_item_is_run45 fcs.flare_plan_item_is_run(name + " No. 0", 0, 1, 500);46 # TEST*$flare_plan_item_is_run47 fcs.flare_plan_item_is_run(name + " No. 1", 1, 0, 1500);48 # TEST*$flare_plan_item_is_checkpoint49 fcs.flare_plan_item_is_checkpoint(name + " No. 2", 2);50def test_with_checkpoints():51 testname = "With checkpoints"52 fcs = FC_Solve()53 # TEST*$input_cmd_line54 fcs.input_cmd_line("Input Flares",55 ["--flare-name", "dfs", "-nf",56 "--flare-name", "befs", "--method", "a-star", "-nf",57 "--flare-name", "foo", "--method", "a-star",58 "-asw", "0.2,0.3,0.5,0,0", "-nf",59 "--flare-name", "bar", "-to", "[01][23467]",60 ])61 # TEST*$compile_flares_plan_ok62 fcs.compile_flares_plan_ok(testname, "Run:500@dfs,Run:300@bar,CP:,Run:1000@befs")63 # 4 items and then the implicit checkpoint.64 # TEST65 fcs.flare_plan_num_items_is(testname, 5);66 # TEST*$flare_plan_item_is_run67 fcs.flare_plan_item_is_run(("%s No. 0" % (testname)), 0, 0, 500);68 # TEST*$flare_plan_item_is_run69 fcs.flare_plan_item_is_run(("%s No. 1" % (testname)), 1, 3, 300);70 # TEST*$flare_plan_item_is_checkpoint71 fcs.flare_plan_item_is_checkpoint(("%s No. 2" % (testname)), 2);72 # TEST*$flare_plan_item_is_run73 fcs.flare_plan_item_is_run(("%s No. 3" % (testname)), 3, 1, 1000);74 # TEST*$flare_plan_item_is_checkpoint75 fcs.flare_plan_item_is_checkpoint(("%s No. 4" % (testname)), 4);76def test_with_checkpoints_and_explicit_checkpoint():77 testname = "With checkpoints with explicit checkpoint at end."78 fcs = FC_Solve()79 # TEST*$input_cmd_line80 fcs.input_cmd_line("Input Flares",81 ["--flare-name", "dfs", "-nf",82 "--flare-name", "befs", "--method", "a-star", "-nf",83 "--flare-name", "foo", "--method", "a-star",84 "-asw", "0.2,0.3,0.5,0,0", "-nf",85 "--flare-name", "bar", "-to", "[01][23467]",86 ])87 # TEST*$compile_flares_plan_ok88 fcs.compile_flares_plan_ok(testname, "Run:500@dfs,Run:300@bar,CP:,Run:1000@befs,CP:")89 # 5 items (without an extra and redundant explicit checkpoint at the end.)90 # TEST91 fcs.flare_plan_num_items_is(testname, 5);92 # TEST*$flare_plan_item_is_run93 fcs.flare_plan_item_is_run(("%s No. 0" % (testname)), 0, 0, 500);94 # TEST*$flare_plan_item_is_run95 fcs.flare_plan_item_is_run(("%s No. 1" % (testname)), 1, 3, 300);96 # TEST*$flare_plan_item_is_checkpoint97 fcs.flare_plan_item_is_checkpoint(("%s No. 2" % (testname)), 2);98 # TEST*$flare_plan_item_is_run99 fcs.flare_plan_item_is_run(("%s No. 3" % (testname)), 3, 1, 1000);100 # TEST*$flare_plan_item_is_checkpoint101 fcs.flare_plan_item_is_checkpoint(("%s No. 4" % (testname)), 4);102def test_with_run_indef():103 testname = "With RunIndef"104 fcs = FC_Solve()105 # TEST*$input_cmd_line106 fcs.input_cmd_line("Input Flares",107 ["--flare-name", "dfs", "-nf",108 "--flare-name", "befs", "--method", "a-star", "-nf",109 "--flare-name", "foo", "--method", "a-star",110 "-asw", "0.2,0.3,0.5,0,0", "-nf",111 "--flare-name", "bar", "-to", "[01][23467]",112 ])113 # TEST*$compile_flares_plan_ok114 fcs.compile_flares_plan_ok(testname, "Run:500@dfs,Run:300@bar,CP:,RunIndef:befs")115 # 5 items (with an extra implicit chechpoint at the end).116 # TEST117 fcs.flare_plan_num_items_is(testname, 5);118 # TEST*$flare_plan_item_is_run119 fcs.flare_plan_item_is_run(("%s No. 0" % (testname)), 0, 0, 500);120 # TEST*$flare_plan_item_is_run121 fcs.flare_plan_item_is_run(("%s No. 1" % (testname)), 1, 3, 300);122 # TEST*$flare_plan_item_is_checkpoint123 fcs.flare_plan_item_is_checkpoint(("%s No. 2" % (testname)), 2);124 # TEST*$flare_plan_item_is_run_indef125 fcs.flare_plan_item_is_run_indef(("%s No. 3" % (testname)), 3, 1);126 # TEST*$flare_plan_item_is_checkpoint127 fcs.flare_plan_item_is_checkpoint(("%s No. 4" % (testname)), 4);128def main():129 test_null_plan()130 test_empty_plan()131 test_two_runs()132 test_with_checkpoints()133 test_with_checkpoints_and_explicit_checkpoint()134 test_with_run_indef()135#----------------------------------------------------------------------136if __name__ == "__main__":...
test_truncate_plan.py
Source:test_truncate_plan.py
...13])14def test_truncate_plan(plan, targets, index):15 """Ensure plan is properly truncated for both types migrations names."""16 assert truncate_plan(targets, plan) == plan[:index]17def test_empty_plan():18 """Ensure function work when plan is empty."""19 assert not truncate_plan([('app1', '0001_initial')], [])20@pytest.mark.parametrize('targets', [21 [('app4', None)],22 [('app1', '0047_magic')],23 [('app1', '0005_fifth'), ('app4', None)],24 [('app1', '0005_fifth'), ('app4', '0047_magic'), ('app3', None)],25])26def test_migration_target_does_not_exist(plan, targets):27 """Ensure ``MigrationNotInPlan`` is raised when target not in plan."""28 with pytest.raises(MigrationNotInPlan):...
parser_test.py
Source:parser_test.py
1import pytest2from crispr.config.parser import parse_config3from crispr.parameter_registry import ParameterRegistry, init_registry4def test_empty_plan():5 plan_source = ""6 with pytest.raises(SystemExit) as e:7 parse_config(plan_source, init_registry(ParameterRegistry()))8 assert e.value.code == 19def test_simple_plan():10 plan_source = """11# simulation plan12title = "example plan"13num_bufs = [i for i in range(5, 100)]14num_nodes = [10, 20, 30, 40, 50]15network_types = ["linear"]16 """17 plan = parse_config(plan_source, ParameterRegistry())18 assert plan["title"] == "example plan"...
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!!