Added coverage for lookahead (simple). Reached 100%.

This commit is contained in:
Maximilien Rigaut 2022-05-30 03:34:15 +02:00
parent c18b145d2d
commit 0dbe632f45
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
3 changed files with 65 additions and 15 deletions

View File

@ -1,7 +1,7 @@
import pytest
from bootstraparse.modules import context_mngr
from bootstraparse.modules.syntax import SemanticType, TextToken, Linebreak, StructuralElementStartToken, StructuralElementEndToken
from bootstraparse.modules.syntax import SemanticType, TextToken, Linebreak, StructuralElementStartToken, StructuralElementEndToken, EtUlistToken, EtOlistToken
from bootstraparse.modules.tools import __GLk
__XF = pytest.mark.xfail
@ -57,6 +57,59 @@ _token_list_with_expected_result = [
],
__GLk(1),
],
[
[
EtUlistToken(["a"]),
Linebreak([]),
EtUlistToken(["b"]),
Linebreak([]),
EtUlistToken(["c"]),
EtUlistToken(["d"]),
EtOlistToken(["aa"]),
EtOlistToken(["bb"]),
EtOlistToken(["cc"]),
Linebreak([]),
EtOlistToken(["dd"]),
Linebreak([]),
Linebreak([]),
TextToken([1]),
Linebreak([]),
TextToken([2]),
],
[
context_mngr.EtUlistContainer([
EtUlistToken(["a"]),
Linebreak([]),
EtUlistToken(["b"]),
Linebreak([]),
EtUlistToken(["c"]),
EtUlistToken(["d"]),
]),
None,
None,
None,
None,
None,
context_mngr.EtUlistContainer([
EtOlistToken(["aa"]),
EtOlistToken(["bb"]),
EtOlistToken(["cc"]),
Linebreak([]),
EtOlistToken(["dd"]),
Linebreak([]),
]),
None,
None,
None,
None,
None,
context_mngr.LinebreakContainer([Linebreak([])]),
context_mngr.TextContainer([TextToken([1])]),
context_mngr.LinebreakContainer([Linebreak([])]),
context_mngr.TextContainer([TextToken([2])]),
],
__GLk(1),
],
] # TODO: Test a lot more thouroughly
_zipped_token_list_with_expected_result = [
@ -105,6 +158,14 @@ def test_encapsulate_bad_index(base_cm):
with pytest.raises(SystemExit):
base_cm.encapsulate(2, 1)
base_cm.encapsulate(1, 2)
with pytest.raises(SystemExit):
base_cm.encapsulate(2, 2)
base_cm.pile[0] = {}
with pytest.raises(AttributeError):
base_cm.encapsulate(0, 0)
def test_encapsulate_bad_cm(base_cm):
base_cm.pile[1] = SemanticType([1])

View File

@ -112,8 +112,10 @@ def test_with_optionnals():
@pytest.mark.xfail(reason="Not implemented")
def test_format_optionnals():
import rich
from bootstraparse.modules import syntax # noqa E402
export.format_optionals("")
rich.inspect(export.format_optionals(""))
assert False

View File

@ -266,12 +266,11 @@ def test_subfolder_parsing():
assert pp.export_with_imports().read() == final_content_superimports
@pytest.mark.xfail(reason="Not implemented")
def test_do_imports():
"""
Test the full export function
"""
testfile = temp_name("index.bpr")
testfile = temp_name(os.path.join(_BASE_PATH_GIVEN, "index.bpr"))
assert os.path.exists(testfile)
pp = preparser.PreParser(testfile, env)
pp.do_imports()
@ -279,18 +278,6 @@ def test_do_imports():
assert f.read() == final_content_index
@pytest.mark.xfail(reason="Not implemented")
def test_do_replacements():
"""
Test the full replacement function
"""
testfile = temp_name("index.bpr")
assert os.path.exists(testfile)
pp = preparser.PreParser(testfile, env)
f = pp.do_replacements()
assert f.read() == final_content_index
def test_get_all_lines():
"""
Test the line reader