How to use shortDescription method in tappy

Best Python code snippet using tappy_python

testparsing.py

Source:testparsing.py Github

copy

Full Screen

...28 # Deleting directory29 shutil.rmtree(testpath, ignore_errors=True) # paranoid30 return31class MoreaParsingTestCase(MoreaTestCase):32 def shortDescription(self):33 return ""34class MoreaTestAcceptingValidFiles(MoreaParsingTestCase):35 def shortDescription(self):36 return super(MoreaTestAcceptingValidFiles, self).shortDescription() + "accepting valid files, "37 def runMoreaTest(self, content):38 try:39 MoreaFile(write_string_to_testfile("test.md", content), warnings=False, parse_comments=True)40 except CustomException as e:41 self.fail(42 " Cannot acquire content due to the following error:\n" +43 yellow(offset_string(str(e), 10)) + "\n\n" + offset_string(red(content), 10))44 self.assertTrue(True)45 return46class MoreaTestAcceptingValidFilesNoComments(MoreaTestAcceptingValidFiles):47 def shortDescription(self):48 return super(MoreaTestAcceptingValidFilesNoComments, self).shortDescription() + "no comments, "49 def runMoreaTest(self, content):50 super(MoreaTestAcceptingValidFilesNoComments, self).runMoreaTest(content)51# noinspection PyPep8Naming,PyPep8Naming52class MoreaTestAcceptingValidFilesWithNoComments_Test_1(MoreaTestAcceptingValidFilesNoComments):53 def shortDescription(self):54 return super(MoreaTestAcceptingValidFilesWithNoComments_Test_1, self).shortDescription() + "minimal file."55 def runTest(self):56 content = "---\n" \57 "title: ok\n" \58 "---\n"59 super(MoreaTestAcceptingValidFilesWithNoComments_Test_1, self).runMoreaTest(content)60# noinspection PyPep8Naming,PyPep8Naming61class MoreaTestAcceptingValidFilesWithNoComments_Test_2(MoreaTestAcceptingValidFilesNoComments):62 def shortDescription(self):63 return super(MoreaTestAcceptingValidFilesWithNoComments_Test_2, self).shortDescription() + "full-fledged file."64 def runTest(self):65 content = "---\n" \66 "title: \"doubly quoted\"\n" \67 "morea_summary: some long string\n" \68 " that spans multiple\n" \69 " lines.\n" \70 "morea_start_date: \"some long doubly\n" \71 " quoted string\"\n" \72 "published: true\n" \73 "morea_readings:\n" \74 " - item1\n" \75 " - item2\n" \76 " - crap\n" \77 "morea_labels:\n" \78 "- foo1\n" \79 "- foo2\n" \80 "---\n" \81 "Some content\n"82 super(MoreaTestAcceptingValidFilesWithNoComments_Test_2, self).runMoreaTest(content)83# noinspection PyPep8Naming,PyPep8Naming84class MoreaTestAcceptingValidFilesWithNoComments_Test_3(MoreaTestAcceptingValidFilesNoComments):85 def shortDescription(self):86 return super(MoreaTestAcceptingValidFilesWithNoComments_Test_3, self).shortDescription() + "unicode support."87 def runTest(self):88 content = u'---\ntitle: \" a ≥ 1 and b quoted\"\n' \89 u'morea_summary: a ≥ 1 and bing\n' \90 u' that a ≥ 1 and b multiple\n' \91 u' lines.\n' \92 u'morea_start_date: \"some a ≥ 1 and b doubly\n' \93 u' quoted string\"\n' \94 u'published: true\n' \95 u'morea_labels:\n' \96 u' - a ≥ 1 and b\n' \97 u' - item2\n' \98 u' - a ≥ 1 and b\n' \99 u'morea_readings:\n' \100 u'- a ≥ 1 and b\n' \101 u'- foo2\n' \102 u'---\n' \103 u' a ≥ 1 and b content\n'104 super(MoreaTestAcceptingValidFilesWithNoComments_Test_3, self).runMoreaTest(content)105class MoreaTestRejectingInvalidFiles(MoreaParsingTestCase):106 def shortDescription(self):107 return super(MoreaTestRejectingInvalidFiles, self).shortDescription() + "rejecting invalid files, "108 def runMoreaTest(self, content):109 try:110 MoreaFile(write_string_to_testfile("test.md", content), warnings=False, parse_comments=True)111 except CustomException:112 self.assertTrue(True)113 return114 self.fail(" Failed to detect error for:\n\n" + offset_string(red(content), 10))115class MoreaTestRejectingInvalidFilesWithNoComments(MoreaTestRejectingInvalidFiles):116 def shortDescription(self):117 return super(MoreaTestRejectingInvalidFilesWithNoComments, self).shortDescription() + "no comments, "118# noinspection PyPep8Naming,PyPep8Naming119class MoreaTestRejectingInvalidFilesWithNoComments_Test_1(MoreaTestRejectingInvalidFilesWithNoComments):120 def shortDescription(self):121 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_1, self).shortDescription() + "empty file."122 def runTest(self):123 content = ""124 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_1, self).runMoreaTest(content)125# noinspection PyPep8Naming,PyPep8Naming126class MoreaTestRejectingInvalidFilesWithNoComments_Test_2(MoreaTestRejectingInvalidFilesWithNoComments):127 def shortDescription(self):128 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_2, self).shortDescription() + "one new line."129 def runTest(self):130 content = "\n"131 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_2, self).runMoreaTest(content)132# noinspection PyPep8Naming,PyPep8Naming133class MoreaTestRejectingInvalidFilesWithNoComments_Test_3(MoreaTestRejectingInvalidFilesWithNoComments):134 def shortDescription(self):135 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_3, self).shortDescription() + "some strings."136 def runTest(self):137 content = "hello\n" \138 "bye\n"139 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_3, self).runMoreaTest(content)140# noinspection PyPep8Naming,PyPep8Naming141class MoreaTestRejectingInvalidFilesWithNoComments_Test_4(MoreaTestRejectingInvalidFilesWithNoComments):142 def shortDescription(self):143 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_4, self).shortDescription() + "wrong delimiter."144 def runTest(self):145 content = "--\n" \146 "title: \"doubly quoted\"\n" \147 "---\n" \148 "Some random content\n"149 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_4, self).runMoreaTest(content)150# noinspection PyPep8Naming,PyPep8Naming151class MoreaTestRejectingInvalidFilesWithNoComments_Test_5(MoreaTestRejectingInvalidFilesWithNoComments):152 def shortDescription(self):153 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_5, self).shortDescription() + "empty content."154 def runTest(self):155 content = "---\n" \156 "---\n"157 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_5, self).runMoreaTest(content)158# noinspection PyPep8Naming,PyPep8Naming159class MoreaTestRejectingInvalidFilesWithNoComments_Test_6(MoreaTestRejectingInvalidFilesWithNoComments):160 def shortDescription(self):161 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_6,162 self).shortDescription() + "YAML as a sentence."163 def runTest(self):164 content = "---\n" \165 "some sentence\n" \166 "---\n" \167 "some content\n"168 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_6, self).runMoreaTest(content)169# noinspection PyPep8Naming,PyPep8Naming170class MoreaTestRejectingInvalidFilesWithNoComments_Test_7(MoreaTestRejectingInvalidFilesWithNoComments):171 def shortDescription(self):172 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_7, self).shortDescription() + "broken line."173 def runTest(self):174 content = "---\n" \175 "title: line that\n" \176 "is not indented" \177 "---\n"178 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_7, self).runMoreaTest(content)179# noinspection PyPep8Naming,PyPep8Naming180class MoreaTestRejectingInvalidFilesWithNoComments_Test_8(MoreaTestRejectingInvalidFilesWithNoComments):181 def shortDescription(self):182 return super(MoreaTestRejectingInvalidFilesWithNoComments_Test_8, self).shortDescription() + "duplicate entry."183 def runTest(self):184 content = "---\n" \185 "title: title1\n" \186 "title: title2\n" \187 "---\n"188 super(MoreaTestRejectingInvalidFilesWithNoComments_Test_8, self).runMoreaTest(content)189class MoreaTestParsingValidFiles(MoreaParsingTestCase):190 def shortDescription(self):191 return super(MoreaTestParsingValidFiles, self).shortDescription() + "parsing valid files, "192 def runMoreaTest(self, content, parsetree):193 try:194 # print "CONTENT = ",content195 f = MoreaFile(write_string_to_testfile("test.md", content), warnings=False, parse_comments=True)196 # print "\nFLATTENED===>", flattened_property_list(f.property_list), "\n"197 # print "\nTEST===>", contents[index][1], "\n"198 self.assertEqual(cmp(parsetree, flattened_property_list(f.property_list)), 0,199 " Incorrect parse tree for:\n\n" + offset_string(200 red(content), 10) + offset_string(201 red("PARSED:\n" + str(flattened_property_list(f.property_list))) + "\n\n" +202 red("EXPECTED:\n" + str(parsetree)), 10) + "\n")203 return204 except CustomException as e:205 self.fail(206 " Cannot acquire content due to the following error:\n" + yellow(207 offset_string(str(e), 10)) + "\n\n" + offset_string(red(content), 10))208class MoreaTestParsingValidFilesWithNoComments(MoreaTestParsingValidFiles):209 def shortDescription(self):210 return super(MoreaTestParsingValidFilesWithNoComments, self).shortDescription() + "no comments, "211 def runMoreaTest(self, content, parsetree):212 super(MoreaTestParsingValidFilesWithNoComments, self).runMoreaTest(content, parsetree)213# noinspection PyPep8Naming,PyPep8Naming214class MoreaTestParsingValidFilesWithNoComments_Test_1(MoreaTestParsingValidFilesWithNoComments):215 def shortDescription(self):216 return super(MoreaTestParsingValidFilesWithNoComments_Test_1, self).shortDescription() + "full file."217 def runTest(self):218 content = "---\n" \219 "morea_id: ok\n" \220 "title: wir\n" \221 " - tanzen\n" \222 "morea_labels:\n" \223 " - hello1\n" \224 " - hello2\n" \225 "morea_readings:\n" \226 " - hello1\n" \227 "---\n"228 parsetree = {"morea_id": [[False, (False, "ok")]],229 "morea_labels": [[False, [(False, "hello1"), (False, "hello2")]]],230 "morea_readings": [[False, [(False, "hello1")]]],231 "title": [[False, (False, "wir - tanzen")]],232 }233 super(MoreaTestParsingValidFilesWithNoComments_Test_1, self).runMoreaTest(content, parsetree)234# noinspection PyPep8Naming,PyPep8Naming235class MoreaTestParsingValidFilesWithNoComments_Test_2(MoreaTestParsingValidFilesWithNoComments):236 def shortDescription(self):237 return super(MoreaTestParsingValidFilesWithNoComments_Test_2, self).shortDescription() + "multi-line string."238 def runTest(self):239 content = "---\n" \240 "title: wir\n" \241 "\n\n\n" \242 " - tanzen\n" \243 "---\n"244 parsetree = {"title": [[False, (False, "wir\n\n\n- tanzen")]]245 }246 super(MoreaTestParsingValidFilesWithNoComments_Test_2, self).runMoreaTest(content, parsetree)247# noinspection PyPep8Naming,PyPep8Naming248class MoreaTestParsingValidFilesWithNoComments_Test_3(MoreaTestParsingValidFilesWithNoComments):249 def shortDescription(self):250 return super(MoreaTestParsingValidFilesWithNoComments_Test_3, self).shortDescription() + "unicode."251 def runTest(self):252 content = "---\n" \253 "morea_summary: a ≥ 1\n" \254 "---\n"255 parsetree = {"morea_summary": [[False, (False, u"a \u2265 1")]]256 }257 super(MoreaTestParsingValidFilesWithNoComments_Test_3, self).runMoreaTest(content, parsetree)258# noinspection PyPep8Naming,PyPep8Naming259class MoreaTestParsingValidFilesWithNoComments_Test_4(MoreaTestParsingValidFilesWithNoComments):260 def shortDescription(self):261 return super(MoreaTestParsingValidFilesWithNoComments_Test_4, self).shortDescription() + "multi-line with #'s."262 def runTest(self):263 content = "---\n" \264 "title: \"something \n" \265 " # this hash is fine\n" \266 "end of string\"\n" \267 "---\n"268 parsetree = {"title": [[False, (False, "something # this hash is fine end of string")]]269 }270 super(MoreaTestParsingValidFilesWithNoComments_Test_4, self).runMoreaTest(content, parsetree)271# noinspection PyPep8Naming,PyPep8Naming272class MoreaTestParsingValidFilesWithNoComments_Test_5(MoreaTestParsingValidFilesWithNoComments):273 def shortDescription(self):274 return super(MoreaTestParsingValidFilesWithNoComments_Test_5,275 self).shortDescription() + "multi-line with #'s #2."276 def runTest(self):277 content = "---\n" \278 "title: \"something \n" \279 " # this hash is fine\n" \280 "# and so is this one # and this one\n" \281 "end of string\"\n" \282 "---\n"283 parsetree = {"title": [284 [False, (False, "something # this hash is fine # and so is this one # and this one end of string")]]285 }286 super(MoreaTestParsingValidFilesWithNoComments_Test_5, self).runMoreaTest(content, parsetree)287class MoreaTestParsingValidFilesWithComments(MoreaTestParsingValidFiles):288 def shortDescription(self):289 return super(MoreaTestParsingValidFilesWithComments, self).shortDescription() + "comments, "290 def runMoreaTest(self, content, parsetree):291 super(MoreaTestParsingValidFilesWithComments, self).runMoreaTest(content, parsetree)292# noinspection PyPep8Naming,PyPep8Naming293class MoreaTestParsingValidFilesWithComments_Test_1(MoreaTestParsingValidFilesWithComments):294 def shortDescription(self):295 return super(MoreaTestParsingValidFilesWithComments_Test_1, self).shortDescription() + "all commented out."296 def runTest(self):297 content = "---\n" \298 "#morea_id: ok\n" \299 "---\n\n"300 parsetree = {"morea_id": [[True, (True, "ok")]]301 }302 super(MoreaTestParsingValidFilesWithComments_Test_1, self).runMoreaTest(content, parsetree)303# noinspection PyPep8Naming,PyPep8Naming304class MoreaTestParsingValidFilesWithComments_Test_2(MoreaTestParsingValidFilesWithComments):305 def shortDescription(self):306 return super(MoreaTestParsingValidFilesWithComments_Test_2,307 self).shortDescription() + "multiline, all commented out."308 def runTest(self):309 content = "---\n" \310 "#title: ok\n" \311 "# something else\n" \312 "# another thing\n" \313 "---\n\n"314 parsetree = {"title": [[True, (True, "ok something else another thing")]]315 }316 super(MoreaTestParsingValidFilesWithComments_Test_2, self).runMoreaTest(content, parsetree)317# noinspection PyPep8Naming,PyPep8Naming318class MoreaTestParsingValidFilesWithComments_Test_3(MoreaTestParsingValidFilesWithComments):319 def shortDescription(self):320 return super(MoreaTestParsingValidFilesWithComments_Test_3,321 self).shortDescription() + "multiline, all commented out #2."322 def runTest(self):323 content = "---\n" \324 "#title:\n" \325 "# some string\n" \326 "# something else\n" \327 "# another thing\n" \328 "---\n\n"329 parsetree = {"title": [[True, (True, "some string something else another thing")]]330 }331 super(MoreaTestParsingValidFilesWithComments_Test_3, self).runMoreaTest(content, parsetree)332# noinspection PyPep8Naming,PyPep8Naming333class MoreaTestParsingValidFilesWithComments_Test_4(MoreaTestParsingValidFilesWithComments):334 def shortDescription(self):335 return super(MoreaTestParsingValidFilesWithComments_Test_4,336 self).shortDescription() + "commented-out list items."337 def runTest(self):338 content = "---\n" \339 "title: something \n" \340 "morea_readings: \n" \341 " - item1\n" \342 " #- item2 # some comment\n" \343 " # # # # # # # # # #- item3\n" \344 "# - item4###\n" \345 " - item5\n" \346 "---\n\n"347 parsetree = {'morea_readings': [348 [False, [(False, 'item1'), (True, 'item2'), (True, 'item3'), (True, 'item4###'), (False, 'item5')]]],349 'title': [[False, (False, 'something')]]350 }351 super(MoreaTestParsingValidFilesWithComments_Test_4, self).runMoreaTest(content, parsetree)352# noinspection PyPep8Naming,PyPep8Naming353class MoreaTestParsingValidFilesWithComments_Test_5(MoreaTestParsingValidFilesWithComments):354 def shortDescription(self):355 return super(MoreaTestParsingValidFilesWithComments_Test_5,356 self).shortDescription() + "empty list items."357 def runTest(self):358 content = "---\n" \359 "morea_readings: \n" \360 " - ####item1\n" \361 " - item2\n" \362 "# - item5\n" \363 "---\n\n"364 parsetree = {'morea_readings': [[False, [(False, 'item2'), (True, 'item5')]]],365 }366 super(MoreaTestParsingValidFilesWithComments_Test_5, self).runMoreaTest(content, parsetree)367# noinspection PyPep8Naming,PyPep8Naming368class MoreaTestParsingValidFilesWithComments_Test_6(MoreaTestParsingValidFilesWithComments):369 def shortDescription(self):370 return super(MoreaTestParsingValidFilesWithComments_Test_6,371 self).shortDescription() + "multiline unquoted value."372 def runTest(self):373 content = "---\n" \374 "#title: here is the\n" \375 "# beginning\n" \376 "# and some more\n" \377 "---\n\n"378 parsetree = {'title': [[True, (True, "here is the beginning and some more")]],379 }380 super(MoreaTestParsingValidFilesWithComments_Test_6, self).runMoreaTest(content, parsetree)381# noinspection PyPep8Naming,PyPep8Naming382class MoreaTestParsingValidFilesWithComments_Test_7(MoreaTestParsingValidFilesWithComments):383 def shortDescription(self):384 return super(MoreaTestParsingValidFilesWithComments_Test_7,385 self).shortDescription() + "multiline quoted value."386 def runTest(self):387 content = "---\n" \388 "#title: \"here is the\n" \389 "# beginning\n" \390 "# and some more\"\n" \391 "---\n\n"392 parsetree = {'title': [[True, (True, "here is the beginning and some more")]],393 }394 super(MoreaTestParsingValidFilesWithComments_Test_7, self).runMoreaTest(content, parsetree)395# noinspection PyPep8Naming,PyPep8Naming396class MoreaTestParsingValidFilesWithComments_Test_8(MoreaTestParsingValidFilesWithComments):397 def shortDescription(self):398 return super(MoreaTestParsingValidFilesWithComments_Test_8,399 self).shortDescription() + "insanity."400 def runTest(self):401 content = "---\n" \402 "#title: \"here is the ###\n" \403 "# beginning ###\n" \404 "# # # and some # # more\" ###### EOL # # # EOL2\n" \405 "#morea_readings:\n" \406 "##### - item2 # EOL # EOL ##### EOL\n" \407 " ## - item3 ###\n" \408 "# # # # # # - item4\n" \409 "# item4item4\n" \410 "---\n\n"411 parsetree = {'title': [[True, (True, "here is the ### beginning ### # # and some # # more")]],412 'morea_readings': [[True, [(True, "item2"), (True, 'item3'), (True, 'item4 item4item4')]]],413 }414 super(MoreaTestParsingValidFilesWithComments_Test_8, self).runMoreaTest(content, parsetree)415# noinspection PyPep8Naming,PyPep8Naming416class MoreaTestParsingValidFilesWithComments_Test_9(MoreaTestParsingValidFilesWithComments):417 def shortDescription(self):418 return super(MoreaTestParsingValidFilesWithComments_Test_9,419 self).shortDescription() + "numerical values."420 def runTest(self):421 content = "---\n" \422 "#morea_sort_order: 12\n" \423 "morea_sort_order: 42\n" \424 "---\n\n"425 parsetree = {'morea_sort_order': [[True, (True, 12)], [False, (False, 42)]],426 }427 super(MoreaTestParsingValidFilesWithComments_Test_9, self).runMoreaTest(content, parsetree)428# noinspection PyPep8Naming,PyPep8Naming429class MoreaTestParsingValidFilesWithComments_Test_10(MoreaTestParsingValidFilesWithComments):430 def shortDescription(self):431 return super(MoreaTestParsingValidFilesWithComments_Test_10,432 self).shortDescription() + "boolean values."433 def runTest(self):434 content = "---\n" \435 "#published: false\n" \436 "published: True\n" \437 "---\n\n"438 parsetree = {'published': [[True, (True, False)], [False, (False, True)]],439 }440 super(MoreaTestParsingValidFilesWithComments_Test_10, self).runMoreaTest(content, parsetree)441class MoreaTestRejectingInvalidFilesWithComments(MoreaTestRejectingInvalidFiles):442 def shortDescription(self):443 return super(MoreaTestRejectingInvalidFilesWithComments, self).shortDescription() + "comments, "444# noinspection PyPep8Naming,PyPep8Naming445class MoreaTestRejectingInvalidFilesWithComments_Test_1(MoreaTestRejectingInvalidFilesWithComments):446 def shortDescription(self):447 return super(MoreaTestRejectingInvalidFilesWithComments_Test_1,448 self).shortDescription() + "fishy commenting."449 def runTest(self):450 content = "---\n" \451 "#morea_labels:\n" \452 " - itemA\n" \453 "# - itemB\n" \454 " - itemC\n" \455 "---\n\n"456 super(MoreaTestRejectingInvalidFilesWithComments_Test_1, self).runMoreaTest(content)457# noinspection PyPep8Naming,PyPep8Naming458class MoreaTestRejectingInvalidFilesWithComments_Test_2(MoreaTestRejectingInvalidFilesWithComments):459 def shortDescription(self):460 return super(MoreaTestRejectingInvalidFilesWithComments_Test_2,461 self).shortDescription() + "dangling full-line comments."462 def runTest(self):463 content = "---\n" \464 "title: \"I love \n" \465 " # SHOULD NOT BE LOST\n" \466 " C # something \" # EOL\n" \467 "# Hello World!!!\n" \468 "---\n\n"469 super(MoreaTestRejectingInvalidFilesWithComments_Test_2, self).runMoreaTest(content)470# noinspection PyPep8Naming,PyPep8Naming471class MoreaTestRejectingInvalidFilesWithComments_Test_3(MoreaTestRejectingInvalidFilesWithComments):472 def shortDescription(self):473 return super(MoreaTestRejectingInvalidFilesWithComments_Test_3,474 self).shortDescription() + "dangling full-line comments #2."475 def runTest(self):476 content = "---\n" \477 "title: \"I love \n" \478 "# Hello World!!!\n" \479 "morea_id: hello\n" \480 "# Full-line comments\n" \481 "morea_type: full" \482 "---\n\n"...

Full Screen

Full Screen

feat.py

Source:feat.py Github

copy

Full Screen

1import os2import sys3import shutil4import pathlib5import json6def write_db(filepath, fg_data):7 id = 18 with open(filepath, mode='w', encoding='UTF-8', errors='strict', buffering=1) as file:9 file.write('<root version="2.9">\n')10 file.write(' <feat>\n')11 for entry in fg_data:12 string_id = "00000"[0:len("00000")-len(str(id))] + str(id)13 file.write(f' <id-{string_id}>\n')14 file.write(' <description type="formattedtext">\n')15 file.write(f' <p></p>\n')16 file.write(' </description>\n')17 file.write(f' <flavor type="string">{entry["flavor"]}</flavor>\n')18 file.write(' <linkedpowers>\n')19 file.write(' </linkedpowers>\n')20 file.write(' <locked type="number">1</locked>\n')21 file.write(f' <name type="string">{entry["name"]}</name>\n')22 desc = entry["shortdescription"].replace(u'\xa0', ' ').replace('&','&amp;')23 file.write(f' <shortdescription type="string">{repr(desc)[1:-1]}</shortdescription>\n')24 file.write(f' </id-{string_id}>\n')25 id = id + 126 file.write(' </feat>\n')27 file.write('</root>')28if __name__ == '__main__':29 # Pull data from Portable Compendium30 data_source = {}31 sql_sections = []32 for path in pathlib.Path("sources/").iterdir():33 if path.is_file() and 'ddiFeat' in path.stem:34 with open(path, encoding="utf8") as inp:35 for section in inp.read().split("INSERT INTO `Feat` VALUES"):36 sql_sections.append(section)37 sql_sections.pop(0)38 for index, section in enumerate(sql_sections):39 html = section.split('.</p>\\r\\n ', 1)[0] + '.</p>'40 html = '<h1' + html.split('<h1', 1)[1]41 html = html.replace('\\', '')42 data_source[index] = html43 print(str(len(data_source.keys())) + " entries recovered")44 # Convert data to FG format45 print("converting to FG format...")46 # Initialize all modules databases47 Feat_fg = []48 try:49 from BeautifulSoup import BeautifulSoup50 except ImportError:51 from bs4 import BeautifulSoup, Tag, NavigableString52 if not data_source.items():53 print("NO DATA FOUND IN SOURCES, MAKE SURE YOU HAVE COPIED YOUR 4E PORTABLE COMPENDIUM DATA TO SOURCES!")54 input('Press enter to close.')55 sys.exit(0)56 for key, value in data_source.items():57 fg_entry = {}58 parsed_html = BeautifulSoup(value, features="html.parser").contents59 # Parse header data from parsed_html [0] (split if needed)60 composed_name = parsed_html[0].text61 start = composed_name.find('[')62 end = composed_name.find(']')63 if start != -1 and end != -1:64 name = composed_name[0:start-1]65 context = composed_name[start+1:end]66 else:67 name = composed_name68 context = ""69 fg_entry['name'] = name70 fg_entry['flavor'] = context71 # Recover Feat core data always located in parsed_html [1]72 shortdescription = ""73 for content in parsed_html[1].contents:74 html_content = str(content)75 if '<br/>' in html_content:76 shortdescription = shortdescription + "\n"77 elif isinstance(content, NavigableString):78 shortdescription = shortdescription + str(content)79 elif isinstance(content, Tag):80 shortdescription = shortdescription + content.text81 # Check if there is linked powers (we want to ignore them since they are handled by an other module)82 i = 083 power_start = -184 power_end = -185 for tag in parsed_html:86 if isinstance(tag, Tag):87 if tag.name in 'h1' and power_start == -1:88 if 'player' not in tag.attrs['class'][0]:89 power_start = i90 elif tag.name in 'p':91 if 'powerstat' in tag.attrs['class'][0] or 'flavor' in tag.attrs['class'][0]:92 power_end = i93 i = i + 194 # Add remaining information to Feat core data (shortdescription), ignore power section if present.95 if power_start != -1 and power_end != -1 and power_start < power_end:96 # get sub section from power_end97 remaining_info = parsed_html[power_end+1:len(parsed_html)]98 else:99 # get sub section from [2]100 remaining_info = parsed_html[2:len(parsed_html)]101 shortdescription_end = ""102 for content in remaining_info:103 html_content = str(content)104 if '<br/>' in html_content:105 shortdescription_end = shortdescription_end + "\n"106 elif isinstance(content, NavigableString):107 shortdescription_end = shortdescription_end + str(content)108 elif isinstance(content, Tag):109 shortdescription_end = shortdescription_end + content.text110 fg_entry['shortdescription'] = shortdescription + shortdescription_end...

Full Screen

Full Screen

test_cases.py

Source:test_cases.py Github

copy

Full Screen

...21 c1 = case.Test(TC('test_one'), config=config)22 c2 = case.Test(TC('test_two'), config=config)23 self.assertEqual(str(c1), '(1) test')24 self.assertEqual(str(c2), '(2) test')25 assert c1.shortDescription().startswith('test #'), \26 "Unexpected shortDescription: %s" % c1.shortDescription()27 assert c2.shortDescription().startswith('test #'), \28 "Unexpected shortDescription: %s" % c2.shortDescription()29if __name__ == '__main__':...

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