Python tests: skip importing weirdly-named modules (#27151)

* Python tests: allow importing weirdly-named modules

e.g. with dashes in name

* SIP tests: allow importing weirdly-named modules

* Skip modules with invalid names

* Changes from review

* Update from review

* Update from review

* Cleanup
This commit is contained in:
iarspider 2021-11-08 20:22:33 +01:00 committed by GitHub
parent db504db9aa
commit f164bae4a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,7 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import inspect
import os
import re
import shutil
import llnl.util.tty as tty
@ -144,6 +145,8 @@ def import_modules(self):
modules.append(path.replace(root + os.sep, '', 1).replace(
'.py', '').replace('/', '.'))
modules = [mod for mod in modules if re.match('[a-zA-Z0-9._]+$', mod)]
tty.debug('Detected the following modules: {0}'.format(modules))
return modules

View File

@ -5,6 +5,7 @@
import inspect
import os
import re
import llnl.util.tty as tty
from llnl.util.filesystem import find, join_path, working_dir
@ -81,6 +82,8 @@ def import_modules(self):
modules.append(path.replace(root + os.sep, '', 1).replace(
'.py', '').replace('/', '.'))
modules = [mod for mod in modules if re.match('[a-zA-Z0-9._]+$', mod)]
tty.debug('Detected the following modules: {0}'.format(modules))
return modules