2019-12-21 19:24:54 +01:00
|
|
|
"""
|
|
|
|
WIP
|
2019-12-21 19:25:47 +01:00
|
|
|
|
|
|
|
Yes, we do write tests for our tests.
|
2019-12-21 19:24:54 +01:00
|
|
|
"""
|
2019-12-24 19:34:31 +01:00
|
|
|
from pathlib import Path
|
|
|
|
from typing import List
|
|
|
|
from unittest import TestCase
|
2020-01-09 12:12:06 +01:00
|
|
|
from tests import syntax_lint
|
2019-12-21 19:24:54 +01:00
|
|
|
|
|
|
|
|
2019-12-24 19:34:31 +01:00
|
|
|
def open_test_case_file(n: int) -> List[bytes]:
|
|
|
|
tests_path = Path(__file__).parent.joinpath()
|
2019-12-21 19:24:54 +01:00
|
|
|
|
2019-12-24 19:34:31 +01:00
|
|
|
with open(f'{tests_path}/testcases/testcase{n}.md', 'rb') as f:
|
|
|
|
file_list = [line.rstrip() for line in f.readlines()]
|
|
|
|
return file_list
|
2019-12-21 19:24:54 +01:00
|
|
|
|
|
|
|
|
2019-12-24 19:34:31 +01:00
|
|
|
test_case_1 = open_test_case_file(1)
|
|
|
|
test_case_2 = open_test_case_file(2)
|
|
|
|
test_case_3 = open_test_case_file(3)
|
2019-12-21 19:24:54 +01:00
|
|
|
|
|
|
|
|
2019-12-24 19:34:31 +01:00
|
|
|
class TestSyntax(TestCase):
|
2019-12-21 19:24:54 +01:00
|
|
|
|
2019-12-24 19:34:31 +01:00
|
|
|
def test_details_count_case1(self):
|
2020-01-09 12:12:06 +01:00
|
|
|
self.assertTrue(syntax_lint.count_details(test_case_1))
|
2019-12-21 19:24:54 +01:00
|
|
|
|
2019-12-24 19:34:31 +01:00
|
|
|
def test_details_count_case2(self):
|
2020-01-09 12:12:06 +01:00
|
|
|
self.assertTrue(syntax_lint.count_details(test_case_2))
|
2019-12-21 19:24:54 +01:00
|
|
|
|
2019-12-24 19:34:31 +01:00
|
|
|
def test_details_errors_1(self):
|
2020-01-09 12:12:06 +01:00
|
|
|
syntax_lint.check_details_tag(test_case_1)
|
|
|
|
self.assertFalse(syntax_lint.errors)
|
2019-12-24 19:34:31 +01:00
|
|
|
|
|
|
|
def test_details_errors_2(self):
|
2020-01-09 12:12:06 +01:00
|
|
|
syntax_lint.check_details_tag(test_case_2)
|
|
|
|
self.assertFalse(syntax_lint.errors)
|
2019-12-24 19:34:31 +01:00
|
|
|
#
|
|
|
|
# def test_details_error_exist_1(self):
|
|
|
|
# syntax_checker.check_details_tag(test_case_3)
|
|
|
|
# print(syntax_checker.errors)
|
|
|
|
# self.assertEqual(len(syntax_checker.errors), 3)
|