Add mock to TestCase attribute in addition to parameter list
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
requests-mock |
New
|
Undecided
|
Unassigned |
Bug Description
Being able to decorate a `TestCase` class and have it apply automatically to all `test*` methods is pretty cool. However, it means modifying every method to accept the new argument. To me, it would make more sense to add the mock to the `TestCase` object itself (i.e. `self`, in the tests).
In my tests I've subclassed `requests_
```python
class Mocker(
"""A version of requests_
https:/
"""
def __init__(self, **kwargs):
self._attr = kwargs.pop('attr', None)
def copy(self):
m = Mocker(
)
return m
def decorate_
def inner(*args, **kwargs):
with self as m:
if self._attr:
return inner
```