--- you can reply above this line ---

New issue 217: mock.patch-Decorator and test fixtures don’t work together
https://bitbucket.org/hpk42/pytest/issue/217/mockpatch-decorator-and-test-fixtures-don

Stefan Scherfke:

This:

```
#!python
import mock

@mock.patch('sys.exit')
def test_spam(exit_mock, tmpdir):
    assert isinstance(exit_mock. mock.Mock)
```
does not work and fails like this:


```
#!bash
__________________________________ test_spam ___________________________________

    @wraps(func)
    def patched(*args, **keywargs):
        # don't use a with here (backwards compatability with Python 2.4)
        extra_args = []
        entered_patchers = []
    
        # can't use try...except...finally because of Python 2.4
        # compatibility
        exc_info = tuple()
        try:
            try:
                for patching in patched.patchings:
                    arg = patching.__enter__()
                    entered_patchers.append(patching)
                    if patching.attribute_name is not None:
                        keywargs.update(arg)
                    elif patching.new is DEFAULT:
                        extra_args.append(arg)
    
                args += tuple(extra_args)
>               return func(*args, **keywargs)
E               TypeError: test_spam() takes exactly 2 arguments (1 given)

/Users/stefan/.virtualenvs/simpy/lib/python3.2/site-packages/mock.py:1190: 
TypeError
```

I’m not sure whether pytest or mock is to blame so I posted this on each issue 
tracker.

Responsible: hpk42
--

This is an issue notification from bitbucket.org. You are receiving
this either because you are the owner of the issue, or you are
following the issue.
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to