-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Support for the Michele Simionato's 'decorator' module. #697
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Original comment by Bruno Oliveira (BitBucket: nicoddemus, GitHub: nicoddemus): Thanks, you seem to have got to the bottom of the issue... Can you go ahead and provide a PR? I think the |
Original comment by Éric Araujo (BitBucket: Merwok, GitHub: Merwok): Python 3.4 provides inspect.unwrap for this use case; it’s a little more complicated than the hasattr solution. Code is here, for inspiration if not for copying depending on licensing compatibility: |
Original comment by Bruno Oliveira (BitBucket: nicoddemus, GitHub: nicoddemus): I see, thanks for the links! I think a solution would be to use if hasattr(inspect, 'unwrap'):
realfunction = inspect.unwrap(realfunction)
else:
while hasattr(realfunction, "__wrapped__"):
realfunction = realfunction.__wrapped__ |
Original comment by Vladislav Turbanov (BitBucket: iptvd, GitHub: iptvd): Didn't dig into the |
Original comment by Bruno Oliveira (BitBucket: nicoddemus, GitHub: nicoddemus): Yes, the appropriate approach would be to implement something like:
And apply this in other parts of the code base that need something similar... probably everywhere that uses Anyone volunteers to write a PR? :) |
Original comment by Bruno Oliveira (BitBucket: nicoddemus, GitHub: nicoddemus): I approve the reference, for obvious reasons. :) |
we recently addded wrapper inwrapping, is this still an issue @nicoddemus @vladipus |
What do you mean? |
whops, typo, i meant unwrapping, py.test now iterates until it no longer finds a wrapped attribute |
@nicoddemus ping? |
@vladipus can you confirm this is still an issue? |
closing due to lack of feedback, please reopen/notify |
I think this is still an issue. |
@sharad1087 And what exactly happens when you do? FWIW responses seems to have some code trying to keep compatibility with pytest and other things inspecting the signature of something. |
My requests was neither served by the (mock) response I added nor was actually attempting to reach the server. It simply said 'Connection Refused'. I'll try few more things and refer the attached code (thanks for pointing to it!) and share any updates I have. |
Originally reported by: Vladislav Turbanov (BitBucket: iptvd, GitHub: iptvd)
I'm getting the following error, while using the Simionato's useful 'decorator' module https://pypi.python.org/pypi/decorator , which helps decorators preseve the original wrapped function signature.
The solution to the problem is here: http://micheles.googlecode.com/hg/decorator/documentation.html#getting-the-source-code
The decorator's functions have a special member
__wrapped__
, which can be used to get the source code. So the following change in thepytest/python.py:1489
file can eliminate the error.I've also noticed, that you are already using this techinque in the same
python.py
file. Maybe, it is the way to get the source lines. Your technique is:The text was updated successfully, but these errors were encountered: