示例#1
0
 def test_job_error(self):
     exc_args = ('some error', )
     e = exc.JobError(*exc_args, jobid=1234)
     self.assertEqual(1234, e.jobid)
     self.assertRaisesRegex(exc.JobError, r'\(jobid=1234\) some error',
                            raise_exc, e)
     self.assertEqual(exc_args, e.args)
示例#2
0
 def test_reraise_job_error_no_message(self):
     try:
         try:
             raise ValueError('random value error')
         except ValueError as e:
             raise exc.JobError(jobid=1234) from e
     except exc.JobError as e:
         assert '[jobid=1234]: random value error' == str(e)
示例#3
0
    def test_job_error(self):
        exc_args = ('some error', )
        e = exc.JobError(*exc_args, jobid=1234)
        assert 1234 == e.jobid
        with pytest.raises(exc.JobError, match=r'\[jobid=1234\] some error'):
            raise_exc(e)

        assert exc_args == e.args
示例#4
0
def test_reraise_job_error():
    try:
        try:
            raise ValueError('random value error')
        except ValueError as e:
            raise exc.JobError('some error', jobid=1234) from e
    except exc.JobError as e:
        assert '[jobid=1234] some error: random value error' == str(e)
示例#5
0
 def test_reraise_job_error_no_message(self):
     try:
         try:
             raise ValueError('random value error')
         except ValueError as e:
             raise exc.JobError(jobid=1234) from e
     except exc.JobError as e:
         self.assertEqual('(jobid=1234): random value error', str(e))
示例#6
0
 def test_reraise_job_error(self):
     try:
         try:
             raise ValueError('random value error')
         except ValueError as e:
             raise exc.JobError('some error', jobid=1234) from e
     except exc.JobError as e:
         self.assertEqual('[jobid=1234] some error: random value error',
                          str(e))