Improved PythonEvaluator when dealing with concept class
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import ast
|
||||
|
||||
import core.utils
|
||||
import pytest
|
||||
from core.builtin_concepts import ParserResultConcept, NotForMeConcept
|
||||
from core.tokenizer import Tokenizer, LexerError
|
||||
from parsers.PythonParser import PythonNode, PythonParser, PythonErrorNode
|
||||
import core.utils
|
||||
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
@@ -72,12 +73,16 @@ class TestPythonParser(TestUsingMemoryBasedSheerka):
|
||||
assert res.value.get_value("reason")[0].text == error_text
|
||||
|
||||
def test_i_can_parse_a_concept(self):
|
||||
text = "c:name|key: + 1"
|
||||
text = "c:name|id: + 1"
|
||||
|
||||
parser = PythonParser()
|
||||
res = parser.parse(self.get_context(), text)
|
||||
encoded = core.utils.encode_concept(("name", "id"))
|
||||
|
||||
assert res
|
||||
assert res.value.value == PythonNode(
|
||||
"c:name|key: + 1",
|
||||
ast.parse(core.utils.encode_concept(("name", "key"), True) + "+1", mode="eval"))
|
||||
"c:name|id: + 1",
|
||||
ast.parse(encoded + "+1", mode="eval"))
|
||||
assert res.value.value.concepts == {
|
||||
encoded: ("name", "id")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user