How to use to_list method in localstack

Best Python code snippet using localstack_python

citations_tests.py

Source:citations_tests.py Github

copy

Full Screen

...22 (u'Official Interpretations of § 102.33(c)(2)',23 ['102', '33', 'c', '2', 'Interp'])]:24 citations = internal_citations(text, Label(part='101'))25 self.assertEqual(1, len(citations))26 self.assertEqual(citations[0].label.to_list(), label)27 def test_single_references(self):28 for text, link, label in [29 ("The requirements in paragraph (a)(4)(iii) of",30 'paragraph (a)(4)(iii)', ['102', '6', 'a', '4', 'iii']),31 ("Creditors may comply with paragraphs (a)(6) of this section",32 'paragraphs (a)(6)', ['102', '6', 'a', '6']),33 (u"date in § 1005.20(h)(1) must disclose", u'§ 1005.20(h)(1)',34 ['1005', '20', 'h', '1']),35 ('(a) Solicited issuance. Except as provided in paragraph (b) '36 + 'of this section', 'paragraph (b)', ['102', '6', 'b']),37 ("And Section 222.87(d)(2)(i) says something",38 'Section 222.87(d)(2)(i)', ['222', '87', 'd', '2', 'i']),39 ("More in paragraph 22(a)(4).", "paragraph 22(a)(4)",40 ["102", "22", "a", "4"]),41 ("See comment 32(b)(3) blah blah", 'comment 32(b)(3)',42 ['102', '32', 'b', '3', 'Interp']),43 ("refer to comment 36(a)(2)-3 of thing", 'comment 36(a)(2)-3',44 ['102', '36', 'a', '2', 'Interp', '3']),45 ("See Appendix A-5", "Appendix A-5", ['102', 'A', '5']),46 ("See Appendix A-5(R)", "Appendix A-5(R)", ['102', 'A', '5(R)']),47 ("See comment 3(v)-1.v. Another", "comment 3(v)-1.v",48 ['102', '3', 'v', 'Interp', '1', 'v']),49 ("See the commentary to 3(b)(1)", 'commentary to 3(b)(1)',50 ['102', '3', 'b', '1', 'Interp']),51 ("See comment 3(b)(1)-1.v.", 'comment 3(b)(1)-1.v',52 ['102', '3', 'b', '1', 'Interp', '1', 'v']),53 ("See appendix G, part V.4.D.", 'appendix G, part V.4.D',54 ['102', 'G', 'V', '4', 'D']),55 ("See comment 3-1 for things", 'comment 3-1',56 ['102', '3', 'Interp', '1'])]:57 citations = internal_citations(text, Label(part='102',58 section='6'))59 self.assertEqual(1, len(citations))60 citation = citations[0]61 self.assertEqual(citation.label.to_list(), label)62 self.assertEqual(link, to_full_text(citation, text))63 def test_single_reference_false_positives(self):64 text = "See the commentary. (a) child paragraph"65 citations = internal_citations(66 text, Label(part='102', section='1'))67 self.assertEqual(0, len(citations))68 def test_section_ref_in_appendix(self):69 text = u"""(a) Something something § 1005.7(b)(1)."""70 citations = internal_citations(71 text, Label(part='1005', appendix='A', appendix_section='2',72 p1='a'))73 self.assertEqual(citations[0].label.to_list(),74 ['1005', '7', 'b', '1'])75 def test_multiple_matches(self):76 text = "Please see A-5 and Q-2(r) and Z-12(g)(2)(ii) then more text"77 citations = internal_citations(text, Label(part='102', section='1'))78 self.assertEqual(3, len(citations))79 citation = citations[0]80 self.assertEqual(citation.label.to_list(), ['102', 'A', '5'])81 self.assertEqual(to_text(citation, text), 'A-5')82 citation = citations[1]83 self.assertEqual(citation.label.to_list(), ['102', 'Q', '2(r)'])84 self.assertEqual(to_text(citation, text), 'Q-2(r)')85 citation = citations[2]86 self.assertEqual(citation.label.to_list(),87 ['102', 'Z', '12(g)(2)(ii)'])88 self.assertEqual(to_text(citation, text), 'Z-12(g)(2)(ii)')89 text = u"Appendices G and H—Yadda yadda"90 citations = internal_citations(text, Label(part='102'))91 self.assertEqual(2, len(citations))92 citG, citH = citations93 self.assertEqual(citG.label.to_list(), ['102', 'G'])94 self.assertEqual(citH.label.to_list(), ['102', 'H'])95 def test_single_match_multiple_paragraphs1(self):96 text = "the requirements of paragraphs (c)(3), (d)(2), (e)(1), "97 text += "(e)(3), and (f) of this section"98 citations = internal_citations(text, Label(part='222', section='5'))99 self.assertEqual(5, len(citations))100 citation = citations[0]101 self.assertEqual(['222', '5', 'c', '3'], citation.label.to_list())102 self.assertEqual(to_text(citation, text), '(c)(3)')103 citation = citations[1]104 self.assertEqual(['222', '5', 'd', '2'], citation.label.to_list())105 self.assertEqual(to_text(citation, text), '(d)(2)')106 citation = citations[2]107 self.assertEqual(['222', '5', 'e', '1'], citation.label.to_list())108 self.assertEqual(to_text(citation, text), '(e)(1)')109 citation = citations[3]110 self.assertEqual(['222', '5', 'e', '3'], citation.label.to_list())111 self.assertEqual(to_text(citation, text), '(e)(3)')112 citation = citations[4]113 self.assertEqual(['222', '5', 'f'], citation.label.to_list())114 self.assertEqual(to_text(citation, text), '(f)')115 text = "set forth in paragraphs (b)(1) or (b)(2)"116 citations = internal_citations(text, Label(part='222', section='5'))117 self.assertEqual(2, len(citations))118 citation = citations[0]119 self.assertEqual(['222', '5', 'b', '1'], citation.label.to_list())120 self.assertEqual(to_text(citation, text), '(b)(1)')121 citation = citations[1]122 self.assertEqual(['222', '5', 'b', '2'], citation.label.to_list())123 self.assertEqual(to_text(citation, text), '(b)(2)')124 text = 'paragraphs (c)(1) and (2) of this section'125 citations = internal_citations(text, Label(part='222', section='5'))126 self.assertEqual(2, len(citations))127 citation = citations[0]128 self.assertEqual(['222', '5', 'c', '1'], citation.label.to_list())129 self.assertEqual(to_text(citation, text), '(c)(1)')130 citation = citations[1]131 self.assertEqual(['222', '5', 'c', '2'], citation.label.to_list())132 self.assertEqual(to_text(citation, text), '(2)')133 text = 'paragraphs (b)(1)(ii) and (iii)'134 citations = internal_citations(text, Label(part='222', section='5'))135 self.assertEqual(2, len(citations))136 citation = citations[0]137 self.assertEqual(['222', '5', 'b', '1', 'ii'],138 citation.label.to_list())139 self.assertEqual(to_text(citation, text), '(b)(1)(ii)')140 citation = citations[1]141 self.assertEqual(['222', '5', 'b', '1', 'iii'],142 citation.label.to_list())143 self.assertEqual(to_text(citation, text), '(iii)')144 text = 'see paragraphs (z)(9)(vi)(A) and (D)'145 citations = internal_citations(text, Label(part='222', section='5'))146 self.assertEqual(2, len(citations))147 citation = citations[0]148 self.assertEqual(['222', '5', 'z', '9', 'vi', 'A'],149 citation.label.to_list())150 self.assertEqual(to_text(citation, text), '(z)(9)(vi)(A)')151 citation = citations[1]152 self.assertEqual(['222', '5', 'z', '9', 'vi', 'D'],153 citation.label.to_list())154 self.assertEqual(to_text(citation, text), '(D)')155 text = 'see 32(d)(6) and (7) Content content'156 citations = internal_citations(text, Label(part='222'))157 self.assertEqual(2, len(citations))158 citation = citations[0]159 self.assertEqual(['222', '32', 'd', '6'], citation.label.to_list())160 self.assertEqual(to_text(citation, text), '32(d)(6)')161 citation = citations[1]162 self.assertEqual(['222', '32', 'd', '7'], citation.label.to_list())163 self.assertEqual(to_text(citation, text), '(7)')164 def test_single_match_multiple_paragraphs2(self):165 text = u'§ 1005.10(a) and (d)'166 citations = internal_citations(text, Label(part='222', section='5'))167 self.assertEqual(2, len(citations))168 citation = citations[0]169 self.assertEqual(['1005', '10', 'a'], citation.label.to_list())170 self.assertEqual(to_text(citation, text), '1005.10(a)')171 citation = citations[1]172 self.assertEqual(['1005', '10', 'd'], citation.label.to_list())173 self.assertEqual(to_text(citation, text), '(d)')174 text = u'§ 1005.7(b)(1), (2) and (3)'175 citations = internal_citations(text, Label(part='222', section='5'))176 self.assertEqual(3, len(citations))177 self.assertEqual(['1005', '7', 'b', '1'],178 citations[0].label.to_list())179 self.assertEqual(['1005', '7', 'b', '2'],180 citations[1].label.to_list())181 self.assertEqual(['1005', '7', 'b', '3'],182 citations[2].label.to_list())183 text = u'§ 1005.15(d)(1)(i) and (ii)'184 citations = internal_citations(text, Label(part='222', section='5'))185 self.assertEqual(2, len(citations))186 self.assertEqual(['1005', '15', 'd', '1', 'i'],187 citations[0].label.to_list())188 self.assertEqual(['1005', '15', 'd', '1', 'ii'],189 citations[1].label.to_list())190 text = u'§ 1005.9(a)(5) (i), (ii), or (iii)'191 citations = internal_citations(text, Label(part='222', section='5'))192 self.assertEqual(3, len(citations))193 self.assertEqual(['1005', '9', 'a', '5', 'i'],194 citations[0].label.to_list())195 self.assertEqual(['1005', '9', 'a', '5', 'ii'],196 citations[1].label.to_list())197 self.assertEqual(['1005', '9', 'a', '5', 'iii'],198 citations[2].label.to_list())199 text = u'§ 1005.11(a)(1)(vi) or (vii).'200 citations = internal_citations(text, Label(part='222', section='5'))201 self.assertEqual(2, len(citations))202 self.assertEqual(['1005', '11', 'a', '1', 'vi'],203 citations[0].label.to_list())204 self.assertEqual(['1005', '11', 'a', '1', 'vii'],205 citations[1].label.to_list())206 text = u'§§ 1005.3(b)(2) and (3), 1005.10(b), (d), and (e), 1005.13, '207 text += 'and 1005.20'208 citations = internal_citations(text, Label(part='222', section='5'))209 self.assertEqual(7, len(citations))210 text = 'Sections 1005.3, .4, and .5'211 citations = internal_citations(text, Label(part='222', section='5'))212 self.assertEqual(3, len(citations))213 self.assertEqual(['1005', '3'], citations[0].label.to_list())214 self.assertEqual(['1005', '4'], citations[1].label.to_list())215 self.assertEqual(['1005', '5'], citations[2].label.to_list())216 def test_single_match_multiple_paragraphs4(self):217 text = "Listing sections 11.55(d) and 321.11 (h)(4)"218 citations = internal_citations(text, Label(part='222', section='5'))219 self.assertEqual(2, len(citations))220 citation = citations[0]221 self.assertEqual(['11', '55', 'd'], citation.label.to_list())222 self.assertEqual(to_text(citation, text), '11.55(d)')223 citation = citations[1]224 self.assertEqual(['321', '11', 'h', '4'], citation.label.to_list())225 self.assertEqual(to_text(citation, text), '321.11 (h)(4)')226 def test_single_match_multiple_paragraphs5(self):227 text = "See, e.g., comments 31(b)(1)(iv)-1 and 31(b)(1)(vi)-1"228 citations = internal_citations(text, Label(part='222', section='5'))229 self.assertEqual(2, len(citations))230 citation = citations[0]231 self.assertEqual(['222', '31', 'b', '1', 'iv', 'Interp', '1'],232 citation.label.to_list())233 self.assertEqual(to_text(citation, text), '31(b)(1)(iv)-1')234 citation = citations[1]235 self.assertEqual(['222', '31', 'b', '1', 'vi', 'Interp', '1'],236 citation.label.to_list())237 self.assertEqual(to_text(citation, text), '31(b)(1)(vi)-1')238 def test_single_match_multiple_paragraphs6(self):239 text = "comments 5(b)(3)-1 through -3"240 citations = internal_citations(text, Label(part='100', section='5'))241 citation = citations[0]242 self.assertEqual(2, len(citations))243 self.assertEqual(['100', '5', 'b', '3', 'Interp', '1'],244 citation.label.to_list())245 self.assertEqual(to_text(citation, text), '5(b)(3)-1')246 citation = citations[1]247 self.assertEqual(['100', '5', 'b', '3', 'Interp', '3'],248 citation.label.to_list())249 self.assertEqual(to_text(citation, text), '-3')250 def test_single_match_multiple_paragraphs7(self):251 text = "comments 5(b)(3)-1, 5(b)(3)-3, or 5(d)-1 through -3."252 citations = internal_citations(text, Label(part='100', section='5'))253 citation = citations[0]254 self.assertEqual(4, len(citations))255 self.assertEqual(['100', '5', 'b', '3', 'Interp', '1'],256 citation.label.to_list())257 self.assertEqual(to_text(citation, text), '5(b)(3)-1')258 citation = citations[1]259 self.assertEqual(['100', '5', 'b', '3', 'Interp', '3'],260 citation.label.to_list())261 self.assertEqual(to_text(citation, text), '5(b)(3)-3')262 citation = citations[2]263 self.assertEqual(['100', '5', 'd', 'Interp', '1'],264 citation.label.to_list())265 self.assertEqual(to_text(citation, text), '5(d)-1')266 citation = citations[3]267 self.assertEqual(['100', '5', 'd', 'Interp', '3'],268 citation.label.to_list())269 self.assertEqual(to_text(citation, text), '-3')270 def test_single_match_multiple_paragraphs8(self):271 text = u'§ 105.2(a)(1)-(3)'272 citations = internal_citations(text, Label(part='100', section='2'))273 self.assertEqual(2, len(citations))274 def test_single_match_multiple_p_false_positives(self):275 text = "-9 text and stuff -2. (b) new thing"276 citations = internal_citations(text, Label(part='100', section='4'))277 self.assertEqual(0, len(citations))278class CitationsLabelTest(TestCase):279 def test_using_default_schema(self):280 label = Label(part='111')281 self.assertTrue(label.using_default_schema)282 label = Label(part='111', p1='b')283 self.assertTrue(label.using_default_schema)284 label = Label(part='111', c2='r')285 self.assertTrue(label.using_default_schema)286 label = Label(part='111', section='21')287 self.assertFalse(label.using_default_schema)288 label = Label(part='111', appendix='B3')289 self.assertFalse(label.using_default_schema)290 label = Label(part='111', appendix_section='3')291 self.assertFalse(label.using_default_schema)292 def test_determine_schema(self):293 self.assertEqual(Label.app_sect_schema,294 Label.determine_schema({'appendix_section': '1'}))295 self.assertEqual(Label.app_schema,296 Label.determine_schema({'appendix': 'A'}))297 self.assertEqual(Label.sect_schema,298 Label.determine_schema({'section': '12'}))299 self.assertEqual(None, Label.determine_schema({}))300 def test_to_list(self):301 label = Label(part='222', section='11', p1='c', p2='2')302 self.assertEqual(['222', '11', 'c', '2'], label.to_list())303 label = Label(part='222', p1='d', appendix='R3')304 self.assertEqual(['222', 'R3', 'd'], label.to_list())305 label = Label(part='222', p1='d', appendix='R', appendix_section='4')306 self.assertEqual(['222', 'R', '4', 'd'], label.to_list())307 def test_copy(self):308 label = Label(part='222', section='11', p1='c', p2='2')309 label = label.copy(p3='ii')310 self.assertEqual(['222', '11', 'c', '2', 'ii'], label.to_list())311 label = label.copy(p2='4', p3='iv')312 self.assertEqual(['222', '11', 'c', '4', 'iv'], label.to_list())313 label = label.copy(section='12', p1='d')314 self.assertEqual(['222', '12', 'd'], label.to_list())315 label = label.copy(appendix='D', appendix_section='4')316 self.assertEqual(['222', 'D', '4'], label.to_list())317 label = label.copy(p1='c', p2='3')318 self.assertEqual(['222', 'D', '4', 'c', '3'], label.to_list())319 def test_from_node(self):320 for lst, typ in [(['111'], Node.REGTEXT),321 (['111', '31', 'a', '3'], Node.REGTEXT),322 (['111', 'A', 'b'], Node.APPENDIX),323 (['111', 'A', '4', 'a'], Node.APPENDIX),324 (['111', '21', 'Interp'], Node.INTERP),325 (['111', '21', 'Interp', '1'], Node.INTERP),326 (['111', '21', 'r', 'Interp'], Node.INTERP),327 (['111', '21', 'r', 'Interp', '2'], Node.INTERP),328 (['111', 'G', 'Interp'], Node.INTERP),329 (['111', 'G3', 'r', 'Interp'], Node.INTERP),330 (['111', 'G', '2', 'Interp'], Node.INTERP),331 (['111', 'G3', 'r', 'Interp', '3'], Node.INTERP),332 (['111', 'G', '2', 'Interp', '5'], Node.INTERP),333 (['111', 'Subpart', 'A'], Node.SUBPART),334 (['111', 'Subpart'], Node.EMPTYPART)]:335 n = Node(label=lst, node_type=typ)336 self.assertEqual(Label.from_node(n).to_list(), lst)337 def test_label_representation(self):338 l = Label(part='105', section='3')...

Full Screen

Full Screen

linked_list_practice.py

Source:linked_list_practice.py Github

copy

Full Screen

...79 while node:80 size_llist += 181 node = node.next82 return size_llist83 def to_list(self):84 out = []85 node = self.head86 while node:87 out.append(node.value)88 node = node.next89 return out90# # Test your implementation here91# Test prepend92linked_list = LinkedList()93linked_list.prepend(1)94assert linked_list.to_list() == [1], f"list contents: {linked_list.to_list()}"95linked_list.append(3)96linked_list.prepend(2)97assert linked_list.to_list() == [2, 1, 3], f"list contents: {linked_list.to_list()}"98# Test append99linked_list = LinkedList()100linked_list.append(1)101assert linked_list.to_list() == [1], f"list contents: {linked_list.to_list()}"102linked_list.append(3)103assert linked_list.to_list() == [1, 3], f"list contents: {linked_list.to_list()}"104# Test search105linked_list.prepend(2)106linked_list.prepend(1)107linked_list.append(4)108linked_list.append(3)109assert linked_list.search(1).value == 1, f"list contents: {linked_list.to_list()}"110assert linked_list.search(4).value == 4, f"list contents: {linked_list.to_list()}"111# Test remove112linked_list.remove(1)113assert linked_list.to_list() == [2, 1, 3, 4, 3], f"list contents: {linked_list.to_list()}"114linked_list.remove(3)115assert linked_list.to_list() == [2, 1, 4, 3], f"list contents: {linked_list.to_list()}"116linked_list.remove(3)117assert linked_list.to_list() == [2, 1, 4], f"list contents: {linked_list.to_list()}"118# Test pop119value = linked_list.pop()120assert value == 2, f"list contents: {linked_list.to_list()}"121assert linked_list.head.value == 1, f"list contents: {linked_list.to_list()}"122# Test insert123linked_list.insert(5, 0)124assert linked_list.to_list() == [5, 1, 4], f"list contents: {linked_list.to_list()}"125linked_list.insert(2, 1)126assert linked_list.to_list() == [5, 2, 1, 4], f"list contents: {linked_list.to_list()}"127linked_list.insert(3, 6)128assert linked_list.to_list() == [5, 2, 1, 4, 3], f"list contents: {linked_list.to_list()}"129# Test size...

Full Screen

Full Screen

LinkedListTests.py

Source:LinkedListTests.py Github

copy

Full Screen

...14 linked_list.append(3)15 linked_list.append(2)16 linked_list.append(-1)17 linked_list.append(0.2)18 print ("Pass" if (linked_list.to_list() == [3, 2, -1, 0.2]) else "Fail")19test_linked_list_to_python_list()20def test_comprehensive():21 # Test prepend22 linked_list = LinkedList()23 linked_list.prepend(1)24 assert linked_list.to_list() == [1], f"list contents: {linked_list.to_list()}"25 linked_list.append(3)26 linked_list.prepend(2)27 assert linked_list.to_list() == [2, 1, 3], f"list contents: {linked_list.to_list()}"28 # Test append29 linked_list = LinkedList()30 linked_list.append(1)31 assert linked_list.to_list() == [1], f"list contents: {linked_list.to_list()}"32 linked_list.append(3)33 assert linked_list.to_list() == [1, 3], f"list contents: {linked_list.to_list()}"34 # Test search35 linked_list.prepend(2)36 linked_list.prepend(1)37 linked_list.append(4)38 linked_list.append(3)39 assert linked_list.search(1).value == 1, f"list contents: {linked_list.to_list()}"40 assert linked_list.search(4).value == 4, f"list contents: {linked_list.to_list()}"41 # Test remove42 linked_list.remove(1)43 assert linked_list.to_list() == [2, 1, 3, 4, 3], f"list contents: {linked_list.to_list()}"44 linked_list.remove(3)45 assert linked_list.to_list() == [2, 1, 4, 3], f"list contents: {linked_list.to_list()}"46 linked_list.remove(3)47 assert linked_list.to_list() == [2, 1, 4], f"list contents: {linked_list.to_list()}"48 # Test pop49 value = linked_list.pop()50 assert value == 2, f"list contents: {linked_list.to_list()}"51 assert linked_list.head.value == 1, f"list contents: {linked_list.to_list()}"52 # Test insert53 linked_list.insert(5, 0)54 assert linked_list.to_list() == [5, 1, 4], f"list contents: {linked_list.to_list()}"55 linked_list.insert(2, 1)56 assert linked_list.to_list() == [5, 2, 1, 4], f"list contents: {linked_list.to_list()}"57 linked_list.insert(3, 6)58 assert linked_list.to_list() == [5, 2, 1, 4, 3], f"list contents: {linked_list.to_list()}"59 # Test size60 assert linked_list.size() == 5, f"list contents: {linked_list.to_list()}"61test_comprehensive()62def test_ls_reversed():63 llist = LinkedList()64 for value in [4,2,5,1,-3,0]:65 llist.append(value)66 flipped = llist.reversed()67 is_correct = list(flipped) == list([0,-3,1,5,2,4]) and list(llist) == list(flipped.reversed())68 print("Pass" if is_correct else "Fail")...

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