aboutsummaryrefslogtreecommitdiffstats
path: root/test/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/__init__.py')
-rw-r--r--test/__init__.py17
1 files changed, 7 insertions, 10 deletions
diff --git a/test/__init__.py b/test/__init__.py
index 1c5c139..8005917 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -2,18 +2,14 @@
from __future__ import absolute_import, print_function, unicode_literals
import logging
import yamlish
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
import yaml
import tempfile
import textwrap
-from textwrap import dedent
INPUT = 1
OUTPUT = 2
+
def _generate_test_name(source):
"""
Clean up human-friendly test name into a method name.
@@ -21,6 +17,7 @@ def _generate_test_name(source):
out = source.replace(' ', '_').replace(':', '').replace(',', '').lower()
return "test_%s" % out
+
def _create_input_test(test_src, tested_function):
"""
Decorate tested function to be used as a method for TestCase.
@@ -77,10 +74,10 @@ def _create_output_test(test_src, tested_function):
return do_test_expected
-
def generate_testsuite(test_data, test_case_shell, test_fce, direction=INPUT):
"""
- Generate tests from the test data, class to build upon and function to use for testing.
+ Generate tests from the test data, class to build upon and function
+ to use for testing.
"""
for in_test in test_data:
if ('skip' in in_test) and in_test['skip']:
@@ -88,8 +85,8 @@ def generate_testsuite(test_data, test_case_shell, test_fce, direction=INPUT):
continue
name = _generate_test_name(in_test['name'])
if direction == INPUT:
- test_method = _create_input_test (in_test, test_fce)
+ test_method = _create_input_test(in_test, test_fce)
elif direction == OUTPUT:
test_method = _create_output_test(in_test, test_fce)
- test_method.__name__ = str('test_%s' % name) # IGNORE:W0622
- setattr (test_case_shell, test_method.__name__, test_method)
+ test_method.__name__ = str('test_%s' % name)
+ setattr(test_case_shell, test_method.__name__, test_method)