Best Python code snippet using Kiwi_python
test_labels.py
Source:test_labels.py
...35 ]36 labels = SequenceLabels(labels)37 return labels38class TestClassificationLabels:39 def test_filter_by_name(self, example_classification_data):40 vocabulary = {'A'}41 labels = example_classification_data.filter_by_name(vocabulary)42 labels = labels.dict()43 expected = [44 {'label': 'A'}45 ]46 assert labels == expected47 def test_dont_filter_by_name(self, example_classification_data):48 labels = example_classification_data.filter_by_name()49 assert labels == example_classification_data50 def test_convert_label(self, example_classification_data):51 mapping = {'C': 'D'}52 labels = example_classification_data.replace_label(mapping)53 labels = labels.dict()54 expected = [55 {'label': 'A'},56 {'label': 'B'},57 {'label': 'D'}58 ]59 assert labels == expected60 def test_dont_convert_label(self, example_classification_data):61 labels = example_classification_data.replace_label()62 assert labels == example_classification_data63 def test_merge(self):64 labels = ClassificationLabels([{'label': 'A'}, {'label': 'C'}])65 other = ClassificationLabels([{'label': 'A'}, {'label': 'B'}])66 labels = labels.merge(other)67 expected = [{'label': 'A'}, {'label': 'B'}, {'label': 'C'}]68 actual = sorted(labels.dict(), key=lambda x: x['label'])69 assert actual == expected70class TestSequenceLabels:71 def test_filter_by_name(self, example_sequence_data):72 vocabulary = {'A'}73 labels = example_sequence_data.filter_by_name(vocabulary)74 labels = labels.dict()75 expected = [76 {'label': 'A', 'start_offset': 0, 'end_offset': 1}77 ]78 assert labels == expected79 def test_dont_filter_by_name(self, example_sequence_data):80 labels = example_sequence_data.filter_by_name()81 assert labels == example_sequence_data82 def test_convert_label(self, example_sequence_data):83 mapping = {'C': 'D'}84 labels = example_sequence_data.replace_label(mapping)85 labels = labels.dict()86 expected = [87 {'label': 'A', 'start_offset': 0, 'end_offset': 1},88 {'label': 'B', 'start_offset': 1, 'end_offset': 2},89 {'label': 'D', 'start_offset': 2, 'end_offset': 3}90 ]91 assert labels == expected92 def test_dont_convert_label(self, example_sequence_data):93 labels = example_sequence_data.replace_label()94 assert labels == example_sequence_data95 def test_remove_overlap(self, example_sequence_overlap_data):96 labels = example_sequence_overlap_data.remove_overlapping()97 assert len(labels.dict()) == 198 def test_merge(self):99 labels = SequenceLabels([100 {'label': 'A', 'start_offset': 0, 'end_offset': 1},101 {'label': 'B', 'start_offset': 3, 'end_offset': 5}102 ])103 others = SequenceLabels([104 {'label': 'C', 'start_offset': 1, 'end_offset': 3},105 {'label': 'B', 'start_offset': 1, 'end_offset': 2}106 ])107 labels = labels.merge(others)108 expected = [109 {'label': 'A', 'start_offset': 0, 'end_offset': 1},110 {'label': 'C', 'start_offset': 1, 'end_offset': 3},111 {'label': 'B', 'start_offset': 3, 'end_offset': 5}112 ]113 actual = sorted(labels.dict(), key=lambda x: x['start_offset'])114 assert actual == expected115class TestSeq2seqLabels:116 def test_filter_by_name(self, example_seq2seq_data):117 stop_labels = {'B', 'C', 'D'}118 labels = example_seq2seq_data.filter_by_name(stop_labels)119 assert labels == example_seq2seq_data120 def test_convert_label(self, example_seq2seq_data):121 mapping = {'C': 'D'}122 labels = example_seq2seq_data.replace_label(mapping)123 assert labels == example_seq2seq_data124 def test_merge(self):125 labels = Seq2seqLabels([{'text': 'A'}, {'text': 'C'}])126 other = Seq2seqLabels([{'text': 'A'}, {'text': 'B'}])127 labels = labels.merge(other)128 expected = [{'text': 'A'}, {'text': 'B'}, {'text': 'C'}]129 actual = sorted(labels.dict(), key=lambda x: x['text'])130 assert actual == expected
filter-test.py
Source:filter-test.py
1from time import perf_counter;2def test_filter_by_name():3 usernames: list[str] = ["Pierre", "Thierry", "Aurélie", "Hermine", "Nicolas", "Nicolas", "Clélia", "JF", "Thibaud", "Mathieu", "Samuel"];4 5 start = perf_counter()6 alias_end_by_e: list[str] = [];7 for alias in usernames:8 if (alias.endswith("e")):9 alias_end_by_e.append(alias);10 start = perf_counter();11 alias_end_by_d = [alias for alias in usernames if alias.endswith("e")];12 print(round(perf_counter() - start, 8));13if (__name__ == "__main__"):...
filter_by_name.py
Source:filter_by_name.py
1import allure2@allure.title("ТеÑÑ Ð¿ÑовеÑки ÑилÑÑÑа по имени")3def test_filter_by_name(product):4 product.create_product()5 product.filter()6 with allure.step("ÐоиÑк ÑлеменÑов"):7 item = product.find_element(product.driver, product.tbody_tr_td3)...
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!!