Check that public functions don't begin with _

merge-requests/8/head
Bob Mottram 2020-12-22 18:16:24 +00:00
parent 5cd9aa8d66
commit 2fd901d682
1 changed files with 16 additions and 1 deletions

View File

@ -2626,6 +2626,7 @@ def testFunctions():
for name, properties in functionProperties.items():
if name in exclusions:
continue
isLocalModule = False
if not properties['calledInModule']:
print('function ' + name +
' in module ' + properties['module'] +
@ -2636,9 +2637,10 @@ def testFunctions():
modName = properties['calledInModule'][0]
if modName not in excludeLocal and \
modName == properties['module']:
isLocalModule = True
if not name.startswith('_'):
print('Local function ' + name +
' in ' + modName + ' does not begin with _')
' in ' + modName + '.py does not begin with _')
assert False
if name not in excludeImports:
@ -2649,6 +2651,19 @@ def testFunctions():
if importStr not in open(modName + '.py').read():
print(importStr + ' not found in ' + modName + '.py')
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 + '')