Skip to content

Commit ef5de36

Browse files
committed
Follow-up to #505 for the recently added cmdapi unit tests to reduce legacy
self-test noise.
1 parent 5b8e95f commit ef5de36

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

mig/shared/cmdapi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,7 @@ def parse_command_args(configuration, command_list):
182182
return (function, user_arguments_dict)
183183

184184

185-
def legacy_main(_exit=sys.exit, _print=print):
186-
from mig.shared.conf import get_configuration_object
187-
conf = get_configuration_object()
185+
def legacy_main(conf, print=print, _exit=sys.exit):
188186
for cmd_list in [['cp', 'srcfile', 'dstfile'],
189187
['cp', 'srcfile', 'srcfile2', 'dstdir'],
190188
['cp', '-r', 'srcdir', 'dstdir'],
@@ -200,4 +198,6 @@ def legacy_main(_exit=sys.exit, _print=print):
200198

201199

202200
if __name__ == '__main__':
203-
legacy_main()
201+
from mig.shared.conf import get_configuration_object
202+
conf = get_configuration_object()
203+
legacy_main(conf)

tests/test_mig_shared_cmdapi.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ def test_parse_command_args_mqueue_no_flags_entry(self):
294294

295295

296296
class TestMigSharedCmdapi__legacy_main(MigTestCase):
297-
"""Unit tests for legacy cmdapi self-checks"""
297+
"""Unit tests for corresponding module legacy self-checks"""
298+
299+
def _provide_configuration(self):
300+
return 'testconfig'
298301

299302
def test_existing_main(self):
300303
"""Run the legacy self-tests directly in module"""
@@ -315,7 +318,8 @@ def record_last_print(value):
315318
"""Keep track of printed output"""
316319
raise_on_error_exit.last_print = value
317320

318-
legacy_main(_exit=raise_on_error_exit, _print=record_last_print)
321+
legacy_main(self.configuration, print=record_last_print,
322+
_exit=raise_on_error_exit)
319323

320324

321325
if __name__ == '__main__':

0 commit comments

Comments
 (0)