On Wednesday, October 24, 2012 03:59:15 PM David Malcolm wrote:
> On Mon, 2012-10-08 at 16:24 -0400, Paul Moore wrote:
> [...]
>
> > diff --git a/tests/01-allow.py b/tests/01-allow.py
>
> [...]
>
> > +if __name__ == "__main__":
> > + parser = argparse.ArgumentParser()
> > + parser.add_argument("-b", "--bpf", action="store_true")
> > + parser.add_argument("-p", "--pfc", action="store_true")
> > + args = parser.parse_args()
> > + f = test(args)
> > + if (args.bpf):
> > + f.export_bpf(sys.stdout)
> > + else:
> > + f.export_pfc(sys.stdout)
>
> I see the above fragment apparently duplicated between all tests.
>
> Potentially you could introduce a tests/support.py with something like:
>
> def main(test):
> parser = argparse.ArgumentParser()
> parser.add_argument("-b", "--bpf", action="store_true")
> parser.add_argument("-p", "--pfc", action="store_true")
> args = parser.parse_args()
> f = test(args)
> if (args.bpf):
> f.export_bpf(sys.stdout)
> else:
> f.export_pfc(sys.stdout)
>
> and then each test could have this at the top:
> from support import main
> and this at the bottom:
> main(test)
I had wanted to do something like that - we do the same with the C tests - but
wasn't sure I could use Python modules in the same directory (I thought I
would need to install them first).
> Given that the test filenames contain the "-" character they're not
> directly importable, so I don't think you need to do the
> if __name__ == "__main__"
> dance.
Okay, good to know, thanks.
--
paul moore
security and virtualization @ redhat
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
libseccomp-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss