Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

No longer possible to stub an exception raise in latest version #8

Open
sk- opened this issue Feb 11, 2012 · 4 comments
Open

No longer possible to stub an exception raise in latest version #8

sk- opened this issue Feb 11, 2012 · 4 comments

Comments

@sk-
Copy link

sk- commented Feb 11, 2012

In the latest version is no longer possible to raise an exception from a Stub. Version 3.0 was working just fine. The problem is that the line checking is the returned value was an instance of exception was deleted from the method _expectation_value.

See the attached test below:

import os
from unittest import TestCase

from ludibrio import Stub, Mock

class TestRaiseException(TestCase):
    def test_stub_raise_exception(self):
        with Stub() as exists:
            exists() >> Exception('exist raised a mocked exception from stub')
        with self.assertRaises(Exception):
            exists()
        exists.restore_import()

    def test_mock_rasise_exception(self):
        with Mock() as exists:
            exists() >> Exception('exist raised a mocked exception from stub')
        with self.assertRaises(Exception):
            exists()
        exists.validate()
@dsully
Copy link

dsully commented May 16, 2012

I'm seeing the same thing. Works in 3.0.3, not in 3.1.0

@ws6ramair
Copy link

I have also experienced this. I will start investigation.

@ws6ramair
Copy link

Hi @sk- ,

I'm glad that I wasn't the only one who ran into this issue! I have created pull request: #13 to resolve this issue. Currently under review by the great @nsigustavo

Hope it goes through!

Thanks,
-Jason

@nokios
Copy link

nokios commented Jul 26, 2013

Can we get a bump on this? I just found this and it seems much easier to use than mock. I reviewed the code and it looks good to me.. just my two cents.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants