/usr/share/pyshared/doublex/test/issue-14.py is in python-doublex 1.7.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Thanks to Guillermo Pascual (@pasku1)
# When you spy a method that has a decorator and you want to check the
# arguments with a hamcrest matcher, it seems like matchers are
# ignored.
from functools import wraps
import unittest
from doublex import *
from hamcrest import *
class Collaborator(object):
def simple_decorator(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
return func(self, *args, **kwargs)
return wrapper
@simple_decorator
def method_with_two_arguments(self, one, two):
pass
class ExampleTest(unittest.TestCase):
def test_spying_a_method_with_a_decorator(self):
collaborator = Spy(Collaborator)
collaborator.method_with_two_arguments(1, 'foo bar')
assert_that(collaborator.method_with_two_arguments,
called().with_args(1, ends_with('bar')))
|