Remove white spaces caught by check-files.py

This commit is contained in:
Mohammad Azim Khan 2018-06-13 16:31:26 +01:00
parent ddde34c698
commit b73159d639
3 changed files with 113 additions and 113 deletions

View file

@ -57,20 +57,20 @@ END_CASE_REGEX = '/\*\s*END_CASE\s*\*/'
class InvalidFileFormat(Exception): class InvalidFileFormat(Exception):
""" """
Exception to indicate invalid file format. Exception to indicate invalid file format.
""" """
pass pass
class FileWrapper(io.FileIO): class FileWrapper(io.FileIO):
""" """
File wrapper class. Provides reading with line no. tracking. File wrapper class. Provides reading with line no. tracking.
""" """
def __init__(self, file_name): def __init__(self, file_name):
""" """
Init file handle. Init file handle.
:param file_name: File path to open. :param file_name: File path to open.
""" """
super(FileWrapper, self).__init__(file_name, 'r') super(FileWrapper, self).__init__(file_name, 'r')
@ -174,7 +174,7 @@ def gen_dispatch(name, deps):
def parse_until_pattern(funcs_f, end_regex): def parse_until_pattern(funcs_f, end_regex):
""" """
Parses function headers or helper code until end pattern. Parses function headers or helper code until end pattern.
:param funcs_f: file object for .functions file :param funcs_f: file object for .functions file
:param end_regex: Pattern to stop parsing :param end_regex: Pattern to stop parsing
:return: Test suite headers code :return: Test suite headers code
@ -193,7 +193,7 @@ def parse_until_pattern(funcs_f, end_regex):
def parse_suite_deps(funcs_f): def parse_suite_deps(funcs_f):
""" """
Parses test suite dependencies. Parses test suite dependencies.
:param funcs_f: file object for .functions file :param funcs_f: file object for .functions file
:return: List of test suite dependencies. :return: List of test suite dependencies.
""" """
@ -213,7 +213,7 @@ def parse_suite_deps(funcs_f):
def parse_function_deps(line): def parse_function_deps(line):
""" """
Parses function dependencies. Parses function dependencies.
:param line: Line from .functions file that has dependencies. :param line: Line from .functions file that has dependencies.
:return: List of dependencies. :return: List of dependencies.
""" """
@ -230,7 +230,7 @@ def parse_function_deps(line):
def parse_function_signature(line): def parse_function_signature(line):
""" """
Parsing function signature Parsing function signature
:param line: Line from .functions file that has a function signature. :param line: Line from .functions file that has a function signature.
:return: function name, argument list, local variables for wrapper function and argument dispatch code. :return: function name, argument list, local variables for wrapper function and argument dispatch code.
""" """
@ -271,7 +271,7 @@ def parse_function_signature(line):
def parse_function_code(funcs_f, deps, suite_deps): def parse_function_code(funcs_f, deps, suite_deps):
""" """
Parses out a function from function file object and generates function and dispatch code. Parses out a function from function file object and generates function and dispatch code.
:param funcs_f: file object of the functions file. :param funcs_f: file object of the functions file.
:param deps: List of dependencies :param deps: List of dependencies
:param suite_deps: List of test suite dependencies :param suite_deps: List of test suite dependencies
@ -319,7 +319,7 @@ def parse_function_code(funcs_f, deps, suite_deps):
def parse_functions(funcs_f): def parse_functions(funcs_f):
""" """
Returns functions code pieces Returns functions code pieces
:param funcs_f: file object of the functions file. :param funcs_f: file object of the functions file.
:return: List of test suite dependencies, test function dispatch code, function code and :return: List of test suite dependencies, test function dispatch code, function code and
a dict with function identifiers and arguments info. a dict with function identifiers and arguments info.
@ -361,7 +361,7 @@ def parse_functions(funcs_f):
def escaped_split(str, ch): def escaped_split(str, ch):
""" """
Split str on character ch but ignore escaped \{ch} Split str on character ch but ignore escaped \{ch}
Since return value is used to write back to the intermediate data file. Since return value is used to write back to the intermediate data file.
Any escape characters in the input are retained in the output. Any escape characters in the input are retained in the output.
:param str: String to split :param str: String to split
@ -388,7 +388,7 @@ def escaped_split(str, ch):
def parse_test_data(data_f, debug=False): def parse_test_data(data_f, debug=False):
""" """
Parses .data file Parses .data file
:param data_f: file object of the data file. :param data_f: file object of the data file.
:return: Generator that yields test name, function name, dependency list and function argument list. :return: Generator that yields test name, function name, dependency list and function argument list.
""" """
@ -432,7 +432,7 @@ def parse_test_data(data_f, debug=False):
def gen_dep_check(dep_id, dep): def gen_dep_check(dep_id, dep):
""" """
Generate code for the dependency. Generate code for the dependency.
:param dep_id: Dependency identifier :param dep_id: Dependency identifier
:param dep: Dependency macro :param dep: Dependency macro
:return: Dependency check code :return: Dependency check code
@ -456,7 +456,7 @@ def gen_dep_check(dep_id, dep):
def gen_expression_check(exp_id, exp): def gen_expression_check(exp_id, exp):
""" """
Generates code for expression check Generates code for expression check
:param exp_id: Expression Identifier :param exp_id: Expression Identifier
:param exp: Expression/Macro :param exp: Expression/Macro
:return: Expression check code :return: Expression check code
@ -476,7 +476,7 @@ def write_deps(out_data_f, test_deps, unique_deps):
""" """
Write dependencies to intermediate test data file. Write dependencies to intermediate test data file.
It also returns dependency check code. It also returns dependency check code.
:param out_data_f: Output intermediate data file :param out_data_f: Output intermediate data file
:param test_deps: Dependencies :param test_deps: Dependencies
:param unique_deps: Mutable list to track unique dependencies that are global to this re-entrant function. :param unique_deps: Mutable list to track unique dependencies that are global to this re-entrant function.
@ -501,7 +501,7 @@ def write_parameters(out_data_f, test_args, func_args, unique_expressions):
""" """
Writes test parameters to the intermediate data file. Writes test parameters to the intermediate data file.
Also generates expression code. Also generates expression code.
:param out_data_f: Output intermediate data file :param out_data_f: Output intermediate data file
:param test_args: Test parameters :param test_args: Test parameters
:param func_args: Function arguments :param func_args: Function arguments
@ -533,7 +533,7 @@ def write_parameters(out_data_f, test_args, func_args, unique_expressions):
def gen_suite_deps_checks(suite_deps, dep_check_code, expression_code): def gen_suite_deps_checks(suite_deps, dep_check_code, expression_code):
""" """
Adds preprocessor checks for test suite dependencies. Adds preprocessor checks for test suite dependencies.
:param suite_deps: Test suite dependencies read from the .functions file. :param suite_deps: Test suite dependencies read from the .functions file.
:param dep_check_code: Dependency check code :param dep_check_code: Dependency check code
:param expression_code: Expression check code :param expression_code: Expression check code
@ -557,7 +557,7 @@ def gen_suite_deps_checks(suite_deps, dep_check_code, expression_code):
def gen_from_test_data(data_f, out_data_f, func_info, suite_deps): def gen_from_test_data(data_f, out_data_f, func_info, suite_deps):
""" """
Generates dependency checks, expression code and intermediate data file from test data file. Generates dependency checks, expression code and intermediate data file from test data file.
:param data_f: Data file object :param data_f: Data file object
:param out_data_f:Output intermediate data file :param out_data_f:Output intermediate data file
:param func_info: Dict keyed by function and with function id and arguments info :param func_info: Dict keyed by function and with function id and arguments info

View file

@ -36,7 +36,7 @@ class GenDep(TestCase):
def test_deps_list(self): def test_deps_list(self):
""" """
Test that gen_dep() correctly creates deps for given dependency list. Test that gen_dep() correctly creates deps for given dependency list.
:return: :return:
""" """
deps = ['DEP1', 'DEP2'] deps = ['DEP1', 'DEP2']
dep_start, dep_end = gen_deps(deps) dep_start, dep_end = gen_deps(deps)
@ -50,7 +50,7 @@ class GenDep(TestCase):
def test_disabled_deps_list(self): def test_disabled_deps_list(self):
""" """
Test that gen_dep() correctly creates deps for given dependency list. Test that gen_dep() correctly creates deps for given dependency list.
:return: :return:
""" """
deps = ['!DEP1', '!DEP2'] deps = ['!DEP1', '!DEP2']
dep_start, dep_end = gen_deps(deps) dep_start, dep_end = gen_deps(deps)
@ -64,7 +64,7 @@ class GenDep(TestCase):
def test_mixed_deps_list(self): def test_mixed_deps_list(self):
""" """
Test that gen_dep() correctly creates deps for given dependency list. Test that gen_dep() correctly creates deps for given dependency list.
:return: :return:
""" """
deps = ['!DEP1', 'DEP2'] deps = ['!DEP1', 'DEP2']
dep_start, dep_end = gen_deps(deps) dep_start, dep_end = gen_deps(deps)
@ -78,7 +78,7 @@ class GenDep(TestCase):
def test_empty_deps_list(self): def test_empty_deps_list(self):
""" """
Test that gen_dep() correctly creates deps for given dependency list. Test that gen_dep() correctly creates deps for given dependency list.
:return: :return:
""" """
deps = [] deps = []
dep_start, dep_end = gen_deps(deps) dep_start, dep_end = gen_deps(deps)
@ -88,7 +88,7 @@ class GenDep(TestCase):
def test_large_deps_list(self): def test_large_deps_list(self):
""" """
Test that gen_dep() correctly creates deps for given dependency list. Test that gen_dep() correctly creates deps for given dependency list.
:return: :return:
""" """
deps = [] deps = []
count = 10 count = 10
@ -107,7 +107,7 @@ class GenDepOneLine(TestCase):
def test_deps_list(self): def test_deps_list(self):
""" """
Test that gen_dep() correctly creates deps for given dependency list. Test that gen_dep() correctly creates deps for given dependency list.
:return: :return:
""" """
deps = ['DEP1', 'DEP2'] deps = ['DEP1', 'DEP2']
dep_str = gen_deps_one_line(deps) dep_str = gen_deps_one_line(deps)
@ -162,14 +162,14 @@ class GenFunctionWrapper(TestCase):
def test_params_unpack(self): def test_params_unpack(self):
""" """
Test that params are properly unpacked in the function call. Test that params are properly unpacked in the function call.
:return: :return:
""" """
code = gen_function_wrapper('test_a', '', ('a', 'b', 'c', 'd')) code = gen_function_wrapper('test_a', '', ('a', 'b', 'c', 'd'))
expected = ''' expected = '''
void test_a_wrapper( void ** params ) void test_a_wrapper( void ** params )
{ {
test_a( a, b, c, d ); test_a( a, b, c, d );
} }
@ -179,14 +179,14 @@ void test_a_wrapper( void ** params )
def test_local(self): def test_local(self):
""" """
Test that params are properly unpacked in the function call. Test that params are properly unpacked in the function call.
:return: :return:
""" """
code = gen_function_wrapper('test_a', 'int x = 1;', ('x', 'b', 'c', 'd')) code = gen_function_wrapper('test_a', 'int x = 1;', ('x', 'b', 'c', 'd'))
expected = ''' expected = '''
void test_a_wrapper( void ** params ) void test_a_wrapper( void ** params )
{ {
int x = 1; int x = 1;
test_a( x, b, c, d ); test_a( x, b, c, d );
} }
@ -196,8 +196,8 @@ int x = 1;
def test_empty_params(self): def test_empty_params(self):
""" """
Test that params are properly unpacked in the function call. Test that params are properly unpacked in the function call.
:return: :return:
""" """
code = gen_function_wrapper('test_a', '', ()) code = gen_function_wrapper('test_a', '', ())
expected = ''' expected = '''
@ -219,7 +219,7 @@ class GenDispatch(TestCase):
def test_dispatch(self): def test_dispatch(self):
""" """
Test that dispatch table entry is generated correctly. Test that dispatch table entry is generated correctly.
:return: :return:
""" """
code = gen_dispatch('test_a', ['DEP1', 'DEP2']) code = gen_dispatch('test_a', ['DEP1', 'DEP2'])
expected = ''' expected = '''
@ -234,7 +234,7 @@ class GenDispatch(TestCase):
def test_empty_deps(self): def test_empty_deps(self):
""" """
Test empty dependency list. Test empty dependency list.
:return: :return:
""" """
code = gen_dispatch('test_a', []) code = gen_dispatch('test_a', [])
expected = ''' expected = '''
@ -250,8 +250,8 @@ class StringIOWrapper(StringIO, object):
def __init__(self, file_name, data, line_no = 1): def __init__(self, file_name, data, line_no = 1):
""" """
Init file handle. Init file handle.
:param file_name: :param file_name:
:param data: :param data:
:param line_no: :param line_no:
""" """
@ -262,7 +262,7 @@ class StringIOWrapper(StringIO, object):
def next(self): def next(self):
""" """
Iterator return impl. Iterator return impl.
:return: :return:
""" """
line = super(StringIOWrapper, self).next() line = super(StringIOWrapper, self).next()
return line return line
@ -270,9 +270,9 @@ class StringIOWrapper(StringIO, object):
def readline(self, limit=0): def readline(self, limit=0):
""" """
Wrap the base class readline. Wrap the base class readline.
:param limit: :param limit:
:return: :return:
""" """
line = super(StringIOWrapper, self).readline() line = super(StringIOWrapper, self).readline()
if line: if line:
@ -288,8 +288,8 @@ class ParseUntilPattern(TestCase):
def test_suite_headers(self): def test_suite_headers(self):
""" """
Test that suite headers are parsed correctly. Test that suite headers are parsed correctly.
:return: :return:
""" """
data = '''#include "mbedtls/ecp.h" data = '''#include "mbedtls/ecp.h"
@ -307,9 +307,9 @@ class ParseUntilPattern(TestCase):
def test_line_no(self): def test_line_no(self):
""" """
Test that #line is set to correct line no. in source .function file. Test that #line is set to correct line no. in source .function file.
:return: :return:
""" """
data = '''#include "mbedtls/ecp.h" data = '''#include "mbedtls/ecp.h"
@ -329,7 +329,7 @@ class ParseUntilPattern(TestCase):
def test_no_end_header_comment(self): def test_no_end_header_comment(self):
""" """
Test that InvalidFileFormat is raised when end header comment is missing. Test that InvalidFileFormat is raised when end header comment is missing.
:return: :return:
""" """
data = '''#include "mbedtls/ecp.h" data = '''#include "mbedtls/ecp.h"
@ -347,8 +347,8 @@ class ParseSuiteDeps(TestCase):
def test_suite_deps(self): def test_suite_deps(self):
""" """
:return: :return:
""" """
data = ''' data = '''
* depends_on:MBEDTLS_ECP_C * depends_on:MBEDTLS_ECP_C
@ -363,7 +363,7 @@ class ParseSuiteDeps(TestCase):
def test_no_end_dep_comment(self): def test_no_end_dep_comment(self):
""" """
Test that InvalidFileFormat is raised when end dep comment is missing. Test that InvalidFileFormat is raised when end dep comment is missing.
:return: :return:
""" """
data = ''' data = '''
* depends_on:MBEDTLS_ECP_C * depends_on:MBEDTLS_ECP_C
@ -374,10 +374,10 @@ class ParseSuiteDeps(TestCase):
def test_deps_split(self): def test_deps_split(self):
""" """
Test that InvalidFileFormat is raised when end dep comment is missing. Test that InvalidFileFormat is raised when end dep comment is missing.
:return: :return:
""" """
data = ''' data = '''
* depends_on:MBEDTLS_ECP_C:A:B: C : D :F : G: !H * depends_on:MBEDTLS_ECP_C:A:B: C : D :F : G: !H
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
''' '''
@ -389,13 +389,13 @@ class ParseSuiteDeps(TestCase):
class ParseFuncDeps(TestCase): class ParseFuncDeps(TestCase):
""" """
Test Suite for testing parse_function_deps() Test Suite for testing parse_function_deps()
""" """
def test_function_deps(self): def test_function_deps(self):
""" """
Test that parse_function_deps() correctly parses function dependencies. Test that parse_function_deps() correctly parses function dependencies.
:return: :return:
""" """
line = '/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */' line = '/* BEGIN_CASE depends_on:MBEDTLS_ENTROPY_NV_SEED:MBEDTLS_FS_IO */'
expected = ['MBEDTLS_ENTROPY_NV_SEED', 'MBEDTLS_FS_IO'] expected = ['MBEDTLS_ENTROPY_NV_SEED', 'MBEDTLS_FS_IO']
@ -405,7 +405,7 @@ class ParseFuncDeps(TestCase):
def test_no_deps(self): def test_no_deps(self):
""" """
Test that parse_function_deps() correctly parses function dependencies. Test that parse_function_deps() correctly parses function dependencies.
:return: :return:
""" """
line = '/* BEGIN_CASE */' line = '/* BEGIN_CASE */'
deps = parse_function_deps(line) deps = parse_function_deps(line)
@ -414,7 +414,7 @@ class ParseFuncDeps(TestCase):
def test_poorly_defined_deps(self): def test_poorly_defined_deps(self):
""" """
Test that parse_function_deps() correctly parses function dependencies. Test that parse_function_deps() correctly parses function dependencies.
:return: :return:
""" """
line = '/* BEGIN_CASE depends_on:MBEDTLS_FS_IO: A : !B:C : F*/' line = '/* BEGIN_CASE depends_on:MBEDTLS_FS_IO: A : !B:C : F*/'
deps = parse_function_deps(line) deps = parse_function_deps(line)
@ -423,13 +423,13 @@ class ParseFuncDeps(TestCase):
class ParseFuncSignature(TestCase): class ParseFuncSignature(TestCase):
""" """
Test Suite for parse_function_signature(). Test Suite for parse_function_signature().
""" """
def test_int_and_char_params(self): def test_int_and_char_params(self):
""" """
Test int and char parameters parsing Test int and char parameters parsing
:return: :return:
""" """
line = 'void entropy_threshold( char * a, int b, int result )' line = 'void entropy_threshold( char * a, int b, int result )'
name, args, local, arg_dispatch = parse_function_signature(line) name, args, local, arg_dispatch = parse_function_signature(line)
@ -441,7 +441,7 @@ class ParseFuncSignature(TestCase):
def test_hex_params(self): def test_hex_params(self):
""" """
Test hex parameters parsing Test hex parameters parsing
:return: :return:
""" """
line = 'void entropy_threshold( char * a, HexParam_t * h, int result )' line = 'void entropy_threshold( char * a, HexParam_t * h, int result )'
name, args, local, arg_dispatch = parse_function_signature(line) name, args, local, arg_dispatch = parse_function_signature(line)
@ -453,7 +453,7 @@ class ParseFuncSignature(TestCase):
def test_non_void_function(self): def test_non_void_function(self):
""" """
Test invalid signature (non void). Test invalid signature (non void).
:return: :return:
""" """
line = 'int entropy_threshold( char * a, HexParam_t * h, int result )' line = 'int entropy_threshold( char * a, HexParam_t * h, int result )'
self.assertRaises(ValueError, parse_function_signature, line) self.assertRaises(ValueError, parse_function_signature, line)
@ -461,7 +461,7 @@ class ParseFuncSignature(TestCase):
def test_unsupported_arg(self): def test_unsupported_arg(self):
""" """
Test unsupported arguments (not among int, char * and HexParam_t) Test unsupported arguments (not among int, char * and HexParam_t)
:return: :return:
""" """
line = 'int entropy_threshold( char * a, HexParam_t * h, int * result )' line = 'int entropy_threshold( char * a, HexParam_t * h, int * result )'
self.assertRaises(ValueError, parse_function_signature, line) self.assertRaises(ValueError, parse_function_signature, line)
@ -469,7 +469,7 @@ class ParseFuncSignature(TestCase):
def test_no_params(self): def test_no_params(self):
""" """
Test no parameters. Test no parameters.
:return: :return:
""" """
line = 'void entropy_threshold()' line = 'void entropy_threshold()'
name, args, local, arg_dispatch = parse_function_signature(line) name, args, local, arg_dispatch = parse_function_signature(line)
@ -487,7 +487,7 @@ class ParseFunctionCode(TestCase):
def test_no_function(self): def test_no_function(self):
""" """
Test no test function found. Test no test function found.
:return: :return:
""" """
data = ''' data = '''
No No
@ -500,7 +500,7 @@ function
def test_no_end_case_comment(self): def test_no_end_case_comment(self):
""" """
Test missing end case. Test missing end case.
:return: :return:
""" """
data = ''' data = '''
void test_func() void test_func()
@ -514,7 +514,7 @@ void test_func()
def test_parse_function_signature_called(self, parse_function_signature_mock): def test_parse_function_signature_called(self, parse_function_signature_mock):
""" """
Test parse_function_code() Test parse_function_code()
:return: :return:
""" """
parse_function_signature_mock.return_value = ('test_func', [], '', []) parse_function_signature_mock.return_value = ('test_func', [], '', [])
data = ''' data = '''
@ -537,7 +537,7 @@ void test_func()
gen_dispatch_mock): gen_dispatch_mock):
""" """
Test generated code. Test generated code.
:return: :return:
""" """
parse_function_signature_mock.return_value = ('func', [], '', []) parse_function_signature_mock.return_value = ('func', [], '', [])
gen_function_wrapper_mock.return_value = '' gen_function_wrapper_mock.return_value = ''
@ -582,7 +582,7 @@ exit:
gen_dispatch_mock): gen_dispatch_mock):
""" """
Test when exit label is present. Test when exit label is present.
:return: :return:
""" """
parse_function_signature_mock.return_value = ('func', [], '', []) parse_function_signature_mock.return_value = ('func', [], '', [])
gen_function_wrapper_mock.return_value = '' gen_function_wrapper_mock.return_value = ''
@ -624,7 +624,7 @@ class ParseFunction(TestCase):
def test_begin_header(self, parse_until_pattern_mock): def test_begin_header(self, parse_until_pattern_mock):
""" """
Test that begin header is checked and parse_until_pattern() is called. Test that begin header is checked and parse_until_pattern() is called.
:return: :return:
""" """
def stop(this): def stop(this):
raise Exception raise Exception
@ -644,7 +644,7 @@ class ParseFunction(TestCase):
def test_begin_helper(self, parse_until_pattern_mock): def test_begin_helper(self, parse_until_pattern_mock):
""" """
Test that begin helper is checked and parse_until_pattern() is called. Test that begin helper is checked and parse_until_pattern() is called.
:return: :return:
""" """
def stop(this): def stop(this):
raise Exception raise Exception
@ -665,7 +665,7 @@ void print_helloworld()
def test_begin_dep(self, parse_suite_deps_mock): def test_begin_dep(self, parse_suite_deps_mock):
""" """
Test that begin dep is checked and parse_suite_deps() is called. Test that begin dep is checked and parse_suite_deps() is called.
:return: :return:
""" """
def stop(this): def stop(this):
raise Exception raise Exception
@ -684,7 +684,7 @@ void print_helloworld()
def test_begin_function_dep(self, parse_function_deps_mock): def test_begin_function_dep(self, parse_function_deps_mock):
""" """
Test that begin dep is checked and parse_function_deps() is called. Test that begin dep is checked and parse_function_deps() is called.
:return: :return:
""" """
def stop(this): def stop(this):
raise Exception raise Exception
@ -705,7 +705,7 @@ void print_helloworld()
def test_return(self, parse_function_deps_mock, parse_function_code_mock): def test_return(self, parse_function_deps_mock, parse_function_code_mock):
""" """
Test that begin case is checked and parse_function_code() is called. Test that begin case is checked and parse_function_code() is called.
:return: :return:
""" """
def stop(this): def stop(this):
raise Exception raise Exception
@ -740,7 +740,7 @@ void print_helloworld()
def test_parsing(self): def test_parsing(self):
""" """
Test case parsing. Test case parsing.
:return: :return:
""" """
data = '''/* BEGIN_HEADER */ data = '''/* BEGIN_HEADER */
#include "mbedtls/ecp.h" #include "mbedtls/ecp.h"
@ -833,7 +833,7 @@ void test_func2_wrapper( void ** params )
def test_same_function_name(self): def test_same_function_name(self):
""" """
Test name conflict. Test name conflict.
:return: :return:
""" """
data = '''/* BEGIN_HEADER */ data = '''/* BEGIN_HEADER */
#include "mbedtls/ecp.h" #include "mbedtls/ecp.h"
@ -872,14 +872,14 @@ class ExcapedSplit(TestCase):
def test_invalid_input(self): def test_invalid_input(self):
""" """
Test when input split character is not a character. Test when input split character is not a character.
:return: :return:
""" """
self.assertRaises(ValueError, escaped_split, '', 'string') self.assertRaises(ValueError, escaped_split, '', 'string')
def test_empty_string(self): def test_empty_string(self):
""" """
Test empty strig input. Test empty strig input.
:return: :return:
""" """
splits = escaped_split('', ':') splits = escaped_split('', ':')
self.assertEqual(splits, []) self.assertEqual(splits, [])
@ -887,7 +887,7 @@ class ExcapedSplit(TestCase):
def test_no_escape(self): def test_no_escape(self):
""" """
Test with no escape character. The behaviour should be same as str.split() Test with no escape character. The behaviour should be same as str.split()
:return: :return:
""" """
s = 'yahoo:google' s = 'yahoo:google'
splits = escaped_split(s, ':') splits = escaped_split(s, ':')
@ -896,7 +896,7 @@ class ExcapedSplit(TestCase):
def test_escaped_input(self): def test_escaped_input(self):
""" """
Test imput that has escaped delimiter. Test imput that has escaped delimiter.
:return: :return:
""" """
s = 'yahoo\:google:facebook' s = 'yahoo\:google:facebook'
splits = escaped_split(s, ':') splits = escaped_split(s, ':')
@ -905,7 +905,7 @@ class ExcapedSplit(TestCase):
def test_escaped_escape(self): def test_escaped_escape(self):
""" """
Test imput that has escaped delimiter. Test imput that has escaped delimiter.
:return: :return:
""" """
s = 'yahoo\\\:google:facebook' s = 'yahoo\\\:google:facebook'
splits = escaped_split(s, ':') splits = escaped_split(s, ':')
@ -914,7 +914,7 @@ class ExcapedSplit(TestCase):
def test_all_at_once(self): def test_all_at_once(self):
""" """
Test imput that has escaped delimiter. Test imput that has escaped delimiter.
:return: :return:
""" """
s = 'yahoo\\\:google:facebook\:instagram\\\:bbc\\\\:wikipedia' s = 'yahoo\\\:google:facebook\:instagram\\\:bbc\\\\:wikipedia'
splits = escaped_split(s, ':') splits = escaped_split(s, ':')
@ -929,7 +929,7 @@ class ParseTestData(TestCase):
def test_parser(self): def test_parser(self):
""" """
Test that tests are parsed correctly from data file. Test that tests are parsed correctly from data file.
:return: :return:
""" """
data = """ data = """
Diffie-Hellman full exchange #1 Diffie-Hellman full exchange #1
@ -970,7 +970,7 @@ dhm_selftest:
def test_with_dependencies(self): def test_with_dependencies(self):
""" """
Test that tests with dependencies are parsed. Test that tests with dependencies are parsed.
:return: :return:
""" """
data = """ data = """
Diffie-Hellman full exchange #1 Diffie-Hellman full exchange #1
@ -997,7 +997,7 @@ dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
def test_no_args(self): def test_no_args(self):
""" """
Test AssertionError is raised when test function name and args line is missing. Test AssertionError is raised when test function name and args line is missing.
:return: :return:
""" """
data = """ data = """
Diffie-Hellman full exchange #1 Diffie-Hellman full exchange #1
@ -1020,7 +1020,7 @@ dhm_do_dhm:10:"93450983094850938450983409623":10:"9345098304850938450983409622"
def test_incomplete_data(self): def test_incomplete_data(self):
""" """
Test AssertionError is raised when test function name and args line is missing. Test AssertionError is raised when test function name and args line is missing.
:return: :return:
""" """
data = """ data = """
Diffie-Hellman full exchange #1 Diffie-Hellman full exchange #1
@ -1038,13 +1038,13 @@ depends_on:YAHOO
class GenDepCheck(TestCase): class GenDepCheck(TestCase):
""" """
Test suite for gen_dep_check(). It is assumed this function is called with valid inputs. Test suite for gen_dep_check(). It is assumed this function is called with valid inputs.
""" """
def test_gen_dep_check(self): def test_gen_dep_check(self):
""" """
Test that dependency check code generated correctly. Test that dependency check code generated correctly.
:return: :return:
""" """
expected = """ expected = """
case 5: case 5:
@ -1062,7 +1062,7 @@ class GenDepCheck(TestCase):
def test_noT(self): def test_noT(self):
""" """
Test dependency with !. Test dependency with !.
:return: :return:
""" """
expected = """ expected = """
case 5: case 5:
@ -1080,27 +1080,27 @@ class GenDepCheck(TestCase):
def test_empty_dependency(self): def test_empty_dependency(self):
""" """
Test invalid dependency input. Test invalid dependency input.
:return: :return:
""" """
self.assertRaises(AssertionError, gen_dep_check, 5, '!') self.assertRaises(AssertionError, gen_dep_check, 5, '!')
def test_negative_dep_id(self): def test_negative_dep_id(self):
""" """
Test invalid dependency input. Test invalid dependency input.
:return: :return:
""" """
self.assertRaises(AssertionError, gen_dep_check, -1, 'YAHOO') self.assertRaises(AssertionError, gen_dep_check, -1, 'YAHOO')
class GenExpCheck(TestCase): class GenExpCheck(TestCase):
""" """
Test suite for gen_expression_check(). It is assumed this function is called with valid inputs. Test suite for gen_expression_check(). It is assumed this function is called with valid inputs.
""" """
def test_gen_exp_check(self): def test_gen_exp_check(self):
""" """
Test that expression check code generated correctly. Test that expression check code generated correctly.
:return: :return:
""" """
expected = """ expected = """
case 5: case 5:
@ -1114,14 +1114,14 @@ class GenExpCheck(TestCase):
def test_invalid_expression(self): def test_invalid_expression(self):
""" """
Test invalid expression input. Test invalid expression input.
:return: :return:
""" """
self.assertRaises(AssertionError, gen_expression_check, 5, '') self.assertRaises(AssertionError, gen_expression_check, 5, '')
def test_negative_exp_id(self): def test_negative_exp_id(self):
""" """
Test invalid expression id. Test invalid expression id.
:return: :return:
""" """
self.assertRaises(AssertionError, gen_expression_check, -1, 'YAHOO') self.assertRaises(AssertionError, gen_expression_check, -1, 'YAHOO')
@ -1134,7 +1134,7 @@ class WriteDeps(TestCase):
def test_no_test_deps(self): def test_no_test_deps(self):
""" """
Test when test_deps is empty. Test when test_deps is empty.
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_deps = [] unique_deps = []
@ -1145,8 +1145,8 @@ class WriteDeps(TestCase):
def test_unique_dep_ids(self): def test_unique_dep_ids(self):
""" """
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_deps = [] unique_deps = []
@ -1185,8 +1185,8 @@ class WriteDeps(TestCase):
def test_dep_id_repeat(self): def test_dep_id_repeat(self):
""" """
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_deps = [] unique_deps = []
@ -1235,7 +1235,7 @@ class WriteParams(TestCase):
def test_no_params(self): def test_no_params(self):
""" """
Test with empty test_args Test with empty test_args
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_expressions = [] unique_expressions = []
@ -1247,7 +1247,7 @@ class WriteParams(TestCase):
def test_no_exp_param(self): def test_no_exp_param(self):
""" """
Test when there is no macro or expression in the params. Test when there is no macro or expression in the params.
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_expressions = [] unique_expressions = []
@ -1260,7 +1260,7 @@ class WriteParams(TestCase):
def test_hex_format_int_param(self): def test_hex_format_int_param(self):
""" """
Test int parameter in hex format. Test int parameter in hex format.
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_expressions = [] unique_expressions = []
@ -1273,7 +1273,7 @@ class WriteParams(TestCase):
def test_with_exp_param(self): def test_with_exp_param(self):
""" """
Test when there is macro or expression in the params. Test when there is macro or expression in the params.
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_expressions = [] unique_expressions = []
@ -1304,7 +1304,7 @@ class WriteParams(TestCase):
def test_with_repeate_calls(self): def test_with_repeate_calls(self):
""" """
Test when write_parameter() is called with same macro or expression. Test when write_parameter() is called with same macro or expression.
:return: :return:
""" """
s = StringIOWrapper('test_suite_ut.data', '') s = StringIOWrapper('test_suite_ut.data', '')
unique_expressions = [] unique_expressions = []
@ -1343,13 +1343,13 @@ class WriteParams(TestCase):
class GenTestSuiteDepsChecks(TestCase): class GenTestSuiteDepsChecks(TestCase):
""" """
""" """
def test_empty_suite_deps(self): def test_empty_suite_deps(self):
""" """
Test with empty suite_deps list. Test with empty suite_deps list.
:return: :return:
""" """
dep_check_code, expression_code = gen_suite_deps_checks([], 'DEP_CHECK_CODE', 'EXPRESSION_CODE') dep_check_code, expression_code = gen_suite_deps_checks([], 'DEP_CHECK_CODE', 'EXPRESSION_CODE')
self.assertEqual(dep_check_code, 'DEP_CHECK_CODE') self.assertEqual(dep_check_code, 'DEP_CHECK_CODE')
@ -1358,8 +1358,8 @@ class GenTestSuiteDepsChecks(TestCase):
def test_suite_deps(self): def test_suite_deps(self):
""" """
Test with suite_deps list. Test with suite_deps list.
:return: :return:
""" """
dep_check_code, expression_code = gen_suite_deps_checks(['SUITE_DEP'], 'DEP_CHECK_CODE', 'EXPRESSION_CODE') dep_check_code, expression_code = gen_suite_deps_checks(['SUITE_DEP'], 'DEP_CHECK_CODE', 'EXPRESSION_CODE')
exprectd_dep_check_code = ''' exprectd_dep_check_code = '''
@ -1377,8 +1377,8 @@ EXPRESSION_CODE
def test_no_dep_no_exp(self): def test_no_dep_no_exp(self):
""" """
Test when there are no dependency and expression code. Test when there are no dependency and expression code.
:return: :return:
""" """
dep_check_code, expression_code = gen_suite_deps_checks([], '', '') dep_check_code, expression_code = gen_suite_deps_checks([], '', '')
self.assertEqual(dep_check_code, '') self.assertEqual(dep_check_code, '')
@ -1396,7 +1396,7 @@ class GenFromTestData(TestCase):
def test_intermediate_data_file(self, gen_suite_deps_checks_mock, write_parameters_mock, write_deps_mock): def test_intermediate_data_file(self, gen_suite_deps_checks_mock, write_parameters_mock, write_deps_mock):
""" """
Test that intermediate data file is written with expected data. Test that intermediate data file is written with expected data.
:return: :return:
""" """
data = ''' data = '''
My test My test
@ -1428,7 +1428,7 @@ func1:0
def test_function_not_found(self): def test_function_not_found(self):
""" """
Test that AssertError is raised when function info in not found. Test that AssertError is raised when function info in not found.
:return: :return:
""" """
data = ''' data = '''
My test My test
@ -1444,7 +1444,7 @@ func1:0
def test_different_func_args(self): def test_different_func_args(self):
""" """
Test that AssertError is raised when no. of parameters and function args differ. Test that AssertError is raised when no. of parameters and function args differ.
:return: :return:
""" """
data = ''' data = '''
My test My test
@ -1460,7 +1460,7 @@ func1:0
def test_output(self): def test_output(self):
""" """
Test that intermediate data file is written with expected data. Test that intermediate data file is written with expected data.
:return: :return:
""" """
data = ''' data = '''
My test 1 My test 1

View file

@ -130,7 +130,7 @@ typedef void (*TestWrapper_t)( void ** );
*/ */
TestWrapper_t test_funcs[] = TestWrapper_t test_funcs[] =
{{ {{
{dispatch_code} {dispatch_code}
#line {line_no} "suites/main_test.function" #line {line_no} "suites/main_test.function"
}}; }};