Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit ff14fddc authored by eckhart's avatar eckhart

- small refactorings

parent e459a8d5
...@@ -586,7 +586,7 @@ def run_test_function(func_name, namespace): ...@@ -586,7 +586,7 @@ def run_test_function(func_name, namespace):
exec(func_name + '()', namespace) exec(func_name + '()', namespace)
def runner(test_classes, namespace): def runner(tests, namespace):
""" """
Runs all or some selected Python unit tests found in the Runs all or some selected Python unit tests found in the
namespace. To run all tests in a module, call namespace. To run all tests in a module, call
...@@ -597,10 +597,12 @@ def runner(test_classes, namespace): ...@@ -597,10 +597,12 @@ def runner(test_classes, namespace):
in such classes or functions, the name of which starts with "test". in such classes or functions, the name of which starts with "test".
Args: Args:
test_classes: Either a string or a list of strings that contains tests: String or list of strings with the names of tests to
the names of test or test classes. Each test and, in the case run. If empty, runner searches by itself all objects the
of a test class, all tests within the test class will be of which starts with 'test' and runs it (if its a function)
run. or all of its methods that start with "test" if its a class
plus the "setup" and "teardown" methods if they exist.
namespace: The namespace for running the test, usually namespace: The namespace for running the test, usually
``globals()`` should be used. ``globals()`` should be used.
...@@ -617,21 +619,22 @@ def runner(test_classes, namespace): ...@@ -617,21 +619,22 @@ def runner(test_classes, namespace):
from DHParser.testing import runner from DHParser.testing import runner
runner("", globals()) runner("", globals())
""" """
test_classes = []
test_functions = []
if tests:
if test_classes: if isinstance(tests, str):
if isinstance(test_classes, str): tests = tests.split(' ')
test_classes = test_classes.split(" ") assert all(test.lower().startswith('test') for test in tests)
else: else:
# collect all test classes, in case no methods or classes have been passed explicitly tests = namespace.keys()
test_classes = []
test_functions = [] for name in tests:
for name in namespace.keys(): if name.lower().startswith('test'):
if name.lower().startswith('test'): if inspect.isclass(namespace[name]):
if inspect.isclass(namespace[name]): test_classes.append(name)
test_classes.append(name) elif inspect.isfunction(namespace[name]):
elif inspect.isfunction(namespace[name]): test_functions.append(name)
test_functions.append(name)
for test in test_classes: for test in test_classes:
run_tests_in_class(test, namespace) run_tests_in_class(test, namespace)
......
#cython: infer_types=True
#cython: language_level=3
#cython: c_string_type=unicode
#cython: c_string_encoding=utf-8
...@@ -46,8 +46,9 @@ from typing import Any, Iterable, Sequence, Set, Union, Dict, Hashable, cast ...@@ -46,8 +46,9 @@ from typing import Any, Iterable, Sequence, Set, Union, Dict, Hashable, cast
try: try:
import cython import cython
cython_optimized = cython.compiled # type: bool cython_optimized = cython.compiled # type: bool
if cython_optimized:
import DHParser.shadow_cython as cython
except ImportError: except ImportError:
# import DHParser.Shadow as cython
cython_optimized = False # type: bool cython_optimized = False # type: bool
import DHParser.shadow_cython as cython import DHParser.shadow_cython as cython
......
...@@ -15,7 +15,8 @@ setup( ...@@ -15,7 +15,8 @@ setup(
name='DHParser', name='DHParser',
version=__version__, version=__version__,
packages=['DHParser'], packages=['DHParser'],
ext_modules=cythonize(['DHParser/stringview.py', ext_modules=cythonize(['DHParser/toolkit.py',
'DHParser/stringview.py',
'DHParser/preprocess.py', 'DHParser/preprocess.py',
'DHParser/error.py', 'DHParser/error.py',
'DHParser/syntaxtree.py', 'DHParser/syntaxtree.py',
......
...@@ -7,8 +7,8 @@ import doctest ...@@ -7,8 +7,8 @@ import doctest
import multiprocessing import multiprocessing
import os import os
import platform import platform
import subprocess #import subprocess
import sys #import sys
import time import time
import threading import threading
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment