repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'B' | assert | string_literal | tests/test_tree_forest_transformer.py | B | CustomTransformer | 56 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | 'ab') | self.assertEqual | string_literal | tests/test_trees.py | test_inline_static | TestTrees | 339 | null |
lark-parser/lark | empty2:
"""
parser = Lark(grammar, parser='earley', lexer=LEXER)
res = parser.parse('ab')
empty_tree = Tree('empty', [Tree('empty2', [])])
self.assertSequenceEqual(res.children, ['a', empty_tree, empty_tree, 'b'])
@unittest.skipIf(LEXER=... | 9 | assert | numeric_literal | tests/test_parser.py | test_parse_textslice | _TestParser | 2,755 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
import logging
import os
import codecs
from lark import logger
from lark.tools.nearley import create_code_for_nearley_grammar, main as nearley_tool_main
logger.setLevel(logging.INFO)
TEST_PATH = os.path.abspath(os.path.dirname(__file__))
NEARLEY_PATH = os.pa... | 153 | assert | numeric_literal | tests/test_nearley/test_nearley.py | test_css | TestNearley | 43 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | TypeError) | self.assertRaises | variable | tests/test_tree_templates.py | test_template_match__only_tree | TestTreeTemplatesConf | 94 | null |
lark-parser/lark | from __future__ import absolute_import, print_function
from unittest import TestCase, main
from lark import Lark
from lark.tree import Tree
from lark.tools import standalone
from io import StringIO
class TestStandalone(TestCase):
def setUp(self):
pass
def _create_standalone(self, grammar, compress=... | UnexpectedToken) | self.assertRaises | variable | tests/test_tools.py | test_interactive | TestStandalone | 68 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'bc' | assert | string_literal | tests/test_tree_forest_transformer.py | ambiguous | CustomTransformer | 180 | null |
lark-parser/lark | from __future__ import absolute_import
import re
import unittest
import os
import sys
from copy import copy, deepcopy
from lark import Token, Transformer_NonRecursive, LexError
from io import (
StringIO as uStringIO,
BytesIO,
open,
)
import lark
from lark import logger
from lark.lark imp... | 3 | assert | numeric_literal | tests/test_parser.py | test_propagate_positions2 | TestParsers | 99 | null |
lark-parser/lark | import json
import sys
import unittest
from itertools import product
from unittest import TestCase
from lark import Lark
from lark.reconstruct import Reconstructor
common = """
%import common (WS_INLINE, NUMBER, WORD)
%ignore WS_INLINE
"""
def _remove_ws(s):
return s.replace(' ', '').replace('\n', '')
class Tes... | tree | assert | variable | tests/test_reconstructor.py | test_switch_grammar_unicode_terminal | TestReconstructor | 191 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | 2.9) | self.assertEqual | numeric_literal | tests/test_trees.py | test_transformer | TestTrees | 148 | null |
lark-parser/lark | import logging
from contextlib import contextmanager
from lark import Lark, logger
from unittest import TestCase, main, skipIf
from io import StringIO
def capture_log():
stream = StringIO()
orig_handler = logger.handlers[0]
del logger.handlers[:]
logger.addHandler(logging.StreamHandler(stream))
yi... | "") | self.assertEqual | string_literal | tests/test_logger.py | test_non_debug | Testlogger | 51 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'start' | assert | string_literal | tests/test_tree_forest_transformer.py | start | CustomTransformer | 134 | null |
lark-parser/lark | from __future__ import absolute_import, print_function
from unittest import TestCase, main
from lark import Lark
from lark.tree import Tree
from lark.tools import standalone
from io import StringIO
class TestStandalone(TestCase):
def setUp(self):
pass
def _create_standalone(self, grammar, compress=... | ['a', 'b']) | self.assertEqual | collection | tests/test_tools.py | test_contextual | TestStandalone | 118 | null |
lark-parser/lark | import json
import sys
import unittest
from itertools import product
from unittest import TestCase
from lark import Lark
from lark.reconstruct import Reconstructor
common = """
%import common (WS_INLINE, NUMBER, WORD)
%ignore WS_INLINE
"""
def _remove_ws(s):
return s.replace(' ', '').replace('\n', '')
class Tes... | _remove_ws(new)) | self.assertEqual | func_call | tests/test_reconstructor.py | assert_reconstruct | TestReconstructor | 28 | null |
lark-parser/lark | import logging
from contextlib import contextmanager
from lark import Lark, logger
from unittest import TestCase, main, skipIf
from io import StringIO
def capture_log():
stream = StringIO()
orig_handler = logger.handlers[0]
del logger.handlers[:]
logger.addHandler(logging.StreamHandler(stream))
yi... | log) | self.assertIn | variable | tests/test_logger.py | test_debug | Testlogger | 38 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | (t, 1, 2)) | self.assertEqual | collection | tests/test_trees.py | test_vargs_set_name | TestTrees | 330 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | GrammarError) | self.assertRaises | variable | tests/test_grammar.py | test_override_rule | TestGrammar | 54 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | TestCls | assert | variable | tests/test_trees.py | ab_classmethod | TestCls | 243 | null |
lark-parser/lark | from __future__ import absolute_import, print_function
from unittest import TestCase, main
from lark import Lark
from lark.tree import Tree
from lark.tools import standalone
from io import StringIO
class TestStandalone(TestCase):
def setUp(self):
pass
def _create_standalone(self, grammar, compress=... | TypeError) | self.assertRaises | variable | tests/test_tools.py | test_interactive | TestStandalone | 69 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | 'hello') | self.assertEqual | string_literal | tests/test_trees.py | test_vargs | TestTrees | 191 | null |
lark-parser/lark | from __future__ import absolute_import, print_function
from unittest import TestCase, main
from lark import Lark
from lark.tree import Tree
from lark.tools import standalone
from io import StringIO
class TestStandalone(TestCase):
def setUp(self):
pass
def _create_standalone(self, grammar, compress=... | ['12', 'elephants']) | self.assertEqual | collection | tests/test_tools.py | test_simple | TestStandalone | 41 | null |
lark-parser/lark | from __future__ import absolute_import, print_function
from unittest import TestCase, main
from lark import Lark
from lark.tree import Tree
from lark.tools import standalone
from io import StringIO
class TestStandalone(TestCase):
def setUp(self):
pass
def _create_standalone(self, grammar, compress=... | _Tree("start", [ _Tree("rule_is_transformed", []), _Token("SOME_TERMINAL", "token is transformed") ])) | self.assertEqual | func_call | tests/test_tools.py | test_transformer | TestStandalone | 169 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | [3, 5] | assert | collection | tests/test_grammar.py | test_find_grammar_errors | TestGrammar | 187 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 4 | assert | numeric_literal | tests/test_tree_forest_transformer.py | start | CustomTransformer | 132 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class TestTreeForestTransformer(unittest.TestCas... | 4) | self.assertEqual | numeric_literal | tests/test_tree_forest_transformer.py | test_default_token | TestTreeForestTransformer | 78 | null |
lark-parser/lark | from __future__ import absolute_import
import logging
from unittest import TestCase, main, skipIf
from lark import Lark, Tree, Transformer, UnexpectedInput
from lark.exceptions import ConfigurationError
from lark.lexer import Lexer, Token
import lark.lark as lark_module
from lark.reconstruct import Reconstructor
from... | res1 | assert | variable | tests/test_cache.py | test_inline | TestCache | 138 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | 123 | assert | numeric_literal | tests/test_trees.py | test_transform_token | TestTrees | 466 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | t2) | self.assertEqual | variable | tests/test_trees.py | test_discard | TestTrees | 392 | null |
lark-parser/lark | import inspect
import textwrap
from unittest import TestCase, main
from lark import Lark
from lark.indenter import PythonIndenter
from lark.exceptions import UnexpectedCharacters, UnexpectedToken, ParseError
valid_DEC_NUMBER = [
"0",
"000",
"0_0_0",
"4_2",
"1_0000_0000",
"123456789012345678901... | 1) | self.assertEqual | numeric_literal | tests/test_python_grammar.py | _test_parsed_is_this_terminal | TestPythonParser | 240 | null |
lark-parser/lark | from __future__ import absolute_import
import logging
from unittest import TestCase, main, skipIf
from lark import Lark, Tree, Transformer, UnexpectedInput
from lark.exceptions import ConfigurationError
from lark.lexer import Lexer, Token
import lark.lark as lark_module
from lark.reconstruct import Reconstructor
from... | parser2.grammar | assert | complex_expr | tests/test_cache.py | test_cache_grammar | TestCache | 206 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | None | assert | none_literal | tests/test_trees.py | test_transform_token | TestTrees | 472 | null |
lark-parser/lark | from __future__ import absolute_import
import re
import unittest
import os
import sys
from copy import copy, deepcopy
from lark import Token, Transformer_NonRecursive, LexError
from io import (
StringIO as uStringIO,
BytesIO,
open,
)
import lark
from lark import logger
from lark.lark imp... | 1) | self.assertEqual | numeric_literal | tests/test_parser.py | test_propagate_positions | TestParsers | 76 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'ab' | assert | string_literal | tests/test_tree_forest_transformer.py | ab | CustomTransformer | 141 | null |
lark-parser/lark | from __future__ import absolute_import, print_function
from unittest import TestCase, main
from lark import Lark
from lark.tree import Tree
from lark.tools import standalone
from io import StringIO
class TestStandalone(TestCase):
def setUp(self):
pass
def _create_standalone(self, grammar, compress=... | context['UnexpectedToken']) | self.assertRaises | complex_expr | tests/test_tools.py | test_simple | TestStandalone | 45 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | self.tree1 | assert | complex_expr | tests/test_trees.py | test_eq | TestTrees | 27 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | b) | self.assertNotEqual | variable | tests/test_grammar.py | test_symbol_eq | TestGrammar | 303 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | b | assert | variable | tests/test_grammar.py | test_override_rule | TestGrammar | 52 | null |
lark-parser/lark | from unittest import TestCase, main
from lark import Lark, Tree, TextSlice
class TestLexer(TestCase):
def setUp(self):
pass
def test_basic(self):
p = Lark("""
start: "a" "b" "c" "d"
%ignore " "
""")
res = list(p.lex("abc cba dd"))
assert res =... | list('abccbadd') | assert | func_call | tests/test_lexer.py | test_basic | TestLexer | 17 | null |
lark-parser/lark | from __future__ import absolute_import
import logging
from unittest import TestCase, main, skipIf
from lark import Lark, Tree, Transformer, UnexpectedInput
from lark.exceptions import ConfigurationError
from lark.lexer import Lexer, Token
import lark.lark as lark_module
from lark.reconstruct import Reconstructor
from... | 1 | assert | numeric_literal | tests/test_cache.py | test_automatic_naming | TestCache | 95 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | conf.test_var(test_case)) | self.assertIsNone | func_call | tests/test_tree_templates.py | test_conf_test_var__not_var | TestTreeTemplatesConf | 57 | null |
lark-parser/lark | from __future__ import absolute_import, print_function
from unittest import TestCase, main
from lark import Lark
from lark.tree import Tree
from lark.tools import standalone
from io import StringIO
class TestStandalone(TestCase):
def setUp(self):
pass
def _create_standalone(self, grammar, compress=... | context['UnexpectedCharacters']) | self.assertRaises | complex_expr | tests/test_tools.py | test_simple | TestStandalone | 47 | null |
lark-parser/lark | import sys
import os, os.path
from io import open
import glob, time
from lark import Lark
from lark.indenter import PythonIndenter
kwargs = dict(postlex=PythonIndenter(), start='file_input')
python_parser3 = Lark.open_from_package('lark', 'python.lark', ['grammars'], parser='lalr', **kwargs)
python_parser2 = Lark.o... | tree2 | assert | variable | examples/advanced/python_parser.py | test_earley_equals_lalr | 73 | null | |
lark-parser/lark | from __future__ import absolute_import
import unittest
import logging
import os
import codecs
from lark import logger
from lark.tools.nearley import create_code_for_nearley_grammar, main as nearley_tool_main
logger.setLevel(logging.INFO)
TEST_PATH = os.path.abspath(os.path.dirname(__file__))
NEARLEY_PATH = os.pa... | 255 | assert | numeric_literal | tests/test_nearley/test_nearley.py | test_css | TestNearley | 44 | null |
lark-parser/lark | self.assertEqual(set(res.children), {'aa', 'a'})
# XXX TODO fix Earley to maintain correct order
# i.e. terminals it imitate greedy search for terminals, but lazy search for rules
# self.assertEqual(res.children, ['aa', 'a'])
def test_earley4(self):
g... | 0 | assert | numeric_literal | tests/test_parser.py | test_match_examples | _TestParser | 2,517 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | list(template.search(test_case))) | self.assertEqual | func_call | tests/test_tree_templates.py | test_template_search__with_template__matched_result_with_parent_tree | TestTreeTemplatesTemplate | 167 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | template.match(Tree("foo", children=["bye"]))) | self.assertIsNone | func_call | tests/test_tree_templates.py | test_template_match__different_tree_no_template__none | TestTreeTemplatesTemplate | 109 | null |
lark-parser/lark | import logging
from contextlib import contextmanager
from lark import Lark, logger
from unittest import TestCase, main, skipIf
from io import StringIO
def capture_log():
stream = StringIO()
orig_handler = logger.handlers[0]
del logger.handlers[:]
logger.addHandler(logging.StreamHandler(stream))
yi... | 0) | self.assertEqual | numeric_literal | tests/test_logger.py | test_loglevel_higher | Testlogger | 64 | null |
lark-parser/lark | import json
import sys
import unittest
from itertools import product
from unittest import TestCase
from lark import Lark
from lark.reconstruct import Reconstructor
common = """
%import common (WS_INLINE, NUMBER, WORD)
%ignore WS_INLINE
"""
def _remove_ws(s):
return s.replace(' ', '').replace('\n', '')
class Tes... | json.loads(test_json)) | self.assertEqual | func_call | tests/test_reconstructor.py | test_json_example | TestReconstructor | 144 | null |
lark-parser/lark | import inspect
import textwrap
from unittest import TestCase, main
from lark import Lark
from lark.indenter import PythonIndenter
from lark.exceptions import UnexpectedCharacters, UnexpectedToken, ParseError
valid_DEC_NUMBER = [
"0",
"000",
"0_0_0",
"4_2",
"1_0000_0000",
"123456789012345678901... | ParseError) | self.assertRaises | variable | tests/test_python_grammar.py | test_invalid_match_statement | TestPythonParser | 293 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
import logging
import os
import codecs
from lark import logger
from lark.tools.nearley import create_code_for_nearley_grammar, main as nearley_tool_main
logger.setLevel(logging.INFO)
TEST_PATH = os.path.abspath(os.path.dirname(__file__))
NEARLEY_PATH = os.pa... | 161 | assert | numeric_literal | tests/test_nearley/test_nearley.py | test_css | TestNearley | 42 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class TestTreeForestTransformer(unittest.TestCas... | tree2) | self.assertEqual | variable | tests/test_tree_forest_transformer.py | test_identity_resolve_ambiguity | TestTreeForestTransformer | 27 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | template.apply_vars({SOME_TEMPLATE_NAME: SOME_NON_TEMPLATE_TREE})) | self.assertEqual | func_call | tests/test_tree_templates.py | test_template_apply_vars__matching_vars__template_replaced | TestTreeTemplatesTemplate | 189 | null |
lark-parser/lark | from __future__ import absolute_import
import logging
from unittest import TestCase, main, skipIf
from lark import Lark, Tree, Transformer, UnexpectedInput
from lark.exceptions import ConfigurationError
from lark.lexer import Lexer, Token
import lark.lark as lark_module
from lark.reconstruct import Reconstructor
from... | 0 | assert | numeric_literal | tests/test_cache.py | test_automatic_naming | TestCache | 93 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 1 | assert | numeric_literal | tests/test_tree_forest_transformer.py | ab | CustomTransformer | 140 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'A' | assert | string_literal | tests/test_tree_forest_transformer.py | A | CustomTransformer | 53 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | OtherClass | assert | variable | tests/test_trees.py | ab_classmethod | OtherClass | 201 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | ParseError) | self.assertRaises | variable | tests/test_grammar.py | test_ranged_repeat_large | TestGrammar | 240 | null |
lark-parser/lark | import inspect
import textwrap
from unittest import TestCase, main
from lark import Lark
from lark.indenter import PythonIndenter
from lark.exceptions import UnexpectedCharacters, UnexpectedToken, ParseError
valid_DEC_NUMBER = [
"0",
"000",
"0_0_0",
"4_2",
"1_0000_0000",
"123456789012345678901... | text) | self.assertEqual | variable | tests/test_python_grammar.py | _test_parsed_is_this_terminal | TestPythonParser | 243 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class TestTreeForestTransformer(unittest.TestCas... | 1) | self.assertEqual | numeric_literal | tests/test_tree_forest_transformer.py | test_default_ambig | TestTreeForestTransformer | 124 | null |
lark-parser/lark | from __future__ import absolute_import
import re
import unittest
import os
import sys
from copy import copy, deepcopy
from lark import Token, Transformer_NonRecursive, LexError
from io import (
StringIO as uStringIO,
BytesIO,
open,
)
import lark
from lark import logger
from lark.lark imp... | l2 | assert | variable | tests/test_parser.py | test_same_ast | TestParsers | 57 | null |
lark-parser/lark | from unittest import TestCase, main
from lark import Lark, Tree, TextSlice
class TestLexer(TestCase):
def setUp(self):
pass
def test_basic(self):
p = Lark("""
start: "a" "b" "c" "d"
%ignore " "
""")
res = list(p.lex("abc cba dd"))
assert res ==... | list('abc cba dd') | assert | func_call | tests/test_lexer.py | test_basic | TestLexer | 20 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | MissingVariableError) | self.assertRaises | variable | tests/test_tree_templates.py | test_template_apply_vars__empty__exception | TestTreeTemplatesTemplate | 173 | null |
lark-parser/lark | from __future__ import absolute_import
import logging
from unittest import TestCase, main, skipIf
from lark import Lark, Tree, Transformer, UnexpectedInput
from lark.exceptions import ConfigurationError
from lark.lexer import Lexer, Token
import lark.lark as lark_module
from lark.reconstruct import Reconstructor
from... | parser.grammar | assert | complex_expr | tests/test_cache.py | test_reconstruct | TestCache | 226 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class CustomTransformer(TreeForestTransf... | 'abcd' | assert | string_literal | tests/test_tree_forest_transformer.py | full | CustomTransformer | 187 | null |
lark-parser/lark | from __future__ import absolute_import
import re
import unittest
import os
import sys
from copy import copy, deepcopy
from lark import Token, Transformer_NonRecursive, LexError
from io import (
StringIO as uStringIO,
BytesIO,
open,
)
import lark
from lark import logger
from lark.lark imp... | 3) | self.assertEqual | numeric_literal | tests/test_parser.py | test_symbol_node_start_end_dynamic_lexer | _TestFullEarley | 978 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from copy import deepcopy
from lark import Lark, Tree, Token
from lark.exceptions import MissingVariableError
from lark.tree_templates import TemplateConf, Template, TemplateTranslator
SOME_NON_TEMPLATED_STRING = "foo bar"
SOME_TEMPLATE_NAME = "thing"
SOME_TEMPL... | template.match(SOME_NON_TEMPLATE_TREE)) | self.assertEqual | func_call | tests/test_tree_templates.py | test_template_match__default_conf_match_same_tree__empty_dictionary | TestTreeTemplatesConf | 88 | null |
lark-parser/lark | from __future__ import absolute_import
import logging
from unittest import TestCase, main, skipIf
from lark import Lark, Tree, Transformer, UnexpectedInput
from lark.exceptions import ConfigurationError
from lark.lexer import Lexer, Token
import lark.lark as lark_module
from lark.reconstruct import Reconstructor
from... | 2 | assert | numeric_literal | tests/test_cache.py | test_automatic_naming | TestCache | 100 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
import logging
import os
import codecs
from lark import logger
from lark.tools.nearley import create_code_for_nearley_grammar, main as nearley_tool_main
logger.setLevel(logging.INFO)
TEST_PATH = os.path.abspath(os.path.dirname(__file__))
NEARLEY_PATH = os.pa... | 3 | assert | numeric_literal | tests/test_nearley/test_nearley.py | test_css | TestNearley | 49 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | s | assert | variable | tests/test_trees.py | test_pickle | TestTrees | 39 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from functools import partial, reduce, partialmethod
from operator import add, mul
from unittest import TestCase
import copy
import pickle
import functools
from lark.tree import Tree
from lark.lexer import Token
from lark.visitors import Visitor, Visitor_Recursiv... | expected) | self.assertEqual | variable | tests/test_trees.py | test_iter_subtrees | TestTrees | 48 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | str(e) | assert | func_call | tests/test_grammar.py | test_errors | TestGrammar | 21 | null |
lark-parser/lark | from __future__ import absolute_import
import os
from unittest import TestCase, main
from lark import Lark, Token, Tree, ParseError, UnexpectedInput
from lark.load_grammar import GrammarError, GRAMMAR_ERRORS, find_grammar_errors, list_grammar_imports
from lark.load_grammar import FromPackageLoader
from lark.grammar i... | ['N']) | self.assertEqual | collection | tests/test_grammar.py | test_import_custom_sources2 | TestGrammar | 166 | null |
lark-parser/lark | from __future__ import absolute_import
import unittest
from lark import Lark
from lark.lexer import Token
from lark.tree import Tree
from lark.visitors import Visitor, Transformer, Discard
from lark.parsers.earley_forest import TreeForestTransformer, handles_ambiguity
class TestTreeForestTransformer(unittest.TestCas... | expected) | self.assertEqual | variable | tests/test_tree_forest_transformer.py | test_transformation | TestTreeForestTransformer | 225 | null |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | ASGIWebsocketState.HANDSHAKE | assert | complex_expr | tests/protocol/test_ws_stream.py | test_send_reject | 326 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | UnexpectedMessageError) | pytest.raises | variable | tests/protocol/test_ws_stream.py | test_send_invalid_message_given_state | 490 | null | |
pgjones/hypercorn | from __future__ import annotations
import os
import socket
import ssl
import sys
from unittest.mock import Mock, NonCallableMock
import pytest
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.config
from hypercorn.config import Config
access_log_format = "bob"
h11_max_incomplete_size = 4
def _check_sta... | [(b"date", b"Sat, 02 Dec 2017 15:43:15 GMT")] | assert | collection | tests/test_config.py | test_response_headers | 154 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
import h2
import h11
import pytest
import wsproto
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.tcp_server import TCPServer
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from .helpers import Mem... | [wsproto.events.TextMessage(data="Hello & Goodbye")] | assert | collection | tests/asyncio/test_sanity.py | test_http1_websocket | 109 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | {"type": "websocket.receive", "bytes": b"abc", "text": None} | assert | collection | tests/protocol/test_ws_stream.py | test_buffer | 40 | null | |
pgjones/hypercorn | from __future__ import annotations
import os
import socket
import ssl
import sys
from unittest.mock import Mock, NonCallableMock
import pytest
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.config
from hypercorn.config import Config
access_log_format = "bob"
h11_max_incomplete_size = 4
def _check_sta... | expected_binding) | assert_* | variable | tests/test_config.py | test_create_sockets_ip | 98 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | TypeError) | pytest.raises | variable | tests/protocol/test_ws_stream.py | test_buffer_mixed_types | 65 | null | |
pgjones/hypercorn | from __future__ import annotations
from typing import Any, cast
from unittest.mock import AsyncMock, call
import pytest
import pytest_asyncio
from hypercorn.asyncio.statsd import StatsdLogger
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from hypercorn.logging import ... | ASGIHTTPState.CLOSED | assert | complex_expr | tests/protocol/test_http_stream.py | test_send_response | 166 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | ASGIWebsocketState.HTTPCLOSED | assert | complex_expr | tests/protocol/test_ws_stream.py | test_send_reject | 332 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from collections.abc import Callable
from functools import partial
from typing import Any
import pytest
import trio
from hypercorn.app_wrappers import _build_environ, InvalidPathError, WSGIWrapper
from hypercorn.typing import ASGIReceiveEvent, ASGISendEvent, Connecti... | "/文".encode().decode("latin-1") | assert | string_literal | tests/test_app_wrappers.py | test_build_environ_encoding | 187 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | 200 | assert | numeric_literal | tests/protocol/test_ws_stream.py | test_handshake_accept_http2 | 136 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any
from unittest.mock import AsyncMock, call, Mock
import h11
import pytest
import pytest_asyncio
from _pytest.monkeypatch import MonkeyPatch
import hypercorn.protocol.h11
from hypercorn.asyncio.worker_context import EventWrapper
from hypercorn.co... | [ # type: ignore call( RawData( data=b"HTTP/1.1 431 \r\ncontent-length: 0\r\nconnection: close\r\n" b"date: Thu, 01 Jan 1970 01:23:20 GMT\r\nserver: hypercorn-h11\r\n\r\n" ) ), call(RawData(data=b"")), call(Closed()), ] | assert | collection | tests/protocol/test_h11.py | test_protocol_handle_max_incomplete | 330 | null | |
pgjones/hypercorn | from __future__ import annotations
from typing import cast
from unittest.mock import AsyncMock, Mock, PropertyMock
import h2
import h11
import pytest
import trio
import wsproto
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.config import Config
from hypercorn.trio.tcp_server import TCPServer
from hype... | [ (b":status", b"200"), (b"content-length", b"15"), (b"date", b"Thu, 01 Jan 1970 01:23:20 GMT"), (b"server", b"hypercorn-h2"), ] | assert | collection | tests/trio/test_sanity.py | test_http2_request | 151 | null | |
pgjones/hypercorn | from __future__ import annotations
import httpx # type: ignore
import pytest
import trio
import hypercorn.trio
from hypercorn.config import Config
from hypercorn.typing import ASGIReceiveCallable, ASGISendCallable, Scope
async def app(scope, receive, send) -> None: # type: ignore
assert scope["type"] == "http"... | b"" | assert | string_literal | tests/e2e/test_httpx.py | test_handle_isolate_state | 100 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from collections.abc import Callable
import pytest
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.config import Config
from hypercorn.typing import HTTPScope, Scope
@pytest.mark.asyncio
async def test... | {"type": "http.disconnect"} | assert | collection | tests/asyncio/test_task_group.py | test_spawn_app | 31 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from unittest.mock import AsyncMock, call, Mock
import pytest
from h2.connection import H2Connection
from h2.events import ConnectionTerminated
from hypercorn.asyncio.worker_context import EventWrapper, WorkerContext
from hypercorn.config import Config
from hypercorn... | [call(Closed())] | assert | collection | tests/protocol/test_h2.py | test_protocol_handle_protocol_error | 89 | null | |
pgjones/hypercorn | from __future__ import annotations
import pytest
from hypercorn.middleware import HTTPToHTTPSRedirectMiddleware
from hypercorn.typing import ConnectionState, HTTPScope, WebsocketScope
from ..helpers import empty_framework
@pytest.mark.asyncio
@pytest.mark.parametrize("raw_path", [b"/abc", b"/abc%3C"])
async def test... | [ { "type": "websocket.http.response.start", "status": 307, "headers": [(b"location", b"wss://localhost%s?a=b" % raw_path)], }, {"type": "websocket.http.response.body"}, ] | assert | collection | tests/middleware/test_http_to_https.py | test_http_to_https_redirect_middleware_websocket | 75 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | idle | assert | variable | tests/protocol/test_ws_stream.py | test_stream_idle | 532 | null | |
pgjones/hypercorn | from __future__ import annotations
from typing import Any, cast
from unittest.mock import AsyncMock, call
import pytest
import pytest_asyncio
from hypercorn.asyncio.statsd import StatsdLogger
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from hypercorn.logging import ... | [ call(Response(stream_id=1, headers=[], status_code=200)), call(Body(stream_id=1, data=b"Body")), call(EndBody(stream_id=1)), call(StreamClosed(stream_id=1)), ] | assert | collection | tests/protocol/test_http_stream.py | test_send_response | 168 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | [call({"type": "websocket.disconnect", "code": 1006})] | assert | collection | tests/protocol/test_ws_stream.py | test_closure | 544 | null | |
pgjones/hypercorn | from __future__ import annotations
import pytest
from hypercorn.middleware import HTTPToHTTPSRedirectMiddleware
from hypercorn.typing import ConnectionState, HTTPScope, WebsocketScope
from ..helpers import empty_framework
@pytest.mark.asyncio
async def test_http_to_https_redirect_middleware_websocket_no_rejection() ... | [{"type": "websocket.close"}] | assert | collection | tests/middleware/test_http_to_https.py | test_http_to_https_redirect_middleware_websocket_no_rejection | 147 | null | |
pgjones/hypercorn | from __future__ import annotations
import logging
import os
import time
import pytest
from hypercorn.config import Config
from hypercorn.logging import AccessLogAtoms, Logger
from hypercorn.typing import HTTPScope, ResponseSummary
@pytest.mark.parametrize(
"target, expected_name, expected_handler_type",
[
... | "%h" | assert | string_literal | tests/test_logging.py | test_access_logger_init | 32 | null | |
pgjones/hypercorn | from __future__ import annotations
from typing import cast
from unittest.mock import AsyncMock, Mock, PropertyMock
import h2
import h11
import pytest
import trio
import wsproto
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.config import Config
from hypercorn.trio.tcp_server import TCPServer
from hype... | [wsproto.events.TextMessage(data="Hello & Goodbye")] | assert | collection | tests/trio/test_sanity.py | test_http1_websocket | 95 | null | |
pgjones/hypercorn | from __future__ import annotations
from typing import Any, cast
from unittest.mock import AsyncMock, call
import pytest
import pytest_asyncio
from hypercorn.asyncio.statsd import StatsdLogger
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from hypercorn.logging import ... | [ # type: ignore call(Response(stream_id=1, headers=[], status_code=200)), call(Body(stream_id=1, data=b"Body")), call(EndBody(stream_id=1)), call(StreamClosed(stream_id=1)), ] | assert | collection | tests/protocol/test_http_stream.py | test_send_trailers_ignored | 294 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
from typing import Any, cast
from unittest.mock import AsyncMock, call, Mock
import pytest
import pytest_asyncio
from wsproto.events import BytesMessage, TextMessage
from hypercorn.asyncio.task_group import TaskGroup
from hypercorn.asyncio.worker_context import Worke... | [ call({"type": "websocket.receive", "bytes": None, "text": "hello"}) ] | assert | collection | tests/protocol/test_ws_stream.py | test_handle_connection | 249 | null | |
pgjones/hypercorn | from __future__ import annotations
from typing import Any, cast
from unittest.mock import AsyncMock, call
import pytest
import pytest_asyncio
from hypercorn.asyncio.statsd import StatsdLogger
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from hypercorn.logging import ... | [call({"type": "http.disconnect"})] | assert | collection | tests/protocol/test_http_stream.py | test_handle_closed | 144 | null | |
pgjones/hypercorn | from __future__ import annotations
import asyncio
import h2
import h11
import pytest
import wsproto
from hypercorn.app_wrappers import ASGIWrapper
from hypercorn.asyncio.tcp_server import TCPServer
from hypercorn.asyncio.worker_context import WorkerContext
from hypercorn.config import Config
from .helpers import Mem... | [ h11.Response( status_code=200, headers=[ (b"content-length", b"15"), (b"date", b"Thu, 01 Jan 1970 01:23:20 GMT"), (b"server", b"hypercorn-h11"), (b"connection", b"close"), ], http_version=b"1.1", reason=b"", ), h11.Data(data=b"Hello & Goodbye"), h11.EndOfMessage(headers=[]), ] | assert | collection | tests/asyncio/test_sanity.py | test_http1_request | 59 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.