sorenisanerd / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

mock.patch prevent nosetest from discovering test generator method #173

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using Mock 0.8.0 and Nose 1.1.2:

test.py:

import mock

import useless_module

class TestClass:

    def check_call(self, number, result):
        assert result == number * 3

    @mock.patch("useless_module.SomeClass")
    def test_method(self, mock_someclass):
        for i in range(3):
            result = i * 3
            yield self.check_call, i, result

useless_module.py:

class SomeClass:
    def return_something():
        raise

When running `nosetests test.py`, here's the output:

% nosetests test.py
.
----------------------------------------------------------------------
Ran 1 test in 0.001s

OK

Obviously, the test is not running the test generator. When I remove the patch, 
it works fine:

% nosetests test.py          
...
----------------------------------------------------------------------
Ran 3 tests in 0.001s

OK

I attached the reproducible code.

Original issue reported on code.google.com by charlesa...@gmail.com on 3 Sep 2012 at 11:51

Attachments:

GoogleCodeExporter commented 9 years ago
This appears to be a duplicate of issue 172.

Original comment by fuzzyman on 3 Sep 2012 at 12:01