Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 08:39:16

0001 #!/usr/bin/env python
0002 # Licensed under the Apache License, Version 2.0 (the "License");
0003 # you may not use this file except in compliance with the License.
0004 # You may obtain a copy of the License at
0005 # http://www.apache.org/licenses/LICENSE-2.0
0006 #
0007 # Authors:
0008 # - Wen Guan, wen.guan@cern.ch, 2017
0009 # - Paul Nilsson, paul.nilsson@cern.ch, 2018
0010 
0011 
0012 import logging
0013 import sys
0014 
0015 from pilot.common.exception import RunPayloadFailure, PilotException
0016 
0017 if sys.version_info < (2, 7):
0018     import unittest2 as unittest
0019 else:
0020     import unittest
0021 
0022 logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
0023 
0024 
0025 class TestException(unittest.TestCase):
0026     """
0027     Unit tests for exceptions.
0028     """
0029 
0030     def test_run_payload_failure(self):
0031         """
0032         Make sure that es message thread works as expected.
0033         """
0034 
0035         try:
0036             pass
0037             raise RunPayloadFailure(a='message a', b='message b')
0038         except PilotException as ex:
0039             self.assertIsInstance(ex, PilotException)
0040             self.assertEqual(ex.get_error_code(), 1305)
0041             logging.info("\nException: error code: %s\n\nMain message: %s\n\nFullStack: %s" % (ex.get_error_code(),
0042                                                                                                str(ex),
0043                                                                                                ex.get_detail()))
0044 
0045         try:
0046             pass
0047             raise RunPayloadFailure("Test message")
0048         except PilotException as ex:
0049             self.assertIsInstance(ex, PilotException)
0050             self.assertEqual(ex.get_error_code(), 1305)
0051             logging.info("\nException: error code: %s\n\nMain message: %s\n\nFullStack: %s" % (ex.get_error_code(),
0052                                                                                                str(ex),
0053                                                                                                ex.get_detail()))