1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-17 04:23:50 +03:00

python:tests: Ensure that we don’t overwrite tests

If the file iterator returns two entries with the same name, one may
overwrite the other.

script_iterator() currently ensures this won’t happen, but it pays to be
safe.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton
2023-05-25 17:03:48 +12:00
committed by Andrew Bartlett
parent 7390eb1254
commit fb759809f8

View File

@@ -255,7 +255,10 @@ class PythonScriptUsageTests(TestCase):
self.assertIn('usage', out.lower() + err.lower(),
'stdout:\n%s\nstderr:\n%s' % (out, err))
setattr(cls, 'test_%s' % name, _f)
attr = 'test_%s' % name
if hasattr(cls, attr):
raise RuntimeError(f'Usage test {attr} already exists!')
setattr(cls, attr, _f)
class HelpTestSuper(TestCase):
@@ -344,7 +347,10 @@ class HelpTestSuper(TestCase):
if self.check_multiline:
self.assertIn('\n', out, 'expected multi-line output')
setattr(cls, 'test_%s' % name, _f)
attr = 'test_%s' % name
if hasattr(cls, attr):
raise RuntimeError(f'Usage test {attr} already exists!')
setattr(cls, attr, _f)
class PythonScriptHelpTests(HelpTestSuper):