-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[master] AttributeError in filter_traceback
: 'str' object has no attribute 'relto'
#995
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
With pytest 2.7.2 (instead of master), I see this error during setup of tests,
|
filter_traceback
: 'str' object has no attribute 'relto'filter_traceback
: 'str' object has no attribute 'relto'
Hi @blueyed, Could you try the patch at https://bitbucket.org/pytest-dev/py/pull-requests/31? Seems related. |
I'm having the exact same error and the patch did not work. Python 3.5.0 running in virtualenv, on Mac OS X 10.11 Beta 6
|
@blueyed @ColtonProvias Do you have a minimal example or a public project where this happens? |
Perhaps it would be best for pytest to be on the safe side in this situation and guarantee that entry.path is always a entry_path = py.path.local(entry.path)
return entry_path != cutdir1 and not entry_path.relto(cutdir2) Either way, it would be nice to get a minimal example, or at least a public project where the error is easily reproducible. 😅 |
I'm starting to see this now as well, I'll try to get some more debug info: entry = " File '<string>':2 in installed_client\n ???\n" Where installed_client is a fixture in which the exception was raised. And here is some of the stack:
|
I believe the issue is using the decorator package (https://pypi.python.org/pypi/decorator). I am using it to preserve certain fixtures signatures while attaching an additional decorator to it. From the documentation of decorator: Calling f() will give you a ZeroDivisionError, but since the function is decorated the traceback will be longer:
>>> f()
Traceback (most recent call last):
...
File "<string>", line 2, in f
File "<doctest __main__[22]>", line 4, in trace
return f(*args, **kw)
File "<doctest __main__[51]>", line 3, in f
1/0
ZeroDivisionError: ...
|
In my case, running on python 3.4, the After upgrading my mock to ver 1.3 I was also able to use |
Recently we had a session level fixture that started failing. The error message in 2.7.3 was correct and helpful (with the complete description "ERROR as setup of ...."), but in 2.8.0 we just had a stack trace ending with
Simply correcting the external condition that was causing the fixture to fail (which is actually to create some particular directory) fixes the problem. That fixture uses a decorator: @pytest.fixture(scope='session')
def sc():
spark_home = os.environ['SPARK_HOME']
sys.path.insert(0, os.path.join(spark_home, 'python'))
sys.path.insert(0, os.path.join(spark_home, 'python/lib/py4j-0.8.2.1-src.zip'))
import pyspark
return pyspark.SparkContext('local', 'tests') |
I got the same as @deuxpi, an error from code being called inside a fixture is hidden by this "AttributeError: 'str' object has no attribute 'relto'" error. Sorry nothing reproducible, but FWIW my structure is:
The triggering error in my app (discovered when examining outside of pytest) is: |
Here is a simple gist that will trigger the error: https://gist.github.com/astraw38/e485eb89cf6cf61c7be9 The 'traceback.cut()' method does not filter out the _pytest internal code if you have an anonymous function in a different file. |
…rated by an exec() statement Fix pytest-dev#995
Thanks @astraw38, that helped me narrow down a simple test case and fix the issue. 😄 |
Fix internal error when filtering tracebacks where one entry was generated by an exec() statement Fixes #995
We're still seeing this error message running against pytest 2.8.2, so it may not be fixed. |
Here is the traceback we see:
Interestingly, I'm unable to replicate the issue on my local workstation which is OS X and Python 2.7.10. I'll continue to troubleshoot until I can narrow down a cause. In the meantime, can you suggest a way to inspect the failure where it does exist? |
Can you use |
@nicoddemus Thanks for the hint. Yes. It works in the latest master. Thanks. |
Will there be a release with this fix anytime soon? I keep running into this. |
This should have been out in 2.8.3... which version are you using? |
Sorry, was running an old version by accident! |
Np! 😄 |
I am seeing the following error suddenly:
Normally
entry.path
is of type<class 'py._path.local.LocalPath'>
, but in this case it is not.Full traceback:
The text was updated successfully, but these errors were encountered: