mirror of https://gitlab.com/bashrc2/epicyon
Fix function tests
parent
0aa42a1d71
commit
cfd1e7b24c
49
tests.py
49
tests.py
|
@ -2613,9 +2613,10 @@ def getFunctionCalls(name: str, lines: [], startLineCtr: int,
|
||||||
callsFunctions = []
|
callsFunctions = []
|
||||||
functionContentStr = ''
|
functionContentStr = ''
|
||||||
for lineCtr in range(startLineCtr + 1, len(lines)):
|
for lineCtr in range(startLineCtr + 1, len(lines)):
|
||||||
if lines[lineCtr].startswith('def '):
|
lineStr = lines[lineCtr].strip()
|
||||||
|
if lineStr.startswith('def '):
|
||||||
break
|
break
|
||||||
if lines[lineCtr].startswith('class '):
|
if lineStr.startswith('class '):
|
||||||
break
|
break
|
||||||
functionContentStr += lines[lineCtr]
|
functionContentStr += lines[lineCtr]
|
||||||
for funcName, properties in functionProperties.items():
|
for funcName, properties in functionProperties.items():
|
||||||
|
@ -2635,14 +2636,14 @@ def functionArgsMatch(callArgs: [], funcArgs: []):
|
||||||
for a in callArgs:
|
for a in callArgs:
|
||||||
if a == 'self':
|
if a == 'self':
|
||||||
continue
|
continue
|
||||||
if '=' not in a:
|
if '=' not in a or a.startswith("'"):
|
||||||
callArgsCtr += 1
|
callArgsCtr += 1
|
||||||
|
|
||||||
funcArgsCtr = 0
|
funcArgsCtr = 0
|
||||||
for a in funcArgs:
|
for a in funcArgs:
|
||||||
if a == 'self':
|
if a == 'self':
|
||||||
continue
|
continue
|
||||||
if '=' not in a:
|
if '=' not in a or a.startswith("'"):
|
||||||
funcArgsCtr += 1
|
funcArgsCtr += 1
|
||||||
|
|
||||||
return callArgsCtr >= funcArgsCtr
|
return callArgsCtr >= funcArgsCtr
|
||||||
|
@ -2670,7 +2671,7 @@ def testFunctions():
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
modules[modName]['lines'] = lines
|
modules[modName]['lines'] = lines
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if not line.startswith('def '):
|
if not line.strip().startswith('def '):
|
||||||
continue
|
continue
|
||||||
methodName = line.split('def ', 1)[1].split('(')[0]
|
methodName = line.split('def ', 1)[1].split('(')[0]
|
||||||
methodArgs = \
|
methodArgs = \
|
||||||
|
@ -2694,7 +2695,9 @@ def testFunctions():
|
||||||
'pyjsonld'
|
'pyjsonld'
|
||||||
]
|
]
|
||||||
excludeFuncs = [
|
excludeFuncs = [
|
||||||
'link'
|
'link',
|
||||||
|
'set',
|
||||||
|
'get'
|
||||||
]
|
]
|
||||||
# which modules is each function used within?
|
# which modules is each function used within?
|
||||||
for modName, modProperties in modules.items():
|
for modName, modProperties in modules.items():
|
||||||
|
@ -2702,7 +2705,11 @@ def testFunctions():
|
||||||
for name, properties in functionProperties.items():
|
for name, properties in functionProperties.items():
|
||||||
lineCtr = 0
|
lineCtr = 0
|
||||||
for line in modules[modName]['lines']:
|
for line in modules[modName]['lines']:
|
||||||
if line.startswith('def '):
|
lineStr = line.strip()
|
||||||
|
if lineStr.startswith('def '):
|
||||||
|
lineCtr += 1
|
||||||
|
continue
|
||||||
|
if lineStr.startswith('class '):
|
||||||
lineCtr += 1
|
lineCtr += 1
|
||||||
continue
|
continue
|
||||||
if name + '(' in line:
|
if name + '(' in line:
|
||||||
|
@ -2735,7 +2742,22 @@ def testFunctions():
|
||||||
|
|
||||||
# don't check these functions, because they are procedurally called
|
# don't check these functions, because they are procedurally called
|
||||||
exclusions = [
|
exclusions = [
|
||||||
|
'do_GET',
|
||||||
|
'do_POST',
|
||||||
|
'do_HEAD',
|
||||||
|
'__run',
|
||||||
|
'globaltrace',
|
||||||
|
'localtrace',
|
||||||
|
'kill',
|
||||||
|
'clone',
|
||||||
|
'unregister_rdf_parser',
|
||||||
'set_document_loader',
|
'set_document_loader',
|
||||||
|
'has_property',
|
||||||
|
'has_value',
|
||||||
|
'add_value',
|
||||||
|
'get_values',
|
||||||
|
'remove_property',
|
||||||
|
'remove_value',
|
||||||
'normalize',
|
'normalize',
|
||||||
'get_document_loader',
|
'get_document_loader',
|
||||||
'runInboxQueueWatchdog',
|
'runInboxQueueWatchdog',
|
||||||
|
@ -2764,17 +2786,26 @@ def testFunctions():
|
||||||
'setOrganizationScheme'
|
'setOrganizationScheme'
|
||||||
]
|
]
|
||||||
excludeImports = [
|
excludeImports = [
|
||||||
'link'
|
'link',
|
||||||
|
'start'
|
||||||
]
|
]
|
||||||
excludeLocal = [
|
excludeLocal = [
|
||||||
'pyjsonld',
|
'pyjsonld',
|
||||||
'daemon',
|
'daemon',
|
||||||
'tests'
|
'tests'
|
||||||
]
|
]
|
||||||
|
excludeMods = [
|
||||||
|
'pyjsonld'
|
||||||
|
]
|
||||||
# check that functions are called somewhere
|
# check that functions are called somewhere
|
||||||
for name, properties in functionProperties.items():
|
for name, properties in functionProperties.items():
|
||||||
|
if name.startswith('__'):
|
||||||
|
if name.endswith('__'):
|
||||||
|
continue
|
||||||
if name in exclusions:
|
if name in exclusions:
|
||||||
continue
|
continue
|
||||||
|
if properties['module'] in excludeMods:
|
||||||
|
continue
|
||||||
isLocalFunction = False
|
isLocalFunction = False
|
||||||
if not properties['calledInModule']:
|
if not properties['calledInModule']:
|
||||||
print('function ' + name +
|
print('function ' + name +
|
||||||
|
@ -2819,7 +2850,7 @@ def testFunctions():
|
||||||
for modName, modProperties in modules.items():
|
for modName, modProperties in modules.items():
|
||||||
lineCtr = 0
|
lineCtr = 0
|
||||||
for line in modules[modName]['lines']:
|
for line in modules[modName]['lines']:
|
||||||
if line.startswith('def '):
|
if line.strip().startswith('def '):
|
||||||
name = line.split('def ')[1].split('(')[0]
|
name = line.split('def ')[1].split('(')[0]
|
||||||
callsList = \
|
callsList = \
|
||||||
getFunctionCalls(name, modules[modName]['lines'],
|
getFunctionCalls(name, modules[modName]['lines'],
|
||||||
|
|
Loading…
Reference in New Issue