Best Python code snippet using avocado_python
aoc2018_7.py
Source:aoc2018_7.py
...103for requirement, step in ((instruction[5], instruction[-12]) for instruction in data.splitlines()):104 direct_requirements[step] = direct_requirements.setdefault(step, set()) | {requirement}105 direct_requirements.setdefault(requirement, set())106#print(direct_requirements.items())107'''def get_all_requirements(step):108 if not direct_requirements[step]:109 return direct_requirements[step]110 return direct_requirements[step] | {r for requirement in direct_requirements[step] for r in get_all_requirements(requirement)}111 112for step in direct_requirements:113 print(step)114 print(get_all_requirements(step))115 print()116order = sorted(direct_requirements)117order = sorted(order, key = lambda k: len(get_all_requirements(k)))118print(order)119print(len(order))120print(''.join(order))'''121performed = []122steps = set(direct_requirements)123while steps:124 available = {step for step in steps if all(requirement in performed for requirement in direct_requirements[step])}125 next_step = min(sorted(available))126 performed.append(next_step)127 steps.remove(next_step)128print(''.join(performed))129performed2 = []130time = -1131workers = [[None, 0] for _ in range(5)]...
test_requirements.py
Source:test_requirements.py
...14 assert branch.requirements == target215 assert sub_dag.requirements == target216 assert t2.requirements == target217 assert t3.requirements == target218 assert dag.get_all_requirements() == target219 assert t1.get_all_requirements() == target220 assert branch.get_all_requirements() == target221 assert sub_dag.get_all_requirements() == target222 assert t2.get_all_requirements() == target223 assert t3.get_all_requirements() == target224def test_specify_requirements_at_branch_level():25 inputs = Inputs()26 with DAG() as dag:27 t1 = PythonTask(function=print, args=["test t1"])28 with BranchTask(branch_data=inputs.data, parents=t1, requirements=["asdf", "fdsa"]) as branch:29 with DAG() as sub_dag:30 t2 = PythonTask(function=print, args=["test t2"])31 t3 = PythonTask(function=print, args=["test t3"], parents=t2)32 target1 = ["pytailor"]33 target2 = ["asdf", "fdsa", "pytailor"]34 assert dag.requirements == target135 assert t1.requirements == target136 assert branch.requirements == target237 assert sub_dag.requirements == target238 assert t2.requirements == target239 assert t3.requirements == target240 assert dag.get_all_requirements() == target241 assert t1.get_all_requirements() == target142 assert branch.get_all_requirements() == target243 assert sub_dag.get_all_requirements() == target244 assert t2.get_all_requirements() == target245 assert t3.get_all_requirements() == target246def test_specify_requirements_at_sub_dag_level():47 inputs = Inputs()48 with DAG() as dag:49 t1 = PythonTask(function=print, args=["test t1"])50 with BranchTask(branch_data=inputs.data, parents=t1) as branch:51 with DAG(requirements=["asdf", "fdsa"]) as sub_dag:52 t2 = PythonTask(function=print, args=["test t2"])53 t3 = PythonTask(function=print, args=["test t3"], parents=t2)54 target1 = ["pytailor"]55 target2 = ["asdf", "fdsa", "pytailor"]56 assert dag.requirements == target157 assert t1.requirements == target158 assert branch.requirements == target159 assert sub_dag.requirements == target260 assert t2.requirements == target261 assert t3.requirements == target262 assert dag.get_all_requirements() == target263 assert t1.get_all_requirements() == target164 assert branch.get_all_requirements() == target265 assert sub_dag.get_all_requirements() == target266 assert t2.get_all_requirements() == target267 assert t3.get_all_requirements() == target268def test_specify_requirements_at_task_level_1():69 inputs = Inputs()70 with DAG() as dag:71 t1 = PythonTask(function=print, args=["test t1"], requirements=["asdf", "fdsa"])72 with BranchTask(branch_data=inputs.data, parents=t1) as branch:73 with DAG() as sub_dag:74 t2 = PythonTask(function=print, args=["test t2"])75 t3 = PythonTask(function=print, args=["test t3"], parents=t2)76 target1 = ["pytailor"]77 target2 = ["asdf", "fdsa", "pytailor"]78 assert dag.requirements == target179 assert t1.requirements == target280 assert branch.requirements == target181 assert sub_dag.requirements == target182 assert t2.requirements == target183 assert t3.requirements == target184 assert dag.get_all_requirements() == target285 assert t1.get_all_requirements() == target286 assert branch.get_all_requirements() == target187 assert sub_dag.get_all_requirements() == target188 assert t2.get_all_requirements() == target189 assert t3.get_all_requirements() == target190def test_specify_requirements_at_task_level_2():91 inputs = Inputs()92 with DAG() as dag:93 t1 = PythonTask(function=print, args=["test t1"])94 with BranchTask(branch_data=inputs.data, parents=t1) as branch:95 with DAG() as sub_dag:96 t2 = PythonTask(function=print, args=["test t2"], requirements=["asdf", "fdsa"])97 t3 = PythonTask(function=print, args=["test t3"], parents=t2)98 target1 = ["pytailor"]99 target2 = ["asdf", "fdsa", "pytailor"]100 assert dag.requirements == target1101 assert t1.requirements == target1102 assert branch.requirements == target1103 assert sub_dag.requirements == target1104 assert t2.requirements == target2105 assert t3.requirements == target1106 assert dag.get_all_requirements() == target2107 assert t1.get_all_requirements() == target1108 assert branch.get_all_requirements() == target2109 assert sub_dag.get_all_requirements() == target2110 assert t2.get_all_requirements() == target2111 assert t3.get_all_requirements() == target1112def test_specify_requirements_at_task_level_3():113 inputs = Inputs()114 with DAG() as dag:115 t1 = PythonTask(function=print, args=["test t1"])116 with BranchTask(branch_data=inputs.data, parents=t1) as branch:117 with DAG() as sub_dag:118 t2 = PythonTask(function=print, args=["test t2"])119 t3 = PythonTask(120 function=print,121 args=["test t3"],122 parents=t2,123 requirements=["asdf", "fdsa"],124 )125 target1 = ["pytailor"]126 target2 = ["asdf", "fdsa", "pytailor"]127 assert dag.requirements == target1128 assert t1.requirements == target1129 assert branch.requirements == target1130 assert sub_dag.requirements == target1131 assert t2.requirements == target1132 assert t3.requirements == target2133 assert dag.get_all_requirements() == target2134 assert t1.get_all_requirements() == target1135 assert branch.get_all_requirements() == target2136 assert sub_dag.get_all_requirements() == target2137 assert t2.get_all_requirements() == target1...
setup.py
Source:setup.py
...33 if site_regex.search(path):34 site_path = Path(path)35 if site_path:36 yield from get_python_packages(site_path)37def get_all_requirements() -> Iterator[str]:38 package_regex = re.compile("[a-zA-Z\-_]+")39 for line_content in open(PROJECT_DIR / "requirements.txt", "r"):40 pack_name = package_regex.match(line_content)41 if pack_name:42 yield pack_name.group().replace("-", "_")43# æ·»å ä¾èµ44packages: List = []45if platform.system() == "Linux":46 packages.append("uvloop")47requirements_str = "-".join(get_all_requirements())48for pack in get_all_packages():49 if pack in requirements_str:50 packages.append(pack)51build_exe_options = {52 "include_files": ["project_env", "pyproject.toml"],53 "packages": packages,54 "excludes": [],55}56setup(57 name="FastSample",58 version=VERSION,59 description="FastAPI Sample",60 options={"build_exe": build_exe_options},61 executables=[Executable("main.py")],...
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!!