How to use dumps method in autotest

Best Python code snippet using autotest_python

canned_data.py

Source:canned_data.py Github

copy

Full Screen

...42 ( 5, '396'),43])44CANNED_TEST_FILE_SYSTEM_DATA = MoveTo(CHROME_EXTENSIONS, {45 'api': {46 '_api_features.json': json.dumps({47 'ref_test': { 'dependencies': ['permission:ref_test'] },48 'tester': { 'dependencies': ['permission:tester', 'manifest:tester'] }49 }),50 '_manifest_features.json': '{}',51 '_permission_features.json': '{}'52 },53 'docs': {54 'templates': {55 'articles': {56 'test_article.html':57 '<h1>hi</h1>you<h2>first</h2><h3>inner</h3><h2>second</h2>'58 },59 'intros': {60 'test_intro.html':61 'you<h2>first</h2><h3>inner</h3><h2>second</h2>'62 },63 'json': {64 'api_availabilities.json': json.dumps({65 'master_api': {66 'channel': 'master'67 },68 'dev_api': {69 'channel': 'dev'70 },71 'beta_api': {72 'channel': 'beta'73 },74 'stable_api': {75 'channel': 'stable',76 'version': 2077 }78 }),79 'intro_tables.json': json.dumps({80 'tester': {81 'Permissions': [82 {83 'class': 'override',84 'text': '"tester"'85 },86 {87 'text': 'is an API for testing things.'88 }89 ],90 'Learn More': [91 {92 'link': 'https://tester.test.com/welcome.html',93 'text': 'Welcome!'94 }95 ]96 }97 }),98 'manifest.json': '{}',99 'permissions.json': '{}'100 },101 'private': {102 'intro_tables': {103 'master_message.html': 'available on master'104 },105 'table_of_contents.html': '<table-of-contents>',106 }107 }108 }109})110_TEST_WHATS_NEW_JSON = {111 "backgroundpages.to-be-non-persistent": {112 "type": "additionsToExistingApis",113 "description": "backgrounds to be non persistent",114 "version": 22115 },116 "chromeSetting.set-regular-only-scope": {117 "type": "additionsToExistingApis",118 "description": "ChromeSetting.set now has a regular_only scope.",119 "version": 21120 },121 "manifest-v1-deprecated": {122 "type": "manifestChanges",123 "description": "Manifest version 1 was deprecated in Chrome 18",124 "version": 20125 }126}127CANNED_API_FILE_SYSTEM_DATA = MoveAllTo(CHROME_EXTENSIONS, {128 'master': {129 'api': {130 '_api_features.json': json.dumps({131 'alarm': {132 'channel': 'stable'133 },134 'app.window': {135 'channel': 'stable'136 },137 'browserAction': {138 'channel': 'stable'139 },140 'contextMenus': {141 'channel': 'stable'142 },143 'events': {144 'channel': 'stable'145 },146 'extension': {147 'channel': 'stable'148 },149 'signedInDevices': {150 'channel': 'stable'151 },152 'systemInfo.cpu': {153 'channel': 'stable'154 },155 'systemInfo.stuff': {156 'channel': 'dev'157 }158 }),159 '_manifest_features.json': json.dumps({160 'history': {161 'channel': 'beta'162 },163 'notifications': {164 'channel': 'beta'165 },166 'page_action': {167 'channel': 'stable'168 },169 'runtime': {170 'channel': 'stable'171 },172 'storage': {173 'channel': 'beta'174 },175 'sync': {176 'channel': 'master'177 },178 'web_request': {179 'channel': 'stable'180 }181 }),182 '_permission_features.json': json.dumps({183 'alarms': {184 'channel': 'stable'185 },186 'bluetooth': {187 'channel': 'dev'188 },189 'bookmarks': {190 'channel': 'stable'191 },192 'cookies': {193 'channel': 'dev'194 },195 'declarativeContent': {196 'channel': 'master'197 },198 'declarativeWebRequest': [199 { 'channel': 'beta',200 'extension_types': ['extension']201 },202 { 'channel': 'stable',203 'extension_types': ['extension'],204 'whitelist': ['aaa']205 },206 ],207 'falseBetaAPI': {208 'channel': 'beta'209 },210 'systemInfo.display': {211 'channel': 'stable'212 },213 'masterAPI': {214 'channel': 'master'215 }216 }),217 'alarm.json': json.dumps([{218 'namespace': 'alarm',219 'description': '<code>alarm</code>'220 }]),221 'app_window.json': json.dumps([{222 'namespace': 'app.window',223 'description': '<code>app.window</code>'224 }]),225 'browser_action.json': json.dumps([{226 'namespace': 'browserAction',227 'description': '<code>browserAction</code>'228 }]),229 'bluetooth.idl': '\n'.join(('//Copyleft Schmopyright',230 '',231 '//An IDL description, oh my!',232 'namespace bluetooth {',233 ' dictionary Socket {',234 ' long id;',235 ' };',236 '};')),237 'context_menus.json': json.dumps([{238 'namespace': 'contextMenus',239 'description': ''240 }]),241 'json_stable_api.json': json.dumps([{242 'namespace': 'jsonStableAPI',243 'description': 'An API with a predetermined availability.'244 }]),245 'idle.json': json.dumps([{'namespace': 'idle', 'description': ''}]),246 'input_ime.json': json.dumps([{247 'namespace': 'input.ime',248 'description': 'An API that has the potential to cause some trouble.'249 }]),250 'menus.json': json.dumps([{'namespace': 'menus', 'description': ''}]),251 'signed_in_devices.json': json.dumps([{252 'namespace': 'signedInDevices',253 'description': 'Another API that could cause some trouble.'254 }]),255 'system_info_stuff.json': json.dumps([{256 'namespace': 'systemInfo.stuff',257 'description': 'Yet another API that could wreck havoc...'258 }]),259 'tabs.json': json.dumps([{'namespace': 'tabs', 'description': ''}]),260 'windows.json': json.dumps([{'namespace': 'windows', 'description': ''}])261 },262 'docs': {263 'templates': {264 'json': {265 'api_availabilities.json': json.dumps({266 'jsonMasterAPI': {267 'channel': 'master'268 },269 'jsonDevAPI': {270 'channel': 'dev'271 },272 'jsonBetaAPI': {273 'channel': 'beta'274 },275 'jsonStableAPI': {276 'channel': 'stable',277 'version': 20278 }279 }),280 'intro_tables.json': json.dumps({281 'test': [282 {283 'Permissions': 'probably none'284 }285 ]286 }),287 'manifest.json': '{}',288 'permissions.json': '{}',289 'whats_new.json': json.dumps(_TEST_WHATS_NEW_JSON)290 },291 'public': {292 'apps': {293 'alarm.html': 'alarm.html',294 'app_window.html': 'app_window.html',295 'contextMenus.html': 'contextMenus.html',296 },297 'extensions': {298 'alarm.html': 'alarm.html',299 'browserAction.html': 'browserAction.html',300 'contextMenus.html': 'contextMenus.html',301 }302 }303 }304 }305 },306 '1612': {307 'api': {308 '_api_features.json': json.dumps({309 'alarm': {310 'channel': 'stable'311 },312 'app.window': {313 'channel': 'stable'314 },315 'browserAction': {316 'channel': 'stable'317 },318 'events': {319 'channel': 'master'320 },321 'extension': {322 'channel': 'stable'323 },324 'systemInfo.cpu': {325 'channel': 'stable'326 },327 'systemInfo.stuff': {328 'channel': 'dev'329 }330 }),331 '_manifest_features.json': json.dumps({332 'contextMenus': {333 'channel': 'master'334 },335 'notifications': {336 'channel': 'beta'337 },338 'page_action': {339 'channel': 'stable'340 },341 'runtime': {342 'channel': 'stable'343 },344 'storage': {345 'channel': 'dev'346 },347 'sync': {348 'channel': 'master'349 },350 'system_info_display': {351 'channel': 'stable'352 },353 'web_request': {354 'channel': 'stable'355 }356 }),357 '_permission_features.json': json.dumps({358 'alarms': {359 'channel': 'stable'360 },361 'appsFirst': {362 'channel': 'stable',363 'extension_types': ['extension', 'platform_app']364 },365 'bluetooth': {366 'channel': 'dev'367 },368 'bookmarks': {369 'channel': 'stable'370 },371 'cookies': {372 'channel': 'dev'373 },374 'declarativeContent': {375 'channel': 'master'376 },377 'declarativeWebRequest': [378 { 'channel': 'beta' },379 { 'channel': 'stable', 'whitelist': ['aaa'] }380 ],381 'downloads': {382 'channel': 'beta'383 }384 }),385 'alarm.json': json.dumps([{386 'namespace': 'alarm',387 'description': '<code>alarm</code>'388 }]),389 'app_window.json': json.dumps([{390 'namespace': 'app.window',391 'description': '<code>app.window</code>'392 }]),393 'browser_action.json': json.dumps([{394 'namespace': 'browserAction',395 'description': '<code>browserAction</code>'396 }]),397 'idle.json': json.dumps([{'namespace': 'idle'}]),398 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),399 'menus.json': json.dumps([{'namespace': 'menus'}]),400 'tabs.json': json.dumps([{'namespace': 'tabs'}]),401 'windows.json': json.dumps([{'namespace': 'windows'}])402 },403 'docs': {404 'templates': {405 'json': {406 'api_availabilities.json': json.dumps({407 'jsonMasterAPI': {408 'channel': 'master'409 },410 'jsonDevAPI': {411 'channel': 'dev'412 },413 'jsonBetaAPI': {414 'channel': 'beta'415 },416 'jsonStableAPI': {417 'channel': 'stable',418 'version': 20419 }420 }),421 'intro_tables.json': json.dumps({422 'test': [423 {424 'Permissions': 'probably none'425 }426 ]427 }),428 'manifest.json': '{}',429 'permissions.json': '{}',430 'whats_new.json': json.dumps(_TEST_WHATS_NEW_JSON)431 },432 'public': {433 'apps': {434 'alarm.html': 'alarm.html',435 'app_window.html': 'app_window.html',436 },437 'extensions': {438 'alarm.html': 'alarm.html',439 'browserAction.html': 'browserAction.html',440 }441 }442 }443 }444 },445 '1599': {446 'api': {447 '_api_features.json': json.dumps({448 'alarm': {449 'channel': 'stable'450 },451 'app.window': {452 'channel': 'stable'453 },454 'browserAction': {455 'channel': 'stable'456 },457 'events': {458 'channel': 'master'459 },460 'extension': {461 'channel': 'stable'462 },463 'systemInfo.cpu': {464 'channel': 'beta'465 },466 'systemInfo.stuff': {467 'channel': 'dev'468 }469 }),470 '_manifest_features.json': json.dumps({471 'contextMenus': {472 'channel': 'master'473 },474 'notifications': {475 'channel': 'dev'476 },477 'page_action': {478 'channel': 'stable'479 },480 'runtime': {481 'channel': 'stable'482 },483 'storage': {484 'channel': 'dev'485 },486 'sync': {487 'channel': 'master'488 },489 'system_info_display': {490 'channel': 'stable'491 },492 'web_request': {493 'channel': 'stable'494 }495 }),496 '_permission_features.json': json.dumps({497 'alarms': {498 'channel': 'stable'499 },500 'appsFirst': {501 'channel': 'stable',502 'extension_types': ['extension', 'platform_app']503 },504 'bluetooth': {505 'channel': 'dev'506 },507 'bookmarks': {508 'channel': 'stable'509 },510 'cookies': {511 'channel': 'dev'512 },513 'declarativeContent': {514 'channel': 'master'515 },516 'declarativeWebRequest': [517 { 'channel': 'beta' },518 { 'channel': 'stable', 'whitelist': ['aaa'] }519 ],520 'downloads': {521 'channel': 'beta'522 }523 }),524 'alarm.json': json.dumps([{525 'namespace': 'alarm',526 'description': '<code>alarm</code>'527 }]),528 'app_window.json': json.dumps([{529 'namespace': 'app.window',530 'description': '<code>app.window</code>'531 }]),532 'browser_action.json': json.dumps([{533 'namespace': 'browserAction',534 'description': '<code>browserAction</code>'535 }]),536 'idle.json': json.dumps([{'namespace': 'idle'}]),537 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),538 'menus.json': json.dumps([{'namespace': 'menus'}]),539 'tabs.json': json.dumps([{'namespace': 'tabs'}]),540 'windows.json': json.dumps([{'namespace': 'windows'}])541 },542 'docs': {543 'templates': {544 'json': {545 'api_availabilities.json': json.dumps({546 'jsonMasterAPI': {547 'channel': 'master'548 },549 'jsonDevAPI': {550 'channel': 'dev'551 },552 'jsonBetaAPI': {553 'channel': 'beta'554 },555 'jsonStableAPI': {556 'channel': 'stable',557 'version': 20558 }559 }),560 'intro_tables.json': json.dumps({561 'test': [562 {563 'Permissions': 'probably none'564 }565 ]566 }),567 'manifest.json': '{}',568 'permissions.json': '{}',569 'whats_new.json': json.dumps(_TEST_WHATS_NEW_JSON)570 },571 'public': {572 'apps': {573 'alarm.html': 'alarm.html',574 'app_window.html': 'app_window.html',575 },576 'extensions': {577 'alarm.html': 'alarm.html',578 'browserAction.html': 'browserAction.html',579 }580 }581 }582 }583 },584 '1547': {585 'api': {586 '_api_features.json': json.dumps({587 'alarm': {588 'channel': 'stable'589 },590 'app.window': {591 'channel': 'stable'592 },593 'browserAction': {594 'channel': 'stable'595 },596 'events': {597 'channel': 'master'598 },599 'extension': {600 'channel': 'stable'601 },602 'systemInfo.stuff': {603 'channel': 'dev'604 }605 }),606 '_manifest_features.json': json.dumps({607 'contextMenus': {608 'channel': 'master'609 },610 'notifications': {611 'channel': 'dev'612 },613 'page_action': {614 'channel': 'stable'615 },616 'runtime': {617 'channel': 'stable'618 },619 'storage': {620 'channel': 'dev'621 },622 'sync': {623 'channel': 'master'624 },625 'system_info_display': {626 'channel': 'stable'627 },628 'web_request': {629 'channel': 'stable'630 }631 }),632 '_permission_features.json': json.dumps({633 'alarms': {634 'channel': 'stable'635 },636 'appsFirst': {637 'channel': 'stable',638 'extension_types': ['extension', 'platform_app']639 },640 'bluetooth': {641 'channel': 'dev'642 },643 'bookmarks': {644 'channel': 'stable'645 },646 'cookies': {647 'channel': 'dev'648 },649 'declarativeContent': {650 'channel': 'master'651 },652 'declarativeWebRequest': [653 { 'channel': 'beta' },654 { 'channel': 'stable', 'whitelist': ['aaa'] }655 ],656 'downloads': {657 'channel': 'beta'658 }659 }),660 'alarm.json': json.dumps([{661 'namespace': 'alarm',662 'description': '<code>alarm</code>'663 }]),664 'app_window.json': json.dumps([{665 'namespace': 'app.window',666 'description': '<code>app.window</code>'667 }]),668 'browser_action.json': json.dumps([{669 'namespace': 'browserAction',670 'description': '<code>browserAction</code>'671 }]),672 'idle.json': json.dumps([{'namespace': 'idle'}]),673 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),674 'menus.json': json.dumps([{'namespace': 'menus'}]),675 'tabs.json': json.dumps([{'namespace': 'tabs'}]),676 'windows.json': json.dumps([{'namespace': 'windows'}])677 },678 'docs': {679 'templates': {680 'json': {681 'api_availabilities.json': json.dumps({682 'jsonMasterAPI': {683 'channel': 'master'684 },685 'jsonDevAPI': {686 'channel': 'dev'687 },688 'jsonBetaAPI': {689 'channel': 'beta'690 },691 'jsonStableAPI': {692 'channel': 'stable',693 'version': 20694 }695 }),696 'intro_tables.json': json.dumps({697 'test': [698 {699 'Permissions': 'probably none'700 }701 ]702 }),703 'manifest.json': '{}',704 'permissions.json': '{}',705 'whats_new.json': json.dumps(_TEST_WHATS_NEW_JSON)706 },707 'public': {708 'apps': {709 'alarm.html': 'alarm.html',710 'app_window.html': 'app_window.html',711 },712 'extensions': {713 'alarm.html': 'alarm.html',714 'browserAction.html': 'browserAction.html',715 }716 }717 }718 }719 },720 '1500': {721 'api': {722 '_api_features.json': json.dumps({723 'alarm': {724 'channel': 'stable'725 },726 'app.window': {727 'channel': 'stable'728 },729 'browserAction': {730 'channel': 'stable'731 },732 'events': {733 'channel': 'master'734 },735 'extension': {736 'channel': 'stable'737 },738 'systemInfo.stuff': {739 'channel': 'dev'740 }741 }),742 '_manifest_features.json': json.dumps({743 'contextMenus': {744 'channel': 'master'745 },746 'notifications': {747 'channel': 'dev'748 },749 'page_action': {750 'channel': 'stable'751 },752 'runtime': {753 'channel': 'stable'754 },755 'storage': {756 'channel': 'dev'757 },758 'sync': {759 'channel': 'master'760 },761 'system_info_display': {762 'channel': 'stable'763 },764 'web_request': {765 'channel': 'stable'766 }767 }),768 '_permission_features.json': json.dumps({769 'alarms': {770 'channel': 'stable'771 },772 'appsFirst': {773 'channel': 'stable',774 'extension_types': ['extension', 'platform_app']775 },776 'bluetooth': {777 'channel': 'dev'778 },779 'bookmarks': {780 'channel': 'stable'781 },782 'cookies': {783 'channel': 'dev'784 },785 'declarativeContent': {786 'channel': 'master'787 },788 'declarativeWebRequest': [789 { 'channel': 'beta' },790 { 'channel': 'stable', 'whitelist': ['aaa'] }791 ],792 'downloads': {793 'channel': 'beta'794 }795 }),796 'alarm.json': json.dumps([{797 'namespace': 'alarm',798 'description': '<code>alarm</code>'799 }]),800 'app_window.json': json.dumps([{801 'namespace': 'app.window',802 'description': '<code>app.window</code>'803 }]),804 'browser_action.json': json.dumps([{805 'namespace': 'browserAction',806 'description': '<code>browserAction</code>'807 }]),808 'idle.json': json.dumps([{'namespace': 'idle'}]),809 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),810 'menus.json': json.dumps([{'namespace': 'menus'}]),811 'tabs.json': json.dumps([{'namespace': 'tabs'}]),812 'windows.json': json.dumps([{'namespace': 'windows'}])813 },814 'docs': {815 'templates': {816 'json': {817 'api_availabilities.json': json.dumps({818 'jsonMasterAPI': {819 'channel': 'master'820 },821 'jsonDevAPI': {822 'channel': 'dev'823 },824 'jsonBetaAPI': {825 'channel': 'beta'826 },827 'jsonStableAPI': {828 'channel': 'stable',829 'version': 20830 }831 }),832 'intro_tables.json': json.dumps({833 'test': [834 {835 'Permissions': 'probably none'836 }837 ]838 }),839 'manifest.json': '{}',840 'permissions.json': '{}',841 'whats_new.json': json.dumps(_TEST_WHATS_NEW_JSON)842 },843 'public': {844 'apps': {845 'alarm.html': 'alarm.html',846 'app_window.html': 'app_window.html',847 },848 'extensions': {849 'alarm.html': 'alarm.html',850 'browserAction.html': 'browserAction.html',851 }852 }853 }854 }855 },856 '1453': {857 'api': {858 '_api_features.json': json.dumps({859 'alarm': {860 'channel': 'stable'861 },862 'app.window': {863 'channel': 'stable'864 },865 'browserAction': {866 'channel': 'stable'867 },868 'events': {869 'channel': 'dev'870 },871 'extension': {872 'channel': 'stable'873 },874 'systemInfo.stuff': {875 'channel': 'dev'876 }877 }),878 '_manifest_features.json': json.dumps({879 'notifications': {880 'channel': 'dev'881 },882 'page_action': {883 'channel': 'stable'884 },885 'runtime': {886 'channel': 'stable'887 },888 'storage': {889 'channel': 'dev'890 },891 'system_info_display': {892 'channel': 'stable'893 },894 'web_request': {895 'channel': 'stable'896 }897 }),898 '_permission_features.json': json.dumps({899 'alarms': {900 'channel': 'stable'901 },902 'appsFirst': {903 'channel': 'stable',904 'extension_types': ['extension', 'platform_app']905 },906 'bluetooth': {907 'channel': 'dev'908 },909 'bookmarks': {910 'channel': 'stable'911 },912 'context_menus': {913 'channel': 'master'914 },915 'declarativeContent': {916 'channel': 'master'917 },918 'declarativeWebRequest': [919 { 'channel': 'beta' },920 { 'channel': 'stable', 'whitelist': ['aaa'] }921 ],922 'downloads': {923 'channel': 'dev'924 }925 }),926 'alarm.json': json.dumps([{927 'namespace': 'alarm',928 'description': '<code>alarm</code>'929 }]),930 'app_window.json': json.dumps([{931 'namespace': 'app.window',932 'description': '<code>app.window</code>'933 }]),934 'browser_action.json': json.dumps([{935 'namespace': 'browserAction',936 'description': '<code>browserAction</code>'937 }]),938 'idle.json': json.dumps([{'namespace': 'idle'}]),939 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),940 'menus.json': json.dumps([{'namespace': 'menus'}]),941 'tabs.json': json.dumps([{'namespace': 'tabs'}]),942 'windows.json': json.dumps([{'namespace': 'windows'}])943 },944 'docs': {945 'templates': {946 'json': {947 'api_availabilities.json': json.dumps({948 'jsonMasterAPI': {949 'channel': 'master'950 },951 'jsonDevAPI': {952 'channel': 'dev'953 },954 'jsonBetaAPI': {955 'channel': 'beta'956 },957 'jsonStableAPI': {958 'channel': 'stable',959 'version': 20960 }961 }),962 'intro_tables.json': json.dumps({963 'test': [964 {965 'Permissions': 'probably none'966 }967 ]968 }),969 'manifest.json': '{}',970 'permissions.json': '{}',971 'whats_new.json': json.dumps(_TEST_WHATS_NEW_JSON)972 },973 'public': {974 'apps': {975 'alarm.html': 'alarm.html',976 'app_window.html': 'app_window.html',977 },978 'extensions': {979 'alarm.html': 'alarm.html',980 'browserAction.html': 'browserAction.html',981 }982 }983 }984 }985 },986 '1410': {987 'api': {988 '_manifest_features.json': json.dumps({989 'alarm': {990 'channel': 'stable'991 },992 'app.window': {993 'channel': 'stable'994 },995 'browserAction': {996 'channel': 'stable'997 },998 'events': {999 'channel': 'beta'1000 },1001 'notifications': {1002 'channel': 'dev'1003 },1004 'page_action': {1005 'channel': 'stable'1006 },1007 'runtime': {1008 'channel': 'stable'1009 },1010 'web_request': {1011 'channel': 'stable'1012 }1013 }),1014 '_permission_features.json': json.dumps({1015 'alarms': {1016 'channel': 'stable'1017 },1018 'appsFirst': {1019 'channel': 'stable',1020 'extension_types': ['extension', 'platform_app']1021 },1022 'bluetooth': {1023 'channel': 'dev'1024 },1025 'bookmarks': {1026 'channel': 'stable'1027 },1028 'context_menus': {1029 'channel': 'master'1030 },1031 'declarativeContent': {1032 'channel': 'master'1033 },1034 'declarativeWebRequest': [1035 { 'channel': 'beta' },1036 { 'channel': 'stable', 'whitelist': ['aaa'] }1037 ],1038 'systemInfo.display': {1039 'channel': 'stable'1040 }1041 }),1042 'alarm.json': json.dumps([{1043 'namespace': 'alarm',1044 'description': '<code>alarm</code>'1045 }]),1046 'app_window.json': json.dumps([{1047 'namespace': 'app.window',1048 'description': '<code>app.window</code>'1049 }]),1050 'browser_action.json': json.dumps([{1051 'namespace': 'browserAction',1052 'description': '<code>browserAction</code>'1053 }]),1054 'idle.json': json.dumps([{'namespace': 'idle'}]),1055 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),1056 'menus.json': json.dumps([{'namespace': 'menus'}]),1057 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1058 'windows.json': json.dumps([{'namespace': 'windows'}])1059 }1060 },1061 '1364': {1062 'api': {1063 '_manifest_features.json': json.dumps({1064 'page_action': {1065 'channel': 'stable'1066 },1067 'runtime': {1068 'channel': 'stable'1069 }1070 }),1071 '_permission_features.json': json.dumps({1072 'alarms': {1073 'channel': 'stable'1074 },1075 'appsFirst': {1076 'channel': 'stable',1077 'extension_types': ['platform_app']1078 },1079 'bookmarks': {1080 'channel': 'stable'1081 },1082 'systemInfo.display': {1083 'channel': 'stable'1084 },1085 'webRequest': {1086 'channel': 'stable'1087 }1088 }),1089 'idle.json': json.dumps([{'namespace': 'idle'}]),1090 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),1091 'menus.json': json.dumps([{'namespace': 'menus'}]),1092 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1093 'windows.json': json.dumps([{'namespace': 'windows'}])1094 }1095 },1096 '1312': {1097 'api': {1098 '_manifest_features.json': json.dumps({1099 'page_action': {1100 'channel': 'stable'1101 },1102 'runtime': {1103 'channel': 'stable'1104 },1105 'web_request': {1106 'channel': 'stable'1107 }1108 }),1109 '_permission_features.json': json.dumps({1110 'alarms': {1111 'channel': 'stable'1112 },1113 'bookmarks': {1114 'channel': 'stable'1115 },1116 'systemInfo.display': {1117 'channel': 'stable'1118 }1119 }),1120 'idle.json': json.dumps([{'namespace': 'idle'}]),1121 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),1122 'menus.json': json.dumps([{'namespace': 'menus'}]),1123 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1124 'windows.json': json.dumps([{'namespace': 'windows'}])1125 }1126 },1127 '1271': {1128 'api': {1129 '_manifest_features.json': json.dumps({1130 'page_action': {1131 'channel': 'stable'1132 },1133 'runtime': {1134 'channel': 'stable'1135 },1136 'system_info_display': {1137 'channel': 'stable'1138 }1139 }),1140 '_permission_features.json': json.dumps({1141 'alarms': {1142 'channel': 'beta'1143 },1144 'bookmarks': {1145 'channel': 'stable'1146 },1147 'webRequest': {1148 'channel': 'stable'1149 }1150 }),1151 'alarms.idl': '//copy\n\n//desc\nnamespace alarms {}',1152 'idle.json': json.dumps([{'namespace': 'idle'}]),1153 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),1154 'menus.json': json.dumps([{'namespace': 'menus'}]),1155 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1156 'windows.json': json.dumps([{'namespace': 'windows'}])1157 }1158 },1159 '1229': {1160 'api': {1161 '_manifest_features.json': json.dumps({1162 'page_action': {1163 'channel': 'stable'1164 },1165 'runtime': {1166 'channel': 'stable'1167 },1168 'web_request': {1169 'channel': 'stable'1170 }1171 }),1172 '_permission_features.json': json.dumps({1173 'bookmarks': {1174 'channel': 'stable'1175 },1176 'systemInfo.display': {1177 'channel': 'beta'1178 }1179 }),1180 'alarms.idl': '//copy\n\n//desc\nnamespace alarms {}',1181 'idle.json': json.dumps([{'namespace': 'idle'}]),1182 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),1183 'menus.json': json.dumps([{'namespace': 'menus'}]),1184 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1185 }1186 },1187 '1180': {1188 'api': {1189 '_manifest_features.json': json.dumps({1190 'page_action': {1191 'channel': 'stable'1192 },1193 'runtime': {1194 'channel': 'stable'1195 }1196 }),1197 '_permission_features.json': json.dumps({1198 'bookmarks': {1199 'channel': 'stable'1200 },1201 'webRequest': {1202 'channel': 'stable'1203 }1204 }),1205 'bookmarks.json': json.dumps([{'namespace': 'bookmarks'}]),1206 'idle.json': json.dumps([{'namespace': 'idle'}]),1207 'input_ime.json': json.dumps([{'namespace': 'input.ime'}]),1208 'menus.json': json.dumps([{'namespace': 'menus'}]),1209 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1210 }1211 },1212 '1132': {1213 'api': {1214 '_manifest_features.json': json.dumps({1215 'bookmarks': {1216 'channel': 'master'1217 },1218 'page_action': {1219 'channel': 'stable'1220 }1221 }),1222 '_permission_features.json': json.dumps({1223 'webRequest': {1224 'channel': 'stable'1225 }1226 }),1227 'bookmarks.json': json.dumps([{'namespace': 'bookmarks'}]),1228 'idle.json': json.dumps([{'namespace': 'idle'}]),1229 'input.ime.json': json.dumps([{'namespace': 'input.ime'}]),1230 'menus.json': json.dumps([{'namespace': 'menus'}]),1231 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1232 }1233 },1234 '1084': {1235 'api': {1236 '_manifest_features.json': json.dumps({1237 'contents': 'nothing of interest here,really'1238 }),1239 'bookmarks.json': json.dumps([{'namespace': 'bookmarks'}]),1240 'idle.json': json.dumps([{'namespace': 'idle'}]),1241 'input.ime.json': json.dumps([{'namespace': 'input.ime'}]),1242 'menus.json': json.dumps([{'namespace': 'menus'}]),1243 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1244 'pageAction.json': json.dumps([{'namespace': 'pageAction'}]),1245 'webRequest.json': json.dumps([{'namespace': 'webRequest'}])1246 }1247 },1248 '1025': {1249 'api': {1250 'bookmarks.json': json.dumps([{'namespace': 'bookmarks'}]),1251 'idle.json': json.dumps([{'namespace': 'idle'}]),1252 'input.ime.json': json.dumps([{'namespace': 'input.ime'}]),1253 'menus.json': json.dumps([{'namespace': 'menus'}]),1254 'tabs.json': json.dumps([{'namespace': 'tabs'}]),1255 'pageAction.json': json.dumps([{'namespace': 'pageAction'}]),1256 'webRequest.json': json.dumps([{'namespace': 'webRequest'}])1257 }1258 },1259 '963': {1260 'api': {1261 'extension_api.json': json.dumps([1262 {1263 'namespace': 'idle'1264 },1265 {1266 'namespace': 'menus'1267 },1268 {1269 'namespace': 'pageAction'1270 },1271 {1272 'namespace': 'webRequest'1273 }1274 ])1275 }1276 },1277 '912': {1278 'api': {1279 'extension_api.json': json.dumps([1280 {1281 'namespace': 'idle'1282 },1283 {1284 'namespace': 'menus'1285 },1286 {1287 'namespace': 'pageAction'1288 },1289 {1290 'namespace': 'experimental.webRequest'1291 }1292 ])1293 }1294 },1295 '874': {1296 'api': {1297 'extension_api.json': json.dumps([1298 {1299 'namespace': 'idle'1300 },1301 {1302 'namespace': 'menus'1303 },1304 {1305 'namespace': 'pageAction'1306 }1307 ])1308 }1309 },1310 '835': {1311 'api': {1312 'extension_api.json': json.dumps([1313 {1314 'namespace': 'idle'1315 },1316 {1317 'namespace': 'menus'1318 },1319 {1320 'namespace': 'pageAction'1321 }1322 ])1323 }1324 },1325 '782': {1326 'api': {1327 'extension_api.json': json.dumps([1328 {1329 'namespace': 'idle'1330 },1331 {1332 'namespace': 'menus'1333 },1334 {1335 'namespace': 'pageAction'1336 }1337 ])1338 }1339 },1340 '742': {1341 'api': {1342 'extension_api.json': json.dumps([1343 {1344 'namespace': 'idle'1345 },1346 {1347 'namespace': 'menus'1348 },1349 {1350 'namespace': 'pageAction'1351 }1352 ])1353 }1354 },1355 '696': {1356 'api': {1357 'extension_api.json': json.dumps([1358 {1359 'namespace': 'idle'1360 },1361 {1362 'namespace': 'menus'1363 },1364 {1365 'namespace': 'pageAction'1366 }1367 ])1368 }1369 },1370 '648': {1371 'api': {1372 'extension_api.json': json.dumps([1373 {1374 'namespace': 'idle'1375 },1376 {1377 'namespace': 'menus'1378 },1379 {1380 'namespace': 'pageAction'1381 }1382 ])1383 }1384 },1385 '597': {1386 'api': {1387 'extension_api.json': json.dumps([1388 {1389 'namespace': 'idle'1390 },1391 {1392 'namespace': 'menus'1393 },1394 {1395 'namespace': 'pageAction'1396 }1397 ])1398 }1399 },1400 '552': {1401 'api': {1402 'extension_api.json': json.dumps([1403 {1404 'namespace': 'idle'1405 },1406 {1407 'namespace': 'menus'1408 },1409 {1410 'namespace': 'pageAction'1411 }1412 ])1413 }1414 },1415 '544': {1416 'api': {1417 'extension_api.json': json.dumps([1418 {1419 'namespace': 'idle'1420 },1421 {1422 'namespace': 'menus'1423 }1424 ])1425 }1426 },1427 '495': {1428 'api': {1429 'extension_api.json': json.dumps([1430 {1431 'namespace': 'idle'1432 },1433 {1434 'namespace': 'menus'1435 }1436 ])1437 }1438 },1439 '396': {1440 'api': {1441 'extension_api.json': json.dumps([1442 {1443 'namespace': 'idle'1444 },1445 {1446 'namespace': 'experimental.menus'1447 }1448 ])1449 }1450 }...

Full Screen

Full Screen

dump_test.py

Source:dump_test.py Github

copy

Full Screen

...23else:24 from collections import OrderedDict25from .context import procyon, pntest26def test_named():27 assert procyon.dumps(None) == "null\n"28 assert procyon.dumps(True) == "true\n"29 assert procyon.dumps(False) == "false\n"30 assert procyon.dumps(float("inf")) == "inf\n"31 assert procyon.dumps(float("-inf")) == "-inf\n"32 assert procyon.dumps(float("nan")) == "nan\n"33def test_scalar():34 assert procyon.dumps(0) == "0\n"35 assert procyon.dumps(0.0) == "0.0\n"36 assert procyon.dumps(1) == "1\n"37 assert procyon.dumps(-1) == "-1\n"38 assert procyon.dumps(9223372036854775807) == "9223372036854775807\n"39 assert procyon.dumps(-9223372036854775808) == "-9223372036854775808\n"40 assert procyon.dumps(5.0) == "5.0\n"41 assert procyon.dumps(0.5) == "0.5\n"42def test_int_range():43 with pytest.raises(OverflowError):44 procyon.dumps(9223372036854775808)45 with pytest.raises(OverflowError):46 procyon.dumps(-9223372036854775809)47def test_floatrounding():48 tests = [49 (-0.0000000000000020e-308, "-2e-323\n"), # 4th-least negative denormal50 (-0.0000000000000015e-308, "-1.5e-323\n"), # 3rd-least negative denormal51 (-0.0000000000000010e-308, "-1e-323\n"), # 2nd-least negative denormal52 (-0.0000000000000005e-308, "-5e-324\n"), # least negative denormal53 (+0.0000000000000000e+000, "0.0\n"), # zero54 (+0.0000000000000005e-308, "5e-324\n"), # least positive denormal55 (+0.0000000000000010e-308, "1e-323\n"), # 2nd-least positive denormal56 (+0.0000000000000015e-308, "1.5e-323\n"), # 3rd-least positive denormal57 (+2.2250738585072004e-308, "2.2250738585072004e-308\n"), # 2nd-most positive denormal58 (+2.2250738585072009e-308, "2.225073858507201e-308\n"), # most positive denormal59 (+2.2250738585072014e-308, "2.2250738585072014e-308\n"), # least positive normal60 (+2.2250738585072019e-308, "2.225073858507202e-308\n"), # 2nd-least positive normal61 (+1.9999999999999998e-001, "0.19999999999999998\n"), # previous value before 0.262 (+2.0000000000000000e-001, "0.2\n"), # 0.263 (+2.0000000000000001e-001, "0.2\n"), # More accurate repr of 0.264 (+2.0000000000000004e-001, "0.20000000000000004\n"), # next value after 0.265 (-5.0000000000000000e-001, "-0.5\n"),66 (+5.0000000000000000e-001, "0.5\n"),67 (+9.9999999999999964e+000, "9.999999999999996\n"), # two values before 1068 (+9.9999999999999982e+000, "9.999999999999998\n"), # previous value before 1069 (+1.0000000000000000e+001, "10.0\n"), # 1070 (+1.0000000000000002e+001, "10.000000000000002\n"), # next value after 1071 (+1.0000000000000000e-025, "1e-25\n"), # 10 ^ -2572 (+1.0000000000000000e-024, "1e-24\n"), # 10 ^ -2473 (+1.0000000000000000e-023, "1e-23\n"), # 10 ^ -2374 (+1.0000000000000000e-022, "1e-22\n"), # 10 ^ -2275 (+1.0000000000000000e-021, "1e-21\n"), # 10 ^ -2176 (+1.0000000000000000e-020, "1e-20\n"), # 10 ^ -2077 (+1.0000000000000000e-019, "1e-19\n"), # 10 ^ -1978 (+1.0000000000000000e-018, "1e-18\n"), # 10 ^ -1879 (+1.0000000000000000e-017, "1e-17\n"), # 10 ^ -1780 (+1.0000000000000000e-016, "1e-16\n"), # 10 ^ -1681 (+1.0000000000000000e-015, "1e-15\n"), # 10 ^ -1582 (+1.0000000000000000e-014, "1e-14\n"), # 10 ^ -1483 (+1.0000000000000000e-013, "1e-13\n"), # 10 ^ -1384 (+1.0000000000000000e-012, "1e-12\n"), # 10 ^ -1285 (+1.0000000000000000e-011, "1e-11\n"), # 10 ^ -1186 (+1.0000000000000000e-010, "1e-10\n"), # 10 ^ -1087 (+1.0000000000000000e-009, "1e-09\n"), # 10 ^ -988 (+1.0000000000000000e-008, "1e-08\n"), # 10 ^ -889 (+1.0000000000000000e-007, "1e-07\n"), # 10 ^ -790 (+1.0000000000000000e-006, "1e-06\n"), # 10 ^ -691 (+1.0000000000000000e-005, "1e-05\n"), # 10 ^ -592 (+1.0000000000000000e-004, "0.0001\n"), # 10 ^ -493 (+1.0000000000000000e-003, "0.001\n"), # 10 ^ -394 (+1.0000000000000000e-002, "0.01\n"), # 10 ^ -295 (+1.0000000000000000e-001, "0.1\n"), # 10 ^ -196 (+1.0000000000000000e+000, "1.0\n"), # 10 ^ 097 (+1.0000000000000000e+001, "10.0\n"), # 10 ^ 198 (+1.0000000000000000e+002, "100.0\n"), # 10 ^ 299 (+1.0000000000000000e+003, "1000.0\n"), # 10 ^ 3100 (+1.0000000000000000e+004, "10000.0\n"), # 10 ^ 4101 (+1.0000000000000000e+005, "100000.0\n"), # 10 ^ 5102 (+1.0000000000000000e+006, "1000000.0\n"), # 10 ^ 6103 (+1.0000000000000000e+007, "10000000.0\n"), # 10 ^ 7104 (+1.0000000000000000e+008, "100000000.0\n"), # 10 ^ 8105 (+1.0000000000000000e+009, "1000000000.0\n"), # 10 ^ 9106 (+1.0000000000000000e+010, "10000000000.0\n"), # 10 ^ 10107 (+1.0000000000000000e+011, "100000000000.0\n"), # 10 ^ 11108 (+1.0000000000000000e+012, "1000000000000.0\n"), # 10 ^ 12109 (+1.0000000000000000e+013, "10000000000000.0\n"), # 10 ^ 13110 (+1.0000000000000000e+014, "100000000000000.0\n"), # 10 ^ 14111 (+1.0000000000000000e+015, "1000000000000000.0\n"), # 10 ^ 15112 (+1.0000000000000000e+016, "1e+16\n"), # 10 ^ 16113 (+1.0000000000000000e+017, "1e+17\n"), # 10 ^ 17114 (+1.0000000000000000e+018, "1e+18\n"), # 10 ^ 18115 (+1.0000000000000000e+019, "1e+19\n"), # 10 ^ 19116 (+1.0000000000000000e+020, "1e+20\n"), # 10 ^ 20117 (+1.0000000000000000e+021, "1e+21\n"), # 10 ^ 21118 (+1.0000000000000000e+022, "1e+22\n"), # 10 ^ 22119 (+1.0000000000000000e+023, "1e+23\n"), # 10 ^ 23120 (+1.0000000000000000e+024, "1e+24\n"), # 10 ^ 24121 (+1.0000000000000000e+025, "1e+25\n"), # 10 ^ 25122 (+9.9999999999999990e-006, "9.999999999999999e-06\n"), # almost 10 ^ -5123 (+9.9999999999999990e-005, "9.999999999999999e-05\n"), # almost 10 ^ -4124 (+9.9999999999999990e-004, "0.0009999999999999998\n"), # almost 10 ^ -3125 (+9.9999999999999990e-003, "0.009999999999999998\n"), # almost 10 ^ -2126 (+9.9999999999999990e-002, "0.09999999999999999\n"), # almost 10 ^ -1127 (+9.9999999999999990e-001, "0.9999999999999999\n"), # almost 10 ^ 0128 (+9.9999999999999990e+000, "9.999999999999998\n"), # almost 10 ^ 1129 (+9.9999999999999990e+001, "99.99999999999999\n"), # almost 10 ^ 2130 (+9.9999999999999990e+002, "999.9999999999999\n"), # almost 10 ^ 3131 (+9.9999999999999990e+003, "9999.999999999998\n"), # almost 10 ^ 4132 (+9.9999999999999990e+004, "99999.99999999999\n"), # almost 10 ^ 5133 (+9.9999999999999990e+005, "999999.9999999999\n"), # almost 10 ^ 6134 (+9.9999999999999990e+006, "9999999.999999998\n"), # almost 10 ^ 7135 (+1.7976931348623155e+308, "1.7976931348623155e+308\n"), # previous value before max136 (+1.7976931348623157e+308, "1.7976931348623157e+308\n"), # float max137 (+float("inf"), "inf\n"), # next value after float max138 (1.1, "1.1\n"),139 (1.1 * 3, "3.3000000000000003\n"),140 (1023.9999999999995, "1023.9999999999995\n"),141 (1023.9999999999997, "1023.9999999999997\n"),142 (1023.9999999999998, "1023.9999999999998\n"),143 (1023.9999999999999, "1023.9999999999999\n"),144 (1024.0000000000000, "1024.0\n"),145 (1024.0000000000002, "1024.0000000000002\n"),146 (1024.0000000000005, "1024.0000000000005\n"),147 ]148 for d, s in tests:149 # First check: is the test valid? Does the representation given150 # actually encode the double value?151 assert float(s) == d152 # Second check: do we print the given representation?153 assert procyon.dumps(d) == s154def test_data():155 assert procyon.dumps(b"") == "$\n"156 assert procyon.dumps(b"\x01\x02") == "$0102\n"157 assert procyon.dumps(b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff") == (158 "$\t0011 2233 4455 6677 8899 aabb ccdd eeff\n")159 assert procyon.dumps(b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"160 b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"161 b"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99") == (162 "$\t0011 2233 4455 6677 8899 aabb ccdd eeff\n"163 "$\t0011 2233 4455 6677 8899 aabb ccdd eeff\n"164 "$\t0011 2233 4455 6677 8899\n")165def test_string():166 assert procyon.dumps("") == "\"\"\n"167 assert procyon.dumps("\0") == "\"\\u0000\"\n"168 assert procyon.dumps("\1") == "\"\\u0001\"\n"169 assert procyon.dumps("i") == "\"i\"\n"170 assert procyon.dumps("\177") == "\"\\u007f\"\n"171 assert procyon.dumps("procyon") == "\"procyon\"\n"172 assert procyon.dumps("procyon\n") == ">\tprocyon\n"173 assert procyon.dumps(174 "Four score and seven years ago our fathers brought forth on "175 "this continent a new nation, conceived in liberty, and "176 "dedicated to the proposition that all men are created equal.") == (177 ">\tFour score and seven years ago our fathers brought forth on this\n"178 ">\tcontinent a new nation, conceived in liberty, and dedicated to the\n"179 ">\tproposition that all men are created equal.\n"180 "!\n")181 assert procyon.dumps(182 "Four score and seven years ago our fathers brought forth on this "183 "continent a new nation, conceived in liberty, and dedicated to the "184 "proposition that all men are created equal.\n") == (185 ">\tFour score and seven years ago our fathers brought forth on this\n"186 ">\tcontinent a new nation, conceived in liberty, and dedicated to the\n"187 ">\tproposition that all men are created equal.\n")188 assert procyon.dumps(189 "Space: the final frontier.\n"190 "\n"191 "These are the voyages of the starship Enterprise. Its five-year "192 "mission: to explore strange new worlds, to seek out new life and new "193 "civilizations, to boldly go where no man has gone before.\n") == (194 ">\tSpace: the final frontier.\n"195 ">\n"196 ">\tThese are the voyages of the starship Enterprise. Its five-year mission:\n"197 ">\tto explore strange new worlds, to seek out new life and new\n"198 ">\tcivilizations, to boldly go where no man has gone before.\n")199 assert procyon.dumps(("…" * 72) + " \n") == (200 ">\t……………………………………………………………………………………………………………………………………………………………………………………………… \n")201 assert procyon.dumps(("…" * 71) + " \n") == (202 ">\t……………………………………………………………………………………………………………………………………………………………………………………………\n"203 ">\t \n")204 assert procyon.dumps(("…" * 70) + " … \n") == (205 ">\t…………………………………………………………………………………………………………………………………………………………………………………………\n"206 ">\t… \n")207def test_unicode():208 # Control characters:209 assert procyon.dumps("\0") == "\"\\u0000\"\n"210 assert procyon.dumps("\177") == "\"\\u007f\"\n"211 assert procyon.dumps("\u0080") == "\"\\u0080\"\n"212 # Unicode, 2 bytes:213 assert procyon.dumps("½") == "\"½\"\n"214 assert procyon.dumps("ж") == "\"ж\"\n"215 assert procyon.dumps(":\u0335") == "\":\u0335\"\n"216 # Unicode, 3 bytes:217 assert procyon.dumps("→") == "\"→\"\n"218 assert procyon.dumps("〒") == "\"〒\"\n"219 # Unicode, 4 bytes:220 assert procyon.dumps("🈀") == "\"🈀\"\n"221 assert procyon.dumps("🈐") == "\"🈐\"\n"222def test_list():223 assert procyon.dumps([None]) == "[null]\n"224 assert procyon.dumps([True, False]) == "[true, false]\n"225 assert procyon.dumps([1, 2, 3]) == "[1, 2, 3]\n"226 assert procyon.dumps([0.1, 0.2]) == "[0.1, 0.2]\n"227 assert procyon.dumps([None, True, 1, 1.0]) == "[null, true, 1, 1.0]\n"228 assert procyon.dumps(["hello"]) == "*\t\"hello\"\n"229 assert procyon.dumps(["one", "two", "three"]) == (230 "*\t\"one\"\n" # force multi-line231 "*\t\"two\"\n"232 "*\t\"three\"\n")233 assert procyon.dumps(["one\ntwo\nthree\n"]) == (234 "*\t>\tone\n" # force multi-line235 "\t|\ttwo\n"236 "\t|\tthree\n")237 assert procyon.dumps([[None]]) == "*\t[null]\n"238 assert procyon.dumps([["s"]]) == "*\t*\t\"s\"\n"239 assert procyon.dumps([("a", "b"), ("a", "b")]) == ("*\t*\t\"a\"\n"240 "\t*\t\"b\"\n"241 "*\t*\t\"a\"\n"242 "\t*\t\"b\"\n")243def test_map():244 assert procyon.dumps({"null": None}) == "{null: null}\n"245 assert procyon.dumps(OrderedDict([("t", True), ("f", False)])) == "{t: true, f: false}\n"246 assert procyon.dumps(OrderedDict([("one", 1), ("two", 2),247 ("three", 3)])) == "{one: 1, two: 2, three: 3}\n"248 assert procyon.dumps(OrderedDict([("less", 0.1),249 ("more", 0.2)])) == ("{less: 0.1, more: 0.2}\n")250 assert procyon.dumps(251 OrderedDict([252 ("null", None),253 ("bool", True),254 ("int", 1),255 ("float", 1.0),256 ])) == ("{null: null, bool: true, int: 1, float: 1.0}\n")257 assert procyon.dumps({"hello": "world"}) == ("hello: \"world\"\n")258 assert procyon.dumps(OrderedDict([259 ("1", "one"),260 ("2", "two"),261 ("3", "three"),262 ])) == ("1: \"one\"\n"263 "2: \"two\"\n"264 "3: \"three\"\n")265 assert procyon.dumps({"n": "one\ntwo\nthree\n"}) == (266 "n:\n" # force multi-line267 "\t>\tone\n"268 "\t|\ttwo\n"269 "\t|\tthree\n")270 assert procyon.dumps(OrderedDict([271 ("one", "a\nb\n"),272 ("two", "c\nd\n"),273 ])) == ("one:\n"274 "\t>\ta\n"275 "\t|\tb\n"276 "two:\n"277 "\t>\tc\n"278 "\t|\td\n")279 assert procyon.dumps(280 OrderedDict([281 ("one", "one\n"),282 ("two", 2),283 ("three", "three\n"),284 ("four", 4),285 ])) == ("one:\n"286 "\t>\tone\n"287 "two: 2\n"288 "three:\n"289 "\t>\tthree\n"290 "four: 4\n")291def test_composite():292 assert procyon.dumps(293 OrderedDict([294 ("us",295 OrderedDict([296 ("name", "United States of America"),297 ("ratio", 1.9),298 ("stars", 50),299 ("stripes", 13),300 ("colors", [301 b"\xb2\x22\x34",302 b"\xff\xff\xff",303 b"\x3c\x3b\x6e",304 ]),305 ("nicknames", [306 "The Stars and Stripes",307 "Old Glory",308 "The Star-Spangled Banner",309 ]),310 ])),311 ("cl",312 OrderedDict([313 ("name", "Republic of Chile"),314 ("ratio", 1.5),315 ("stars", 1),316 ("stripes", 2),317 ("colors", [318 b"\xda\x29\x1c",319 b"\xff\xff\xff",320 b"\x00\x33\xa0",321 ]),322 ])),323 ("cu",324 OrderedDict([325 ("name", "Republic of Cuba"),326 ("ratio", 2.0),327 ("stars", 1),328 ("stripes", 5),329 ("colors", [330 b"\xcb\x15\x15",331 b"\xff\xff\xff",332 b"\x00\x2a\x8f",333 ]),334 ])),335 ])) == ("us:\n"336 "\tname: \"United States of America\"\n"337 "\tratio: 1.9\n"338 "\tstars: 50\n"339 "\tstripes: 13\n"340 "\tcolors:\n"341 "\t\t*\t$b22234\n"342 "\t\t*\t$ffffff\n"343 "\t\t*\t$3c3b6e\n"344 "\tnicknames:\n"345 "\t\t*\t\"The Stars and Stripes\"\n"346 "\t\t*\t\"Old Glory\"\n"347 "\t\t*\t\"The Star-Spangled Banner\"\n"348 "cl:\n"349 "\tname: \"Republic of Chile\"\n"350 "\tratio: 1.5\n"351 "\tstars: 1\n"352 "\tstripes: 2\n"353 "\tcolors:\n"354 "\t\t*\t$da291c\n"355 "\t\t*\t$ffffff\n"356 "\t\t*\t$0033a0\n"357 "cu:\n"358 "\tname: \"Republic of Cuba\"\n"359 "\tratio: 2.0\n"360 "\tstars: 1\n"361 "\tstripes: 5\n"362 "\tcolors:\n"363 "\t\t*\t$cb1515\n"364 "\t\t*\t$ffffff\n"365 "\t\t*\t$002a8f\n")366def test_circular():367 # Contained within self368 with pytest.raises(ValueError):369 m = {}370 m["m"] = m371 procyon.dumps(m)372 # More deeply nested373 with pytest.raises(ValueError):374 m = {}375 m["m"] = [{"m": [m]}]376 procyon.dumps(m)377 # Not an error for an object to appear multiple times378 m = OrderedDict()379 m["a"] = [None]380 m["b"] = m["a"]381 m["c"] = [m["a"]]382 m["d"] = {"a": m["a"]}383 assert procyon.dumps(m) == (384 "a: [null]\n" # force multi-line385 "b: [null]\n"386 "c:\n"387 "\t*\t[null]\n"388 "d:\n"389 "\ta: [null]\n")390def do_dump(source):391 from procyon.dump import main392 sys.stdin = io.BytesIO(source)393 sys.stdout = io.StringIO()394 sys.stderr = io.StringIO()395 if not main(["procyon.dump"]):396 out = sys.stdout.getvalue().encode("utf-8")397 err = None...

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