mirror of https://gitlab.com/bashrc2/epicyon
Check that public functions don't begin with _
parent
5cd9aa8d66
commit
2fd901d682
17
tests.py
17
tests.py
|
@ -2626,6 +2626,7 @@ def testFunctions():
|
||||||
for name, properties in functionProperties.items():
|
for name, properties in functionProperties.items():
|
||||||
if name in exclusions:
|
if name in exclusions:
|
||||||
continue
|
continue
|
||||||
|
isLocalModule = False
|
||||||
if not properties['calledInModule']:
|
if not properties['calledInModule']:
|
||||||
print('function ' + name +
|
print('function ' + name +
|
||||||
' in module ' + properties['module'] +
|
' in module ' + properties['module'] +
|
||||||
|
@ -2636,9 +2637,10 @@ def testFunctions():
|
||||||
modName = properties['calledInModule'][0]
|
modName = properties['calledInModule'][0]
|
||||||
if modName not in excludeLocal and \
|
if modName not in excludeLocal and \
|
||||||
modName == properties['module']:
|
modName == properties['module']:
|
||||||
|
isLocalModule = True
|
||||||
if not name.startswith('_'):
|
if not name.startswith('_'):
|
||||||
print('Local function ' + name +
|
print('Local function ' + name +
|
||||||
' in ' + modName + ' does not begin with _')
|
' in ' + modName + '.py does not begin with _')
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
if name not in excludeImports:
|
if name not in excludeImports:
|
||||||
|
@ -2649,6 +2651,19 @@ def testFunctions():
|
||||||
if importStr not in open(modName + '.py').read():
|
if importStr not in open(modName + '.py').read():
|
||||||
print(importStr + ' not found in ' + modName + '.py')
|
print(importStr + ' not found in ' + modName + '.py')
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
|
if not isLocalModule:
|
||||||
|
if name.startswith('_'):
|
||||||
|
excludePublic = [
|
||||||
|
'pyjsonld',
|
||||||
|
'daemon',
|
||||||
|
'tests'
|
||||||
|
]
|
||||||
|
modName = properties['module']
|
||||||
|
if modName not in excludePublic:
|
||||||
|
print('Public function ' + name + ' in ' +
|
||||||
|
modName + '.py begins with _')
|
||||||
|
assert False
|
||||||
print('Function: ' + name + ' ✓')
|
print('Function: ' + name + ' ✓')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue