Skip to content

Commit 00a1faf

Browse files
committed
appease checks on CI by reworking some code for pylint's benefit alone
1 parent 7a059ee commit 00a1faf

6 files changed

Lines changed: 30 additions & 20 deletions

File tree

mig/shared/conf.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,3 @@ def get_all_store_vgrids(unique_resource_name):
257257
store_vgrids = dict([(store['name'], store['vgrid'])
258258
for store in store_units])
259259
return store_vgrids
260-
261-
262-
def is_configuration_like(obj):
263-
"""Does the given object quack like a MiG Configuration."""
264-
return Configuration.is_configuration_like(obj)

tests/support/__init__.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,11 @@ def _reset_logging(self, stream):
210210
@staticmethod
211211
def _make_configuration_instance(testcase, configuration_to_make):
212212
from mig.shared.conf import RuntimeConfiguration, \
213-
get_configuration_object, \
214-
is_configuration_like
215-
if is_configuration_like(configuration_to_make):
216-
return configuration_to_make
213+
get_configuration_object
214+
if configuration_to_make == 'preexisting':
215+
configuration = testcase._configuration
216+
assert isinstance(configuration, RuntimeConfiguration)
217+
return configuration
217218
elif configuration_to_make == 'fakeconfig':
218219
fake_configuration = FakeConfiguration(logger=testcase.logger)
219220
return RuntimeConfiguration(fake_configuration)
@@ -233,14 +234,17 @@ def _provide_configuration(self):
233234
def configuration(self):
234235
"""Init a fake configuration if not already done"""
235236

236-
if self._configuration is not None:
237-
return self._configuration
238-
239237
configuration_to_make = self._provide_configuration()
240238

241239
if configuration_to_make == 'unspecified':
242240
raise AssertionError(
243241
"configuration access but testcase did not request it")
242+
elif configuration_to_make == 'preexisting':
243+
# unconditionally proceed so as to be certain that a valid
244+
# configuration has been supplied and get it instrumented
245+
pass
246+
elif self._configuration is not None:
247+
return self._configuration
244248

245249
configuration_instance = self._make_configuration_instance(
246250
self, configuration_to_make)

tests/support/fakes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
"""Fake implementations of various assistant functionality used by MiG logic."""
3232

33+
34+
__INSTRUMENTED_MARKER = "__" + __name__
35+
36+
3337
class FakeSendEmail:
3438
def __init__(self):
3539
self.calls = []
@@ -112,8 +116,14 @@ def instrument_test_case(mig_test_case=None, mig_configuration=None):
112116
assert inspect.ismethod(getattr(mig_configuration, 'context_set', None)), \
113117
"supplied configuration must be usable at runtime"
114118

119+
maybe_marker = getattr(mig_configuration, __INSTRUMENTED_MARKER, None)
120+
if maybe_marker is __INSTRUMENTED_MARKER:
121+
return
122+
115123
fakes_by_context_key = {
116124
'notifier': make_fake_notifier(mig_test_case=mig_test_case),
117125
}
118126
for content_key, context_value in fakes_by_context_key.items():
119127
mig_configuration.context_set(content_key, context_value)
128+
129+
setattr(mig_configuration, __INSTRUMENTED_MARKER, __INSTRUMENTED_MARKER)

tests/test_mig_lib_templates.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ def before_each(self):
2828

2929
# allow the dummy plugin to be loaded
3030
sys.path.append(TEST_DATA_DIR)
31-
32-
def after_each(self):
33-
# undo changes to path for dummy plugin
34-
sys.path.pop()
31+
self._register_check(lambda: sys.path.pop())
3532

3633
def _provide_configuration(self):
3734
return 'testconfig'
@@ -131,12 +128,12 @@ class TestMigSharedTemplates_cli(MigTestCase):
131128
def before_each(self):
132129
self.test_conf_file = os.path.join(
133130
TEST_DATA_DIR, 'MiGserver--templates.conf')
131+
134132
# allow the dummy plugin to be loaded
135133
sys.path.append(TEST_DATA_DIR)
134+
self._register_check(lambda: sys.path.pop())
136135

137136
def after_each(self):
138-
# undo changes to path for dummy plugin
139-
sys.path.pop()
140137
# clean up the configuration file specified cache directory
141138
shutil.rmtree(DUMMY_CACHE_DIR, ignore_errors=True)
142139

tests/test_mig_shared_functionality_tmplinterface.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,16 @@ class MigSharedFunctionalityTmplInterface__basics(MigTestCase, SnapshotAssertMix
7474
TEST_CONF_FILE = os.path.join(TEST_DATA_DIR, 'MiGserver--templates.conf')
7575

7676
def _provide_configuration(self):
77-
return get_configuration_object(
78-
self.TEST_CONF_FILE, skip_log=True, disable_auth_log=True)
77+
return 'preexisting'
7978

8079
def before_each(self):
80+
self._configuration = get_configuration_object(
81+
self.TEST_CONF_FILE, skip_log=True, disable_auth_log=True)
82+
8183
# clean up the configuration file specified cache directory
8284
shutil.rmtree(DUMMY_CACHE_DIR, ignore_errors=True)
8385

86+
# allow the dummy plugin to be loaded
8487
sys.path.append(TEST_DATA_DIR)
8588
self._register_check(lambda: sys.path.pop())
8689

tests/test_mig_wsgibin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ def _arrange_use_of_testplugin(self):
285285
# provision template directories
286286
os.makedirs(TEST_TEMPLATE_CACHE_DIR)
287287

288+
# allow the dummy plugin to be loaded
288289
sys.path.append(TEST_DATA_DIR)
289290
self._register_check(lambda: sys.path.pop())
290291

0 commit comments

Comments
 (0)