mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
parser/errors.py: convert to unittest.main()
Do this to simplify test identification, and also support the different invocation mechanisms of unittest, like running individual tests. MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1070 Signed-off-by: Steve Beattie <steve.beattie@canonical.com> Approved-by: John Johansen <john@jjmx.net>
This commit is contained in:
parent
12cf66ff0b
commit
87896b9496
1 changed files with 3 additions and 16 deletions
|
@ -158,22 +158,9 @@ def main():
|
|||
p = ArgumentParser()
|
||||
p.add_argument('-p', '--parser', default=testlib.DEFAULT_PARSER, action="store", dest='parser',
|
||||
help="Specify path of apparmor parser to use [default = %(default)s]")
|
||||
p.add_argument('-v', '--verbose', action="store_true", dest="verbose")
|
||||
config = p.parse_args()
|
||||
|
||||
verbosity = 2 if config.verbose else 1
|
||||
|
||||
test_suite = unittest.TestSuite()
|
||||
test_suite.addTest(unittest.TestLoader().loadTestsFromTestCase(AAErrorTests))
|
||||
try:
|
||||
result = unittest.TextTestRunner(verbosity=verbosity).run(test_suite)
|
||||
except Exception:
|
||||
rc = 1
|
||||
else:
|
||||
rc = 0 if result.wasSuccessful() else 1
|
||||
|
||||
return rc
|
||||
config, args = p.parse_known_args()
|
||||
|
||||
unittest.main(argv=sys.argv[:1] + args)
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue