How to use initialize method in Cypress

Best JavaScript code snippet using cypress

test_diff_parser.py

Source:test_diff_parser.py Github

copy

Full Screen

...30 return x_node31 return None32class Differ(object):33 grammar = load_grammar()34 def initialize(self, code):35 logging.debug('differ: initialize')36 try:37 del cache.parser_cache[self.grammar._hashed][None]38 except KeyError:39 pass40 self.lines = split_lines(code, keepends=True)41 self.module = parse(code, diff_cache=True, cache=True)42 assert code == self.module.get_code()43 _assert_valid_graph(self.module)44 return self.module45 def parse(self, code, copies=0, parsers=0, expect_error_leaves=False):46 logging.debug('differ: parse copies=%s parsers=%s', copies, parsers)47 lines = split_lines(code, keepends=True)48 diff_parser = DiffParser(49 self.grammar._pgen_grammar,50 self.grammar._tokenizer,51 self.module,52 )53 new_module = diff_parser.update(self.lines, lines)54 self.lines = lines55 assert code == new_module.get_code()56 _assert_valid_graph(new_module)57 without_diff_parser_module = parse(code)58 _assert_nodes_are_equal(new_module, without_diff_parser_module)59 error_node = _check_error_leaves_nodes(new_module)60 assert expect_error_leaves == (error_node is not None), error_node61 if parsers is not ANY:62 assert diff_parser._parser_count == parsers63 if copies is not ANY:64 assert diff_parser._copy_count == copies65 return new_module66@pytest.fixture()67def differ():68 return Differ()69def test_change_and_undo(differ):70 func_before = 'def func():\n pass\n'71 # Parse the function and a.72 differ.initialize(func_before + 'a')73 # Parse just b.74 differ.parse(func_before + 'b', copies=1, parsers=2)75 # b has changed to a again, so parse that.76 differ.parse(func_before + 'a', copies=1, parsers=2)77 # Same as before parsers should not be used. Just a simple copy.78 differ.parse(func_before + 'a', copies=1)79 # Now that we have a newline at the end, everything is easier in Python80 # syntax, we can parse once and then get a copy.81 differ.parse(func_before + 'a\n', copies=1, parsers=2)82 differ.parse(func_before + 'a\n', copies=1)83 # Getting rid of an old parser: Still no parsers used.84 differ.parse('a\n', copies=1)85 # Now the file has completely changed and we need to parse.86 differ.parse('b\n', parsers=1)87 # And again.88 differ.parse('a\n', parsers=1)89def test_positions(differ):90 func_before = 'class A:\n pass\n'91 m = differ.initialize(func_before + 'a')92 assert m.start_pos == (1, 0)93 assert m.end_pos == (3, 1)94 m = differ.parse('a', copies=1)95 assert m.start_pos == (1, 0)96 assert m.end_pos == (1, 1)97 m = differ.parse('a\n\n', parsers=1)98 assert m.end_pos == (3, 0)99 m = differ.parse('a\n\n ', copies=1, parsers=2)100 assert m.end_pos == (3, 1)101 m = differ.parse('a ', parsers=1)102 assert m.end_pos == (1, 2)103def test_if_simple(differ):104 src = dedent('''\105 if 1:106 a = 3107 ''')108 else_ = "else:\n a = ''\n"109 differ.initialize(src + 'a')110 differ.parse(src + else_ + "a", copies=0, parsers=1)111 differ.parse(else_, parsers=2, expect_error_leaves=True)112 differ.parse(src + else_, parsers=1)113def test_func_with_for_and_comment(differ):114 # The first newline is important, leave it. It should not trigger another115 # parser split.116 src = dedent("""\117 def func():118 pass119 for a in [1]:120 # COMMENT121 a""")122 differ.initialize(src)123 differ.parse('a\n' + src, copies=1, parsers=3)124def test_one_statement_func(differ):125 src = dedent("""\126 first127 def func(): a128 """)129 differ.initialize(src + 'second')130 differ.parse(src + 'def second():\n a', parsers=1, copies=1)131def test_for_on_one_line(differ):132 src = dedent("""\133 foo = 1134 for x in foo: pass135 def hi():136 pass137 """)138 differ.initialize(src)139 src = dedent("""\140 def hi():141 for x in foo: pass142 pass143 pass144 """)145 differ.parse(src, parsers=2)146 src = dedent("""\147 def hi():148 for x in foo: pass149 pass150 def nested():151 pass152 """)153 # The second parser is for parsing the `def nested()` which is an `equal`154 # operation in the SequenceMatcher.155 differ.parse(src, parsers=1, copies=1)156def test_open_parentheses(differ):157 func = 'def func():\n a\n'158 code = 'isinstance(\n\n' + func159 new_code = 'isinstance(\n' + func160 differ.initialize(code)161 differ.parse(new_code, parsers=1, expect_error_leaves=True)162 new_code = 'a = 1\n' + new_code163 differ.parse(new_code, parsers=2, expect_error_leaves=True)164 func += 'def other_func():\n pass\n'165 differ.initialize('isinstance(\n' + func)166 # Cannot copy all, because the prefix of the function is once a newline and167 # once not.168 differ.parse('isinstance()\n' + func, parsers=2, copies=1)169def test_open_parentheses_at_end(differ):170 code = "a['"171 differ.initialize(code)172 differ.parse(code, parsers=1, expect_error_leaves=True)173def test_backslash(differ):174 src = dedent(r"""175 a = 1\176 if 1 else 2177 def x():178 pass179 """)180 differ.initialize(src)181 src = dedent(r"""182 def x():183 a = 1\184 if 1 else 2185 def y():186 pass187 """)188 differ.parse(src, parsers=1)189 src = dedent(r"""190 def first():191 if foo \192 and bar \193 or baz:194 pass195 def second():196 pass197 """)198 differ.parse(src, parsers=2)199def test_full_copy(differ):200 code = 'def foo(bar, baz):\n pass\n bar'201 differ.initialize(code)202 differ.parse(code, copies=1)203def test_wrong_whitespace(differ):204 code = '''205 hello206 '''207 differ.initialize(code)208 differ.parse(code + 'bar\n ', parsers=2, expect_error_leaves=True)209 code += """abc(\npass\n """210 differ.parse(code, parsers=2, expect_error_leaves=True)211def test_issues_with_error_leaves(differ):212 code = dedent('''213 def ints():214 str..215 str216 ''')217 code2 = dedent('''218 def ints():219 str.220 str221 ''')222 differ.initialize(code)223 differ.parse(code2, parsers=1, expect_error_leaves=True)224def test_unfinished_nodes(differ):225 code = dedent('''226 class a():227 def __init__(self, a):228 self.a = a229 def p(self):230 a(1)231 ''')232 code2 = dedent('''233 class a():234 def __init__(self, a):235 self.a = a236 def p(self):237 self238 a(1)239 ''')240 differ.initialize(code)241 differ.parse(code2, parsers=2, copies=2)242def test_nested_if_and_scopes(differ):243 code = dedent('''244 class a():245 if 1:246 def b():247 2248 ''')249 code2 = code + ' else:\n 3'250 differ.initialize(code)251 differ.parse(code2, parsers=1, copies=0)252def test_word_before_def(differ):253 code1 = 'blub def x():\n'254 code2 = code1 + ' s'255 differ.initialize(code1)256 differ.parse(code2, parsers=1, copies=0, expect_error_leaves=True)257def test_classes_with_error_leaves(differ):258 code1 = dedent('''259 class X():260 def x(self):261 blablabla262 assert 3263 self.264 class Y():265 pass266 ''')267 code2 = dedent('''268 class X():269 def x(self):270 blablabla271 assert 3272 str(273 class Y():274 pass275 ''')276 differ.initialize(code1)277 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)278def test_totally_wrong_whitespace(differ):279 code1 = '''280 class X():281 raise n282 class Y():283 pass284 '''285 code2 = '''286 class X():287 raise n288 str(289 class Y():290 pass291 '''292 differ.initialize(code1)293 differ.parse(code2, parsers=2, copies=0, expect_error_leaves=True)294def test_node_insertion(differ):295 code1 = dedent('''296 class X():297 def y(self):298 a = 1299 b = 2300 c = 3301 d = 4302 ''')303 code2 = dedent('''304 class X():305 def y(self):306 a = 1307 b = 2308 str309 c = 3310 d = 4311 ''')312 differ.initialize(code1)313 differ.parse(code2, parsers=1, copies=2)314def test_whitespace_at_end(differ):315 code = dedent('str\n\n')316 differ.initialize(code)317 differ.parse(code + '\n', parsers=1, copies=1)318def test_endless_while_loop(differ):319 """320 This was a bug in Jedi #878.321 """322 code = '#dead'323 differ.initialize(code)324 module = differ.parse(code, parsers=1)325 assert module.end_pos == (1, 5)326 code = '#dead\n'327 differ.initialize(code)328 module = differ.parse(code + '\n', parsers=1)329 assert module.end_pos == (3, 0)330def test_in_class_movements(differ):331 code1 = dedent("""\332 class PlaybookExecutor:333 p334 b335 def run(self):336 1337 try:338 x339 except:340 pass341 """)342 code2 = dedent("""\343 class PlaybookExecutor:344 b345 def run(self):346 1347 try:348 x349 except:350 pass351 """)352 differ.initialize(code1)353 differ.parse(code2, parsers=1)354def test_in_parentheses_newlines(differ):355 code1 = dedent("""356 x = str(357 True)358 a = 1359 def foo():360 pass361 b = 2""")362 code2 = dedent("""363 x = str(True)364 a = 1365 def foo():366 pass367 b = 2""")368 differ.initialize(code1)369 differ.parse(code2, parsers=1, copies=1)370def test_indentation_issue(differ):371 code1 = dedent("""372 import module373 """)374 code2 = dedent("""375 class L1:376 class L2:377 class L3:378 def f(): pass379 def f(): pass380 def f(): pass381 def f(): pass382 """)383 differ.initialize(code1)384 differ.parse(code2, parsers=2)385def test_endmarker_newline(differ):386 code1 = dedent('''\387 docu = None388 # some comment389 result = codet390 incomplete_dctassign = {391 "module"392 if "a":393 x = 3 # asdf394 ''')395 code2 = code1.replace('codet', 'coded')396 differ.initialize(code1)397 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)398def test_newlines_at_end(differ):399 differ.initialize('a\n\n')400 differ.parse('a\n', copies=1)401def test_end_newline_with_decorator(differ):402 code = dedent('''\403 @staticmethod404 def spam():405 import json406 json.l''')407 differ.initialize(code)408 module = differ.parse(code + '\n', copies=1, parsers=1)409 decorated, endmarker = module.children410 assert decorated.type == 'decorated'411 decorator, func = decorated.children412 suite = func.children[-1]413 assert suite.type == 'suite'414 newline, first_stmt, second_stmt = suite.children415 assert first_stmt.get_code() == ' import json\n'416 assert second_stmt.get_code() == ' json.l\n'417def test_invalid_to_valid_nodes(differ):418 code1 = dedent('''\419 def a():420 foo = 3421 def b():422 la = 3423 else:424 la425 return426 foo427 base428 ''')429 code2 = dedent('''\430 def a():431 foo = 3432 def b():433 la = 3434 if foo:435 latte = 3436 else:437 la438 return439 foo440 base441 ''')442 differ.initialize(code1)443 differ.parse(code2, parsers=1, copies=3)444def test_if_removal_and_reappearence(differ):445 code1 = dedent('''\446 la = 3447 if foo:448 latte = 3449 else:450 la451 pass452 ''')453 code2 = dedent('''\454 la = 3455 latte = 3456 else:457 la458 pass459 ''')460 code3 = dedent('''\461 la = 3462 if foo:463 latte = 3464 else:465 la466 ''')467 differ.initialize(code1)468 differ.parse(code2, parsers=3, copies=2, expect_error_leaves=True)469 differ.parse(code1, parsers=1, copies=1)470 differ.parse(code3, parsers=1, copies=1)471def test_add_error_indentation(differ):472 code = 'if x:\n 1\n'473 differ.initialize(code)474 differ.parse(code + ' 2\n', parsers=1, copies=0, expect_error_leaves=True)475def test_differing_docstrings(differ):476 code1 = dedent('''\477 def foobar(x, y):478 1479 return x480 def bazbiz():481 foobar()482 lala483 ''')484 code2 = dedent('''\485 def foobar(x, y):486 2487 return x + y488 def bazbiz():489 z = foobar()490 lala491 ''')492 differ.initialize(code1)493 differ.parse(code2, parsers=2, copies=1)494 differ.parse(code1, parsers=2, copies=1)495def test_one_call_in_function_change(differ):496 code1 = dedent('''\497 def f(self):498 mro = [self]499 for a in something:500 yield a501 def g(self):502 return C(503 a=str,504 b=self,505 )506 ''')507 code2 = dedent('''\508 def f(self):509 mro = [self]510 def g(self):511 return C(512 a=str,513 t514 b=self,515 )516 ''')517 differ.initialize(code1)518 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)519 differ.parse(code1, parsers=2, copies=1)520def test_function_deletion(differ):521 code1 = dedent('''\522 class C(list):523 def f(self):524 def iterate():525 for x in b:526 break527 return list(iterate())528 ''')529 code2 = dedent('''\530 class C():531 def f(self):532 for x in b:533 break534 return list(iterate())535 ''')536 differ.initialize(code1)537 differ.parse(code2, parsers=1, copies=0, expect_error_leaves=True)538 differ.parse(code1, parsers=1, copies=0)539def test_docstring_removal(differ):540 code1 = dedent('''\541 class E(Exception):542 """543 1544 2545 3546 """547 class S(object):548 @property549 def f(self):550 return cmd551 def __repr__(self):552 return cmd2553 ''')554 code2 = dedent('''\555 class E(Exception):556 """557 1558 3559 """560 class S(object):561 @property562 def f(self):563 return cmd564 return cmd2565 ''')566 differ.initialize(code1)567 differ.parse(code2, parsers=1, copies=2)568 differ.parse(code1, parsers=3, copies=1)569def test_paren_in_strange_position(differ):570 code1 = dedent('''\571 class C:572 """ ha """573 def __init__(self, message):574 self.message = message575 ''')576 code2 = dedent('''\577 class C:578 """ ha """579 )580 def __init__(self, message):581 self.message = message582 ''')583 differ.initialize(code1)584 differ.parse(code2, parsers=1, copies=2, expect_error_leaves=True)585 differ.parse(code1, parsers=0, copies=2)586def insert_line_into_code(code, index, line):587 lines = split_lines(code, keepends=True)588 lines.insert(index, line)589 return ''.join(lines)590def test_paren_before_docstring(differ):591 code1 = dedent('''\592 # comment593 """594 The595 """596 from parso import tree597 from parso import python598 ''')599 code2 = insert_line_into_code(code1, 1, ' ' * 16 + 'raise InternalParseError(\n')600 differ.initialize(code1)601 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)602 differ.parse(code1, parsers=2, copies=1)603def test_parentheses_before_method(differ):604 code1 = dedent('''\605 class A:606 def a(self):607 pass608 class B:609 def b(self):610 if 1:611 pass612 ''')613 code2 = dedent('''\614 class A:615 def a(self):616 pass617 Exception.__init__(self, "x" %618 def b(self):619 if 1:620 pass621 ''')622 differ.initialize(code1)623 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)624 differ.parse(code1, parsers=2, copies=1)625def test_indentation_issues(differ):626 code1 = dedent('''\627 class C:628 def f():629 1630 if 2:631 return 3632 def g():633 to_be_removed634 pass635 ''')636 code2 = dedent('''\637 class C:638 def f():639 1640 ``something``, very ``weird``).641 if 2:642 return 3643 def g():644 to_be_removed645 pass646 ''')647 code3 = dedent('''\648 class C:649 def f():650 1651 if 2:652 return 3653 def g():654 pass655 ''')656 differ.initialize(code1)657 differ.parse(code2, parsers=3, copies=1, expect_error_leaves=True)658 differ.parse(code1, copies=1, parsers=2)659 differ.parse(code3, parsers=2, copies=1)660 differ.parse(code1, parsers=2, copies=1)661def test_error_dedent_issues(differ):662 code1 = dedent('''\663 while True:664 try:665 1666 except KeyError:667 if 2:668 3669 except IndexError:670 4671 5672 ''')673 code2 = dedent('''\674 while True:675 try:676 except KeyError:677 1678 except KeyError:679 if 2:680 3681 except IndexError:682 4683 something_inserted684 5685 ''')686 differ.initialize(code1)687 differ.parse(code2, parsers=3, copies=0, expect_error_leaves=True)688 differ.parse(code1, parsers=1, copies=0)689def test_random_text_insertion(differ):690 code1 = dedent('''\691class C:692 def f():693 return node694 def g():695 try:696 1697 except KeyError:698 2699 ''')700 code2 = dedent('''\701class C:702 def f():703 return node704Some'random text: yeah705 for push in plan.dfa_pushes:706 def g():707 try:708 1709 except KeyError:710 2711 ''')712 differ.initialize(code1)713 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)714 differ.parse(code1, parsers=2, copies=1)715def test_many_nested_ifs(differ):716 code1 = dedent('''\717 class C:718 def f(self):719 def iterate():720 if 1:721 yield t722 else:723 yield724 return725 def g():726 3727 ''')728 code2 = dedent('''\729 def f(self):730 def iterate():731 if 1:732 yield t733 hahahaha734 if 2:735 else:736 yield737 return738 def g():739 3740 ''')741 differ.initialize(code1)742 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)743 differ.parse(code1, parsers=1, copies=1)744@pytest.mark.skipif(sys.version_info < (3, 5), reason="Async starts working in 3.5")745@pytest.mark.parametrize('prefix', ['', 'async '])746def test_with_and_funcdef_in_call(differ, prefix):747 code1 = prefix + dedent('''\748 with x:749 la = C(750 a=1,751 b=2,752 c=3,753 )754 ''')755 code2 = insert_line_into_code(code1, 3, 'def y(self, args):\n')756 differ.initialize(code1)757 differ.parse(code2, parsers=1, expect_error_leaves=True)758 differ.parse(code1, parsers=1)759def test_wrong_backslash(differ):760 code1 = dedent('''\761 def y():762 1763 for x in y:764 continue765 ''')766 code2 = insert_line_into_code(code1, 3, '\\.whl$\n')767 differ.initialize(code1)768 differ.parse(code2, parsers=3, copies=1, expect_error_leaves=True)769 differ.parse(code1, parsers=1, copies=1)770def test_random_unicode_characters(differ):771 """772 Those issues were all found with the fuzzer.773 """774 differ.initialize('')775 differ.parse(u'\x1dĔBϞɛˁşʑ˳˻ȣſéÎ\x90̕ȟòwʘ\x1dĔBϞɛˁşʑ˳˻ȣſéÎ', parsers=1,776 expect_error_leaves=True)777 differ.parse(u'\r\r', parsers=1)778 differ.parse(u"˟Ę\x05À\r rúƣ@\x8a\x15r()\n", parsers=1, expect_error_leaves=True)779 differ.parse(u'a\ntaǁ\rGĒōns__\n\nb', parsers=1,780 expect_error_leaves=sys.version_info[0] == 2)781 s = ' if not (self, "_fi\x02\x0e\x08\n\nle"):'782 differ.parse(s, parsers=1, expect_error_leaves=True)783 differ.parse('')784 differ.parse(s + '\n', parsers=1, expect_error_leaves=True)785 differ.parse(u' result = (\r\f\x17\t\x11res)', parsers=1, expect_error_leaves=True)786 differ.parse('')787 differ.parse(' a( # xx\ndef', parsers=1, expect_error_leaves=True)788def test_dedent_end_positions(differ):789 code1 = dedent('''\790 if 1:791 if b:792 2793 c = {794 5}795 ''')796 code2 = dedent(u'''\797 if 1:798 if ⌟ഒᜈྡྷṭb:799 2800 'l': ''}801 c = {802 5}803 ''')804 differ.initialize(code1)805 differ.parse(code2, parsers=1, expect_error_leaves=True)806 differ.parse(code1, parsers=1)807def test_special_no_newline_ending(differ):808 code1 = dedent('''\809 1810 ''')811 code2 = dedent('''\812 1813 is ''')814 differ.initialize(code1)815 differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)816 differ.parse(code1, copies=1, parsers=0)817def test_random_character_insertion(differ):818 code1 = dedent('''\819 def create(self):820 1821 if self.path is not None:822 return823 # 3824 # 4825 ''')826 code2 = dedent('''\827 def create(self):828 1829 if 2:830 x return831 # 3832 # 4833 ''')834 differ.initialize(code1)835 differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)836 differ.parse(code1, copies=1, parsers=1)837def test_import_opening_bracket(differ):838 code1 = dedent('''\839 1840 2841 from bubu import (X,842 ''')843 code2 = dedent('''\844 11845 2846 from bubu import (X,847 ''')848 differ.initialize(code1)849 differ.parse(code2, copies=1, parsers=2, expect_error_leaves=True)850 differ.parse(code1, copies=1, parsers=2, expect_error_leaves=True)851def test_opening_bracket_at_end(differ):852 code1 = dedent('''\853 class C:854 1855 [856 ''')857 code2 = dedent('''\858 3859 class C:860 1861 [862 ''')863 differ.initialize(code1)864 differ.parse(code2, copies=1, parsers=2, expect_error_leaves=True)865 differ.parse(code1, copies=1, parsers=1, expect_error_leaves=True)866def test_all_sorts_of_indentation(differ):867 code1 = dedent('''\868 class C:869 1870 def f():871 'same'872 if foo:873 a = b874 end875 ''')876 code2 = dedent('''\877 class C:878 1879 def f(yield await %|(880 'same'881 \x02\x06\x0f\x1c\x11882 if foo:883 a = b884 end885 ''')886 differ.initialize(code1)887 differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)888 differ.parse(code1, copies=1, parsers=1, expect_error_leaves=True)889 code3 = dedent('''\890 if 1:891 a892 b893 c894 d895 \x00896 ''')897 differ.parse(code3, parsers=1, expect_error_leaves=True)898 differ.parse('')899def test_dont_copy_dedents_in_beginning(differ):900 code1 = dedent('''\901 a902 4903 ''')904 code2 = dedent('''\905 1906 2907 3908 4909 ''')910 differ.initialize(code1)911 differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)912 differ.parse(code1, parsers=1, copies=1)913def test_dont_copy_error_leaves(differ):914 code1 = dedent('''\915 def f(n):916 x917 if 2:918 3919 ''')920 code2 = dedent('''\921 def f(n):922 def if 1:923 indent924 x925 if 2:926 3927 ''')928 differ.initialize(code1)929 differ.parse(code2, parsers=1, expect_error_leaves=True)930 differ.parse(code1, parsers=1)931def test_error_dedent_in_between(differ):932 code1 = dedent('''\933 class C:934 def f():935 a936 if something:937 x938 z939 ''')940 code2 = dedent('''\941 class C:942 def f():943 a944 dedent945 if other_thing:946 b947 if something:948 x949 z950 ''')951 differ.initialize(code1)952 differ.parse(code2, copies=1, parsers=2, expect_error_leaves=True)953 differ.parse(code1, copies=1, parsers=2)954def test_some_other_indentation_issues(differ):955 code1 = dedent('''\956 class C:957 x958 def f():959 ""960 copied961 a962 ''')963 code2 = dedent('''\964 try:965 de966 a967 b968 c969 d970 def f():971 ""972 copied973 a974 ''')975 differ.initialize(code1)976 differ.parse(code2, copies=0, parsers=1, expect_error_leaves=True)977 differ.parse(code1, copies=1, parsers=1)978def test_open_bracket_case1(differ):979 code1 = dedent('''\980 class C:981 1982 2 # ha983 ''')984 code2 = insert_line_into_code(code1, 2, ' [str\n')985 code3 = insert_line_into_code(code2, 4, ' str\n')986 differ.initialize(code1)987 differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)988 differ.parse(code3, copies=1, parsers=1, expect_error_leaves=True)989 differ.parse(code1, copies=1, parsers=1)990def test_open_bracket_case2(differ):991 code1 = dedent('''\992 class C:993 def f(self):994 (995 b996 c997 def g(self):998 d999 ''')1000 code2 = dedent('''\1001 class C:1002 def f(self):1003 (1004 b1005 c1006 self.1007 def g(self):1008 d1009 ''')1010 differ.initialize(code1)1011 differ.parse(code2, copies=0, parsers=1, expect_error_leaves=True)1012 differ.parse(code1, copies=0, parsers=1, expect_error_leaves=True)1013def test_some_weird_removals(differ):1014 code1 = dedent('''\1015 class C:1016 11017 ''')1018 code2 = dedent('''\1019 class C:1020 11021 @property1022 A1023 return1024 # x1025 omega1026 ''')1027 code3 = dedent('''\1028 class C:1029 11030 ;1031 omega1032 ''')1033 differ.initialize(code1)1034 differ.parse(code2, copies=1, parsers=1, expect_error_leaves=True)1035 differ.parse(code3, copies=1, parsers=3, expect_error_leaves=True)1036 differ.parse(code1, copies=1)1037@pytest.mark.skipif(sys.version_info < (3, 5), reason="Async starts working in 3.5")1038def test_async_copy(differ):1039 code1 = dedent('''\1040 async def main():1041 x = 31042 print(1043 ''')1044 code2 = dedent('''\1045 async def main():1046 x = 31047 print()1048 ''')1049 differ.initialize(code1)1050 differ.parse(code2, copies=1, parsers=1)1051 differ.parse(code1, copies=1, parsers=1, expect_error_leaves=True)1052def test_parent_on_decorator(differ):1053 code1 = dedent('''\1054 class AClass:1055 @decorator()1056 def b_test(self):1057 print("Hello")1058 print("world")1059 def a_test(self):1060 pass''')1061 code2 = dedent('''\1062 class AClass:1063 @decorator()1064 def b_test(self):1065 print("Hello")1066 print("world")1067 def a_test(self):1068 pass''')1069 differ.initialize(code1)1070 module_node = differ.parse(code2, parsers=1)1071 cls = module_node.children[0]1072 cls_suite = cls.children[-1]1073 assert len(cls_suite.children) == 31074def test_wrong_indent_in_def(differ):1075 code1 = dedent('''\1076 def x():1077 a1078 b1079 ''')1080 code2 = dedent('''\1081 def x():1082 //1083 b1084 c1085 ''')1086 differ.initialize(code1)1087 differ.parse(code2, parsers=1, expect_error_leaves=True)1088 differ.parse(code1, parsers=1)1089def test_backslash_issue(differ):1090 code1 = dedent('''1091 pre = (1092 '')1093 after = 'instead'1094 ''')1095 code2 = dedent('''1096 pre = (1097 '')1098 \\if 1099 ''')1100 differ.initialize(code1)1101 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)1102 differ.parse(code1, parsers=1, copies=1)1103def test_paren_with_indentation(differ):1104 code1 = dedent('''1105 class C:1106 def f(self, fullname, path=None):1107 x1108 def load_module(self, fullname):1109 a1110 for prefix in self.search_path:1111 try:1112 b1113 except ImportError:1114 c1115 else:1116 raise1117 def x():1118 pass1119 ''')1120 code2 = dedent('''1121 class C:1122 def f(self, fullname, path=None):1123 x1124 (1125 a1126 for prefix in self.search_path:1127 try:1128 b1129 except ImportError:1130 c1131 else:1132 raise1133 ''')1134 differ.initialize(code1)1135 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)1136 differ.parse(code1, parsers=3, copies=1)1137def test_error_dedent_in_function(differ):1138 code1 = dedent('''\1139 def x():1140 a1141 b1142 c1143 d1144 ''')1145 code2 = dedent('''\1146 def x():1147 a1148 b1149 c1150 d1151 e1152 ''')1153 differ.initialize(code1)1154 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)1155def test_with_formfeed(differ):1156 code1 = dedent('''\1157 @bla1158 async def foo():1159 11160 yield from []1161 return1162 return ''1163 ''')1164 code2 = dedent('''\1165 @bla1166 async def foo():1167 11168 \x0cimport 1169 return1170 return ''1171 ''')1172 differ.initialize(code1)1173 differ.parse(code2, parsers=ANY, copies=ANY, expect_error_leaves=True)1174def test_repeating_invalid_indent(differ):1175 code1 = dedent('''\1176 def foo():1177 return1178 @bla1179 a1180 def foo():1181 a1182 b1183 c1184 ''')1185 code2 = dedent('''\1186 def foo():1187 return1188 @bla1189 a1190 b1191 c1192 ''')1193 differ.initialize(code1)1194 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)1195def test_another_random_indent(differ):1196 code1 = dedent('''\1197 def foo():1198 a1199 b1200 c1201 return1202 def foo():1203 d1204 ''')1205 code2 = dedent('''\1206 def foo():1207 a1208 c1209 return1210 def foo():1211 d1212 ''')1213 differ.initialize(code1)1214 differ.parse(code2, parsers=1, copies=3)1215def test_invalid_function(differ):1216 code1 = dedent('''\1217 a1218 def foo():1219 def foo():1220 b1221 ''')1222 code2 = dedent('''\1223 a1224 def foo():1225 def foo():1226 b1227 ''')1228 differ.initialize(code1)1229 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)1230def test_async_func2(differ):1231 code1 = dedent('''\1232 async def foo():1233 return ''1234 @bla1235 async def foo():1236 x1237 ''')1238 code2 = dedent('''\1239 async def foo():1240 return ''1241 {1242 @bla1243 async def foo():1244 x1245 y1246 ''')1247 differ.initialize(code1)1248 differ.parse(code2, parsers=ANY, copies=ANY, expect_error_leaves=True)1249def test_weird_ending(differ):1250 code1 = dedent('''\1251 def foo():1252 a1253 return1254 ''')1255 code2 = dedent('''\1256 def foo():1257 a1258 nonlocal xF"""1259 y"""''')1260 differ.initialize(code1)1261 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)1262def test_nested_class(differ):1263 code1 = dedent('''\1264def c():1265 a = 31266 class X:1267 b1268 ''')1269 code2 = dedent('''\1270def c():1271 a = 31272 class X:1273 elif1274 ''')1275 differ.initialize(code1)1276 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)1277def test_class_with_paren_breaker(differ):1278 code1 = dedent('''\1279class Grammar:1280 x1281 def parse():1282 y1283 parser(1284 )1285 z1286 ''')1287 code2 = dedent('''\1288class Grammar:1289 x1290 def parse():1291 y1292 parser(1293 finally ;1294 )1295 z1296 ''')1297 differ.initialize(code1)1298 differ.parse(code2, parsers=3, copies=1, expect_error_leaves=True)1299def test_byte_order_mark(differ):1300 code2 = dedent('''\1301 x1302 \ufeff1303 else :1304 ''')1305 differ.initialize('\n')1306 differ.parse(code2, parsers=2, expect_error_leaves=True)1307 code3 = dedent('''\1308 \ufeff1309 if:1310 x1311 ''')1312 differ.initialize('\n')1313 differ.parse(code3, parsers=2, expect_error_leaves=True)1314def test_byte_order_mark2(differ):1315 code = u'\ufeff# foo'1316 differ.initialize(code)1317 differ.parse(code + 'x', parsers=ANY)1318def test_byte_order_mark3(differ):1319 code1 = u"\ufeff#\ny\n"1320 code2 = u'x\n\ufeff#\n\ufeff#\ny\n'1321 differ.initialize(code1)1322 differ.parse(code2, expect_error_leaves=True, parsers=ANY, copies=ANY)1323 differ.parse(code1, parsers=1)1324def test_backslash_insertion(differ):1325 code1 = dedent('''1326 def f():1327 x1328 def g():1329 base = "" \\1330 ""1331 return1332 ''')1333 code2 = dedent('''1334 def f():1335 x1336 def g():1337 base = "" \\1338 def h():1339 ""1340 return1341 ''')1342 differ.initialize(code1)1343 differ.parse(code2, parsers=2, copies=1, expect_error_leaves=True)1344 differ.parse(code1, parsers=2, copies=1)1345def test_fstring_with_error_leaf(differ):1346 code1 = dedent("""\1347 def f():1348 x1349 def g():1350 y1351 """)1352 code2 = dedent("""\1353 def f():1354 x1355 F'''1356 def g():1357 y1358 {a1359 \x011360 """)1361 differ.initialize(code1)1362 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)1363def test_yet_another_backslash(differ):1364 code1 = dedent('''\1365 def f():1366 x1367 def g():1368 y1369 base = "" \\1370 "" % to1371 return1372 ''')1373 code2 = dedent('''\1374 def f():1375 x1376 def g():1377 y1378 base = "" \\1379 \x0f1380 return1381 ''')1382 differ.initialize(code1)1383 differ.parse(code2, parsers=ANY, copies=ANY, expect_error_leaves=True)1384 differ.parse(code1, parsers=ANY, copies=ANY)1385def test_backslash_before_def(differ):1386 code1 = dedent('''\1387 def f():1388 x1389 def g():1390 y1391 z1392 ''')1393 code2 = dedent('''\1394 def f():1395 x1396 >\\1397 def g():1398 y1399 x1400 z1401 ''')1402 differ.initialize(code1)1403 differ.parse(code2, parsers=3, copies=1, expect_error_leaves=True)1404def test_backslash_with_imports(differ):1405 code1 = dedent('''\1406 from x import y, \\1407 ''')1408 code2 = dedent('''\1409 from x import y, \\1410 z1411 ''')1412 differ.initialize(code1)1413 differ.parse(code2, parsers=1)1414 differ.parse(code1, parsers=1)1415def test_one_line_function_error_recovery(differ):1416 code1 = dedent('''\1417 class X:1418 x1419 def y(): word """1420 # a1421 # b1422 c(self)1423 ''')1424 code2 = dedent('''\1425 class X:1426 x1427 def y(): word """1428 # a1429 # b1430 c(\x01+self)1431 ''')1432 differ.initialize(code1)1433 differ.parse(code2, parsers=1, copies=1, expect_error_leaves=True)1434def test_one_line_property_error_recovery(differ):1435 code1 = dedent('''\1436 class X:1437 x1438 @property1439 def encoding(self): True -1440 return 11441 ''')1442 code2 = dedent('''\1443 class X:1444 x1445 @property1446 def encoding(self): True -1447 return 11448 ''')1449 differ.initialize(code1)...

Full Screen

Full Screen

app.py

Source:app.py Github

copy

Full Screen

1from flask import Flask, jsonify2from flask_restful import Api3from dotenv import load_dotenv4from flask_cors import CORS5from resources.authenticate.sys_auth_routes import fn_sys_auth_initialize_routes6from resources.inventory.inv_routes import fn_inv_initialize_routes7from resources.reports.dashboards.dashboard_routes import fn_dashboard_initialize_routes8from resources.sales.sls_routes import fn_sls_initialize_routes9from resources.reports.pdfs.pdf_routes import fn_pdfs_initialize_routes10from resources.organization.org_routes import fn_org_initialize_routes11from resources.system.sys_routes import fn_sys_initialize_routes12from resources.security.sec_routes import fn_sec_initialize_routes13from resources.account.act_routes import fn_act_initialize_routes14from resources.crm.crm_routes import fn_crm_initialize_routes15from resources.utils.crypto.sys_crypto_routes import fn_sys_crypto_routes16from resources.service.srv_routes import fn_srv_initialize_routes17from resources.communication.old_sms.sms_routes import fn_sms_initialize_routes18from resources.communication.old_email.email_routes import fn_email_initialize_routes19from resources.communication.old_whatsapp.whatsapp_routes import fn_whatsapp_initialize_routes20from resources.document.fileManagement.doc_routes import fn_doc_file_management_initialize_routes21from resources.school.sch_routes import fn_sch_initialize_routes22from resources.communication.IndividualMessage.individual_message_routes import fn_individual_message_initialize_routes23from resources.utils.AWS.aws_routes import fn_comm_aws_initialize_routes24from resources.communication.sms.sms_routes import fn_comm_sms_initialize_routes25from resources.communication.batchHistory.batch_history_routes import fn_comm_batch_history_initialize_routes26from resources.communication.batchEmail.email_routes import fn_comm_email_initialize_routes27from resources.communication.batchWhatsapp.whatsapp_routes import fn_comm_whatsapp_initialize_routes28from resources.communication.productMessage.product_routes import fn_com_product_message_initialize_routes29from resources.vehicle.vhc_routes import fn_vhc_initialize_routes30from resources.communication.ssm.ssm_routes import fn_comm_ssm_initialize_routes31from resources.communication.communicationMessage.comm_message_routes import fn_com_message_initialize_routes32from resources.rewards.rwd_routes import fn_rwd_initialize_routes33from resources.transport.trns_routes import fn_trns_initialize_routes34from resources.home.hom_routes import fn_hom_initialize_routes35from resources.ngo.ngo_routes import fn_ngo_initialize_routes36from resources.communication.school.school_routes import fn_com_school_initialize_routes37from resources.ordermanagement.odr_routes import fn_odr_initialize_routes38# Lookups paths39from resources.lookups.inventory.lkp_inv_routes import fn_lkp_inv_initialize_routes40from resources.lookups.organization.lkp_org_routes import fn_lkp_org_initialize_routes41from resources.lookups.account.lkp_act_routes import fn_lkp_act_initialize_routes42from resources.lookups.crm.lkp_crm_routes import fn_lkp_crm_initialize_routes43from resources.lookups.system.lkp_sys_routes import fn_lkp_sys_initialize_routes44from resources.lookups.communication.lkp_com_routes import fn_lkp_com_initialize_routes45from resources.lookups.school.lkp_sch_routes import fn_lkp_sch_initialize_routes46from resources.lookups.document.lkp_doc_routes import fn_lkp_doc_initialize_routes47from resources.lookups.security.lkp_sec_routes import fn_lkp_sec_initialize_routes48from resources.lookups.service.lkp_srv_routes import fn_lkp_srv_initialize_routes49from resources.lookups.vehicle.lkp_vhc_routes import fn_lkp_vhc_initialize_routes50from resources.lookups.sales.lkp_sls_routes import fn_lkp_sls_initialize_routes51from resources.lookups.rewards.lkp_rwd_routes import fn_lkp_rwd_initialize_routes52from resources.lookups.transport.lkp_tpt_routes import fn_lkp_tpt_initialize_routes53from resources.lookups.ngo.lkp_ngo_routes import fn_lkp_ngo_initialize_routes54from resources.lookups.orderManagement.lkp_odm_routes import fn_lkp_odm_initialize_routes55from shared import read_image56app = Flask(__name__)57CORS(app, resources={r"/api/*": {"origins": "*"}})58api = Api(app)59# Route60fn_sys_auth_initialize_routes(api)61fn_inv_initialize_routes(api)62fn_dashboard_initialize_routes(api)63fn_sls_initialize_routes(api)64fn_pdfs_initialize_routes(api)65fn_org_initialize_routes(api)66fn_sys_initialize_routes(api)67fn_sec_initialize_routes(api)68fn_act_initialize_routes(api)69fn_crm_initialize_routes(api)70fn_sys_crypto_routes(api)71fn_srv_initialize_routes(api)72fn_sms_initialize_routes(api)73fn_email_initialize_routes(api)74fn_whatsapp_initialize_routes(api)75fn_doc_file_management_initialize_routes(api)76fn_sch_initialize_routes(api)77fn_individual_message_initialize_routes(api)78fn_comm_aws_initialize_routes(api)79fn_comm_sms_initialize_routes(api)80fn_comm_batch_history_initialize_routes(api)81fn_comm_email_initialize_routes(api)82fn_comm_whatsapp_initialize_routes(api)83fn_com_product_message_initialize_routes(api)84fn_vhc_initialize_routes(api)85fn_comm_ssm_initialize_routes(api)86fn_com_message_initialize_routes(api)87fn_rwd_initialize_routes(api)88fn_trns_initialize_routes(api)89fn_hom_initialize_routes(api)90fn_ngo_initialize_routes(api)91fn_com_school_initialize_routes(api)92fn_odr_initialize_routes(api)93fn_lkp_inv_initialize_routes(api)94fn_lkp_org_initialize_routes(api)95fn_lkp_act_initialize_routes(api)96fn_lkp_crm_initialize_routes(api)97fn_lkp_sys_initialize_routes(api)98fn_lkp_com_initialize_routes(api)99fn_lkp_sch_initialize_routes(api)100fn_lkp_doc_initialize_routes(api)101fn_lkp_sec_initialize_routes(api)102fn_lkp_srv_initialize_routes(api)103fn_lkp_vhc_initialize_routes(api)104fn_lkp_sls_initialize_routes(api)105fn_lkp_rwd_initialize_routes(api)106fn_lkp_tpt_initialize_routes(api)107fn_lkp_ngo_initialize_routes(api)108fn_lkp_odm_initialize_routes(api)109# @app.route('/image')110# def test():111# return jsonify({"base64": read_image('bofa', 'test.png', 'tss-test-bucket')})112if __name__ == "__main__":113 load_dotenv()...

Full Screen

Full Screen

initialize_params_parser.py

Source:initialize_params_parser.py Github

copy

Full Screen

1"""Module containing the InitializeParams parser.2This parser handles the following tasks for the InitializeParams:3- storage / accessibility outside the initialize request4- configuring option defaults5- organizing initialization values in one place6"""7from typing import List, Optional8from pygls.types import InitializeParams, MarkupKind9from .pygls_utils import rgetattr10try:11 from functools import cached_property # type: ignore12except ImportError:13 from cached_property import cached_property14# pylint: disable=line-too-long15# pylint: disable=invalid-name16# pylint: disable=missing-function-docstring17class InitializeParamsParser:18 """Class to parse and manage InitializeParams."""19 def __init__(self) -> None:20 self._initialize_params_store: Optional[InitializeParams] = None21 @cached_property22 def _initialize_params(self) -> InitializeParams:23 """Get the initialize params."""24 if self._initialize_params_store is None:25 raise ValueError("InitializeParams not set")26 return self._initialize_params_store27 def set_initialize_params(self, params: InitializeParams) -> None:28 """Set the initialize params."""29 self._initialize_params_store = params30 @cached_property31 def capabilities_textDocument_completion_completionItem_documentationFormat(32 self,33 ) -> List[MarkupKind]:34 _path = (35 "capabilities",36 "textDocument",37 "completion",38 "completionItem",39 "documentationFormat",40 )41 path = ".".join(_path)42 default = [MarkupKind.PlainText]43 return rgetattr(self._initialize_params, path, default) # type: ignore44 @cached_property45 def capabilities_textDocument_completion_completionItem_snippetSupport(46 self,47 ) -> bool:48 _path = (49 "capabilities",50 "textDocument",51 "completion",52 "completionItem",53 "snippetSupport",54 )55 path = ".".join(_path)56 default = False57 return bool(rgetattr(self._initialize_params, path, default))58 @cached_property59 def capabilities_textDocument_documentSymbol_hierarchicalDocumentSymbolSupport(60 self,61 ) -> bool:62 _path = (63 "capabilities",64 "textDocument",65 "documentSymbol",66 "hierarchicalDocumentSymbolSupport",67 )68 path = ".".join(_path)69 default = False70 return bool(rgetattr(self._initialize_params, path, default))71 @cached_property72 def capabilities_textDocument_hover_contentFormat(73 self,74 ) -> List[MarkupKind]:75 _path = (76 "capabilities",77 "textDocument",78 "hover",79 "contentFormat",80 )81 path = ".".join(_path)82 default = [MarkupKind.PlainText]83 return rgetattr(self._initialize_params, path, default) # type: ignore84 @cached_property85 def capabilities_textDocument_signatureHelp_contentFormat(86 self,87 ) -> List[str]:88 _path = (89 "capabilities",90 "textDocument",91 "hover",92 "contentFormat",93 )94 path = ".".join(_path)95 default = [MarkupKind.PlainText]96 return rgetattr(self._initialize_params, path, default) # type: ignore97 @cached_property98 def initializationOptions_markupKindPreferred(99 self,100 ) -> Optional[MarkupKind]:101 _path = (102 "initializationOptions",103 "markupKindPreferred",104 )105 path = ".".join(_path)106 result = rgetattr(self._initialize_params, path)107 return result if result is None else MarkupKind(result)108 @cached_property109 def initializationOptions_completion_disableSnippets(self) -> bool:110 _path = (111 "initializationOptions",112 "completion",113 "disableSnippets",114 )115 path = ".".join(_path)116 default = False117 return bool(rgetattr(self._initialize_params, path, default))118 @cached_property119 def initializationOptions_diagnostics_enable(self) -> bool:120 _path = (121 "initializationOptions",122 "diagnostics",123 "enable",124 )125 path = ".".join(_path)126 default = True127 return bool(rgetattr(self._initialize_params, path, default))128 @cached_property129 def initializationOptions_diagnostics_didOpen(self) -> bool:130 _path = (131 "initializationOptions",132 "diagnostics",133 "didOpen",134 )135 path = ".".join(_path)136 default = True137 return bool(rgetattr(self._initialize_params, path, default))138 @cached_property139 def initializationOptions_diagnostics_didSave(self) -> bool:140 _path = (141 "initializationOptions",142 "diagnostics",143 "didSave",144 )145 path = ".".join(_path)146 default = True147 return bool(rgetattr(self._initialize_params, path, default))148 @cached_property149 def initializationOptions_diagnostics_didChange(self) -> bool:150 _path = (151 "initializationOptions",152 "diagnostics",153 "didChange",154 )155 path = ".".join(_path)156 default = True157 return bool(rgetattr(self._initialize_params, path, default))158 @cached_property159 def initializationOptions_jediSettings_autoImportModules(160 self,161 ) -> List[str]:162 _path = (163 "initializationOptions",164 "jediSettings",165 "autoImportModules",166 )167 path = ".".join(_path)168 default: List[str] = []...

Full Screen

Full Screen

test_payment_initialize.py

Source:test_payment_initialize.py Github

copy

Full Screen

...21 }22}23"""24@patch.object(PluginsManager, "initialize_payment")25def test_payment_initialize(mocked_initialize_payment, api_client, channel_USD):26 exected_initialize_payment_response = InitializedPaymentResponse(27 gateway="gateway.id",28 name="PaymentPluginName",29 data={30 "epochTimestamp": 1604652056653,31 "expiresAt": 1604655656653,32 "merchantSessionIdentifier": "SSH5EFCB46BA25C4B14B3F37795A7F5B974_BB8E",33 },34 )35 mocked_initialize_payment.return_value = exected_initialize_payment_response36 query = PAYMENT_INITIALIZE_MUTATION37 variables = {38 "gateway": exected_initialize_payment_response.gateway,39 "channel": channel_USD.slug,...

Full Screen

Full Screen

_tables_module.py

Source:_tables_module.py Github

copy

Full Screen

...32from nfv_vim.tables._volume_snapshot_table import volume_snapshot_table_finalize33from nfv_vim.tables._volume_snapshot_table import volume_snapshot_table_initialize34from nfv_vim.tables._volume_table import volume_table_finalize35from nfv_vim.tables._volume_table import volume_table_initialize36def tables_initialize():37 """38 Initialize the tables package39 """40 image_table_initialize()41 volume_table_initialize()42 volume_snapshot_table_initialize()43 tenant_table_initialize()44 subnet_table_initialize()45 network_table_initialize()46 system_table_initialize()47 host_table_initialize()48 host_group_table_initialize()49 hypervisor_table_initialize()50 instance_type_table_initialize()51 instance_table_initialize()52 instance_group_table_initialize()53 service_host_table_initialize()54 host_aggregate_table_initialize()55def tables_finalize():56 """57 Finalize the tables package58 """59 image_table_finalize()60 volume_table_finalize()61 volume_snapshot_table_finalize()62 tenant_table_finalize()63 subnet_table_finalize()64 network_table_finalize()65 system_table_finalize()66 host_table_finalize()67 host_group_table_finalize()68 hypervisor_table_finalize()...

Full Screen

Full Screen

test_initialized.py

Source:test_initialized.py Github

copy

Full Screen

1from __future__ import unicode_literals2import objc3from PyObjCTools.TestSupport import *4from PyObjCTest.initialize import OC_TestInitialize5class OC_TestInitializePython (OC_TestInitialize):6 def init(self):7 return objc.super(OC_TestInitializePython, self).init()8OBJECT_LIST=[]9class OC_TestInitializePython2 (OC_TestInitialize):10 def init(self):11 self = objc.super(OC_TestInitializePython2, self).init()12 OBJECT_LIST.append(self)13 return self14class TestInitializing (TestCase):15 #16 # These tests make sure that we don't call retain/release on objects17 # that are not yet initialized.18 #19 def testDontRetainUnitialized1(self):20 start = OC_TestInitialize.numUninitialized()21 self.assertEqual(start, 0)22 o = OC_TestInitialize.alloc()23 v = OC_TestInitialize.numUninitialized()24 self.assertEqual(v, start)25 o = o.init()26 v = OC_TestInitialize.numUninitialized()27 self.assertEqual(v, start)28 s = o.dummy()29 self.assertEqual(s, "hello")30 v = OC_TestInitialize.numUninitialized()31 self.assertEqual(v, start)32 def testDontRetainUnitialized2(self):33 start = OC_TestInitialize.numUninitialized()34 self.assertEqual(start, 0)35 o = OC_TestInitialize.makeInstance()36 self.assertIsInstance(o, OC_TestInitialize)37 v = OC_TestInitialize.numUninitialized()38 self.assertEqual(v, start)39 s = o.dummy()40 self.assertEqual(s, "hello")41 v = OC_TestInitialize.numUninitialized()42 self.assertEqual(v, start)43 def testDontRetainUnitialized3(self):44 start = OC_TestInitialize.numUninitialized()45 self.assertEqual(start, 0)46 o = OC_TestInitializePython.makeInstance()47 self.assertIsInstance(o, OC_TestInitializePython)48 v = OC_TestInitialize.numUninitialized()49 self.assertEqual(v, start)50 s = o.dummy()51 self.assertEqual(s, "hello")52 v = OC_TestInitialize.numUninitialized()53 self.assertEqual(v, start)54 def testDontRetainUnitialized4(self):55 start = OC_TestInitialize.numUninitialized()56 self.assertEqual(start, 0)57 o = OC_TestInitializePython2.makeInstance()58 self.assertIsInstance(o, OC_TestInitializePython2)59 self.assertIs(OBJECT_LIST[-1], o)60 del OBJECT_LIST[-1]61 v = OC_TestInitialize.numUninitialized()62 self.assertEqual(v, start)63 s = o.dummy()64 self.assertEqual(s, "hello")65 v = OC_TestInitialize.numUninitialized()66 self.assertEqual(v, start)67if __name__ == "__main__":...

Full Screen

Full Screen

initfini.py

Source:initfini.py Github

copy

Full Screen

1from ctypes import c_uint2from . import ffi3def initialize():4 """5 Initialize the LLVM core.6 """7 ffi.lib.LLVMPY_InitializeCore()8def initialize_all_targets():9 """10 Initialize all targets. Necessary before targets can be looked up11 via the :class:`Target` class.12 """13 ffi.lib.LLVMPY_InitializeAllTargetInfos()14 ffi.lib.LLVMPY_InitializeAllTargets()15 ffi.lib.LLVMPY_InitializeAllTargetMCs()16def initialize_all_asmprinters():17 """...

Full Screen

Full Screen

urls.py

Source:urls.py Github

copy

Full Screen

1from django.urls import path, re_path, include2from django.conf.urls import url3from django.conf.urls import include4from django.contrib import admin5from Initialize.views import (6 permission, url, models7)8# Initialize9urlpatterns = [10 re_path('^set_main$', models.main, name="initialize-main"),11 # re_path('^set_url_name_in_database$', url.SetUrlNameDatabaseList, name="initialize-set-url-name"),12 # re_path('^set_primission_in_system_perimission$', permission.AddPermission, name="initialize-set-system-perimission"),13 # re_path('^set_resume_id$', models.setModels_id, name="initialize-set-resume-id"),14 # re_path('^set_default_user$', models.setDefaultUser, name="initialize-default-user"),15 # re_path('^set_event_type$', models.setEventType, name="initialize-event-type"),16 # re_path('^set_solr_full_import_cronjob$', models.setCrojob_inSolrData, name="initialize-solr-cronjob"),17 # re_path('^set_resume_custom_label$', models.setResumeCustomLabel, name="initialize-resume-label"),18 # re_path('^set_system_setting$', models.setSettings, name="initialize-system-setting"),...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress', () => {2 it('is working', () => {3 expect(true).to.equal(true)4 })5 it('visits the app', () => {6 })7})8{9}10{11 "scripts": {12 },13 "devDependencies": {14 }15}16{17}18{19}20{21}22{23}24{

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6describe('My First Test', function() {7 it('Does not do much!', function() {8 expect(true).to.equal(true)9 })10})11describe('My First Test', function() {12 it('Does not do much!', function() {13 expect(true).to.equal(true)14 })15})16describe('My First Test', function() {17 it('Does not do much!', function() {18 expect(true).to.equal(true)19 })20})21describe('My First Test', function() {22 it('Does not do much!', function() {23 expect(true).to.equal(true)24 })25})26describe('My First Test', function() {27 it('Does not do much!', function() {28 expect(true).to.equal(true)29 })30})31describe('My First Test', function() {32 it('Does not do much!', function() {33 expect(true).to.equal(true)34 })35})36describe('My First Test', function() {37 it('Does not do much!', function() {38 expect(true).to.equal(true)39 })40})41describe('My First Test', function() {42 it('Does not do much!', function() {43 expect(true).to.equal(true)44 })45})46describe('My First Test', function() {47 it('Does not do much!', function() {48 expect(true).to.equal(true)49 })50})51describe('My First Test', function() {52 it('Does not do much!', function() {53 expect(true).to.equal(true)54 })55})56describe('My First Test', function() {57 it('Does not do much!', function() {58 expect(true).to.equal(true)59 })60})61describe('My First Test', function() {62 it('Does

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6describe('My First Test', function() {7 it('Does not do much!', function() {8 expect(true).to.equal(true)9 })10})11describe('My First Test', function() {12 it('Does not do much!', function() {13 expect(true).to.equal(true)14 })15})16describe('My First Test', function() {17 it('Does not do much!', function() {18 expect(true).to.equal(true)19 })20})21describe('My First Test', function() {22 it('Does not do much!', function() {23 expect(true).to.equal(true)24 })25})26describe('My First Test', function() {27 it('Does not do much!', function() {28 expect(true).to.equal(true)29 })30})31describe('My First Test', function() {32 it('Does not do much!', function() {33 expect(true).to.equal(true)34 })35})36describe('My First Test', function() {37 it('Does not do much!', function() {38 expect(true).to.equal(true)39 })40})41describe('My First Test', function() {42 it('Does not do much!', function() {43 expect(true).to.equal(true)44 })45})46describe('My First Test', function() {47 it('Does not do much!', function() {48 expect(true).to.equal(true)49 })50})51describe('My First Test', function() {52 it('Does not do much!', function() {53 expect(true).to.equal(true)54 })55})56describe('My First Test', function() {57 it('Does not do much!', function() {58 expect(true).to.equal(true)59 })60})61describe('My First Test', function() {62 it('Does not do much!', function()

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6{7}8describe('My First Test', function() {9 it('Does not do much!', function() {10 cy.visit('/')11 cy.contains('h1', 'Hello World')12 })13})14describe('My First Test', function() {15 it('Does not do much!', function() {16 cy.visit('/')17 cy.contains('h1', 'Hello World')18 cy.get('input').type('Hello World')19 cy.get('button').click()20 cy.contains('h1', 'Hello World')21 })22})23describe('My First Test', function() {24 it('Does not do much!', function() {25 cy.visit('/')26 cy.contains('h1', 'Hello World')27 cy.get('input').type('Hello World')28 cy.get('button').click()29 cy.contains('h1', 'Hello World')30 cy.get('input').should('have.value', '')31 })32})33describe('My First Test', function() {34 it('Does not do much!', function() {35 cy.visit('/')36 cy.contains('h1', 'Hello World')37 cy.get('input').type('Hello World')38 cy.get('button').click()39 cy.contains('h1', 'Hello World')40 cy.get('input').should('have.value', '')41 cy.get('button').click()42 cy.contains('h1', 'Hello World')43 })44})45describe('My First Test', function() {46 it('Does not do much!', function() {47 cy.visit('/')48 cy.contains('h1', 'Hello World')49 cy.get('input').type('Hello World')50 cy.get('button').click()51 cy.contains('h1', 'Hello World')52 cy.get('input').should('have.value', '')53 cy.get('button').click()

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', () => {2 beforeEach(() => {3 })4 it('test', () => {5 cy.get('#email1')6 .type('

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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