[apparmor] [patch] simplify setup_all_tests() call in utils test
Christian Boltz
apparmor at cboltz.de
Thu Mar 5 00:22:47 UTC 2015
Hello,
here's the I-know-what-I-am-doing reply ;-)
Am Mittwoch, 4. März 2015 schrieb Seth Arnold:
> On Thu, Mar 05, 2015 at 12:06:06AM +0100, Christian Boltz wrote:
> > this patch simplifies the setup_all_tests() call and avoids that
> > every test needs to import sys.
> >
> > The patch applies on top of my previous patches, and as usual, I
> > propose it for trunk and 2.9.
>
> I don't this I like this one much it feels like it is increasing the
> coupling between modules / files without any obvious benefits.
>
> Which standard tool didn't work before that now works, or whst other
> problem is being solved?
Nothing was broken ;-)
The point of this patch is to simplify the setup_all_tests() call (which
we'll have in _lots of_ test-*.py files) and to move that bit of code
into common_test.py (where it will exist only once).
Basically this code (before applying the patch)
if __name__ == '__main__':
setup_all_tests(sys.modules[__name__])
always expands to (as you can see from the if condition above it):
if __name__ == '__main__':
setup_all_tests(sys.modules['__main__'])
and sys.modules['__main__'] will also always give the same result.
This means we are calling setup_all_tests() always with the same
parameter, which means it is in fact a constant.
Needless to say that a function parameter that is always the same
doesn't need to be handed over as parameter ;-)
I can't imagine a case where we would hand over a different parameter,
and if we really need to do that one day, we can easily make it an
(optional) parameter again.
BTW: If I had noticed earlier that __name__ is always '__main__',
I'd have implemented the simplified way from the beginning.
> > [ test-loop-simplify.diff ]
Regards,
Christian Boltz
--
[Stefan Wegmann sucht ein optisch ansprechendes Brennprogramm]
Hhhhmmm, unter diesem Aspekt habe ich das ganze noch gar nicht
betrachtet. Was würde denn Deinen gehobenen ästhetischen Ansprüchen
entgegenkommen? Ein zartes Chartreuse im leicht fluffigen Kontrast
zu einem frühlingshaften Ostereidottergelb? Mit Buttons im floralen
Design und Chiffoneske Hilfsfenster mit einer luftig durch-
scheinenden Optik? [Thomas Templin in suse-linux]
More information about the AppArmor
mailing list