From 2fd901d682dd8e828188dc38752e42c08660e8cd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 22 Dec 2020 18:16:24 +0000 Subject: [PATCH] Check that public functions don't begin with _ --- tests.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests.py b/tests.py index 945032a6f..3c2942165 100644 --- a/tests.py +++ b/tests.py @@ -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 + ' ✓')