Commit ff14fddc authored by eckhart's avatar eckhart

- small refactorings

parent e459a8d5
......@@ -586,7 +586,7 @@ def run_test_function(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
namespace. To run all tests in a module, call
......@@ -597,10 +597,12 @@ def runner(test_classes, namespace):
in such classes or functions, the name of which starts with "test".
test_classes: Either a string or a list of strings that contains
the names of test or test classes. Each test and, in the case
of a test class, all tests within the test class will be
tests: String or list of strings with the names of tests to
run. If empty, runner searches by itself all objects the
of which starts with 'test' and runs it (if its a function)
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
``globals()`` should be used.
......@@ -617,16 +619,17 @@ def runner(test_classes, namespace):
from DHParser.testing import runner
runner("", globals())
if test_classes:
if isinstance(test_classes, str):
test_classes = test_classes.split(" ")
# collect all test classes, in case no methods or classes have been passed explicitly
test_classes = []
test_functions = []
for name in namespace.keys():
if tests:
if isinstance(tests, str):
tests = tests.split(' ')
assert all(test.lower().startswith('test') for test in tests)
tests = namespace.keys()
for name in tests:
if name.lower().startswith('test'):
if inspect.isclass(namespace[name]):
#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
import cython
cython_optimized = cython.compiled # type: bool
if cython_optimized:
import DHParser.shadow_cython as cython
except ImportError:
# import DHParser.Shadow as cython
cython_optimized = False # type: bool
import DHParser.shadow_cython as cython
......@@ -15,7 +15,8 @@ setup(
......@@ -7,8 +7,8 @@ import doctest
import multiprocessing
import os
import platform
import subprocess
import sys
#import subprocess
#import sys
import time
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