Best Python code snippet using avocado_python
analyser_test.py
Source:analyser_test.py
1from typing import Union2from nepattern import set_unit3from arclet.alconna.analysis.analyser import Analyser4from arclet.alconna import Alconna, Args5def test_filter_out():6 Analyser.filter_out = ["int"]7 ana = Alconna("ana", Args["foo", str])8 assert ana.parse(["ana", 123, "bar"]).matched is True9 assert ana.parse("ana bar").matched is True10 Analyser.filter_out.remove("int")11 assert ana.parse(["ana", 123, "bar"]).matched is False12def test_preprocessor():13 Analyser.preprocessors["float"] = lambda x: int(x)14 ana1 = Alconna("ana1", Args["bar", int])15 assert ana1.parse(["ana1", 123.06]).matched is True16 assert ana1.parse(["ana1", 123.06]).bar == 12317 del Analyser.preprocessors["float"]18 assert ana1.parse(["ana1", 123.06]).matched is False19def test_with_set_unit():...
test_har_parser.py
Source:test_har_parser.py
...20 {"url_regex": r"^https:\/\/www\.forums\.red.*"})21 urls = [e['request']['url'] for e in matched]22 print(urls)23 assert 'https://www.forums.red/images/flairs/down.png' in urls24def test_filter_out():25 parser = Har.Parser(TEST_CAPTURE_FILE)26 reject = [27 {"url_regex": r"^.*\.(png|gif)$"},28 {"url_regex": r"^.*\.(js|css)$"},29 {"url_regex": r"^.*.styles.css.*$"},30 {"url_regex": r'https://manager.smartlook.com/rec/check'},31 {"mimetype_regex": r'text\/css'},32 {"mimetype_regex": r'image\/(png|jpeg)'},33 ]34 matched = parser.filter_out(reject)35 urls = [e['request']['url'] for e in matched]36 print(urls)37 for m in matched:38 url = m['request']['url']...
test_util.py
Source:test_util.py
...21 "b": 20,22 "c": {"ca": 160, "cb": 200},23 }24 assert map_over_leaves(case, sum) == expected25def test_filter_out():26 cases = [27 {"a": 1, "b": 2, "c": {"ca": 30, "cb": "Hello!"}},28 {"a": 17, "b": 18, "c": {"ca": 130, "cb": "Hi!"}},29 ]30 expected = [31 {"a": 1, "b": 2, "c": {"ca": 30}},32 {"a": 17, "b": 18, "c": {"ca": 130}},33 ]34 for case, exp in zip(cases, expected):35 assert filter_out(case, condition=lambda v: isinstance(v, int)) == exp36def test_dice():37 a = {1, 2, 3, 4}38 b = {5, 6, 7, 4}39 assert dice_coef(a, b) == 0.25...
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!!