-
Notifications
You must be signed in to change notification settings - Fork 219
allow to directly import constants from easybuild.framework.easyconfig.constants #4144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1278,6 +1278,17 @@ def test_constant_doc(self): | |
| ] | ||
| self.assertEqual(len(doc.split('\n')), sum([len(temps)] + [len(x) for x in temps])) | ||
|
|
||
| def test_constants_import(self): | ||
| """Test importing constants works""" | ||
| # Sanity check that importing an EC constant works as-if using EASYCONFIG_CONSTANTS | ||
| from easybuild.framework.easyconfig.constants import SYSTEM | ||
| self.assertEqual(SYSTEM, easyconfig.constants.EASYCONFIG_CONSTANTS['SYSTEM'][0]) | ||
|
||
| # Check each individual constant | ||
| constants = __import__('easybuild.framework.easyconfig.constants', fromlist=[None]) | ||
| for name, (value, _doc) in easyconfig.constants.EASYCONFIG_CONSTANTS.items(): | ||
| self.assertTrue(hasattr(constants, name), 'Missing ' + name) | ||
| self.assertEqual(getattr(constants, name), value) | ||
|
|
||
| def test_build_options(self): | ||
| """Test configure/build/install options, both strings and lists.""" | ||
| orig_contents = '\n'.join([ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, does
__all__.extend(list(EASYCONFIG_CONSTANTS.keys())work too?Just to make sure we don't overlooked adding stuff to
allif additional (real) constants are added toconstants.pyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested that and no.
__all__has a default value if it is not set (only), so at that point it is an undefined variable.It actually isn't really required because (almost) nobody does
from easyconfig.constants import *which is the only use case of__all__, everything else works without it.