-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from jakkdl/meta-tests
Meta-tests
- Loading branch information
Showing
10 changed files
with
120 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import inspect | ||
import os | ||
import os.path | ||
import re | ||
import unittest | ||
from types import FunctionType | ||
from typing import Dict, Optional, Set, Tuple | ||
|
||
from test_flake8_trio import Flake8TrioTestCase | ||
|
||
|
||
class TestTrioTests(unittest.TestCase): | ||
def runTest(self): | ||
# get files | ||
trio_tests: Dict[str, Tuple[str, Optional[FunctionType]]] = { | ||
os.path.splitext(f)[0]: (f, None) | ||
for f in os.listdir("tests") | ||
if re.match(r"^trio.*.py", f) | ||
} | ||
|
||
# get functions | ||
for o in inspect.getmembers(Flake8TrioTestCase): | ||
if inspect.isfunction(o[1]) and re.match(r"^test_trio\d\d\d", o[0]): | ||
key = o[0][5:] | ||
|
||
self.assertIn(key, trio_tests) | ||
self.assertIsNone(trio_tests[key][1], msg=key) | ||
|
||
trio_tests[key] = (trio_tests[key][0], o[1]) | ||
|
||
for test, (filename, func) in sorted(trio_tests.items()): | ||
self.assertIsNotNone(func, msg=test) | ||
assert func is not None # for type checkers | ||
|
||
with open(os.path.join("tests", filename), encoding="utf-8") as file: | ||
file_error_lines = { | ||
lineno + 1 | ||
for lineno, line in enumerate(file) | ||
if re.search(r"# *error", line, flags=re.I) | ||
} | ||
|
||
func_error_lines: Set[int] = set() | ||
for line in inspect.getsourcelines(func)[0]: | ||
m = re.search(r"(?<=make_error\(TRIO\d\d\d, )\d*", line) | ||
if not m: | ||
continue | ||
lineno = int(m.group()) | ||
self.assertNotIn(lineno, func_error_lines, msg=test) | ||
func_error_lines.add(lineno) | ||
|
||
self.assertSetEqual(file_error_lines, func_error_lines, msg=test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters