Fix internal assert failure regression in 5.3.4#6518
Fix internal assert failure regression in 5.3.4#6518bluetech merged 1 commit intopytest-dev:masterfrom
Conversation
|
Awesome @bluetech, thanks for the lightning fast response! And ouch, indeed I managed to reproduce the issue with this: from nose.tools import raises
@raises(RuntimeError)
def test_fail_without_tcp():
raise RuntimeErrorI don't think we need to release this in a hurry, few test suites will be affected (only those mixing nose and pytest). Perhaps we should keep your original patch and just fix the assertion? The test above passes for me when I apply this: diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py
index fc951d2bc..64363662a 100644
--- a/src/_pytest/nodes.py
+++ b/src/_pytest/nodes.py
@@ -462,7 +462,7 @@ class Item(Node):
@cached_property
def location(self) -> Tuple[str, Optional[int], str]:
location = self.reportinfo()
- assert isinstance(location[0], py.path.local), location[0]
+ assert isinstance(location[0], (py.path.local, str)), location[0]
fspath = self.session._node_location_to_relpath(location[0])
assert type(location[2]) is str
return (fspath, location[1], location[2])(It is a shame we don't have a test for that nose feature in the first place actually) |
|
I prefer to revert the entire commit, because all of the changes related to this cache and the type of I'll add the regression test to this PR, thanks! |
This reverts commit 930a158. Regression test from Bruno Oliveira.
4301bfe to
fb99b5c
Compare
|
I added the regression test. Verified that it crashes before/passes after. Will merge once CI passes. |
|
Awesome, thanks again. 👍 |
This reverts commit 930a158 (pr #6511).
Fixes #6517.
The assert is failing on a real test suite. Basically, I was sure the assert was safe because the
_node_location_to_relpathcache that the value is passed into is only designed to work withpy.path.locals, notstrs, and code-wise if given anstr, it would fail. Or so I thought. Turns out several less-than-nice things combined to mislead me:py.path.localfunctionbestrelpathis wrapped in a gianttry...except AttributeErrorwhich masks any wrong types.py.path.localhas an__eq__implementation that can compare true with anstr:py.path.local('/foo') == '/foo'is true.py.path.local, so thebestrelpathcode actually does run withpy.path.locals. When anstrcomes in which compares true with a previouspy.path.local, it seems like everything's fine.Anyway, can look into these things later 😨 , but for now, better to just revert the offending commit to fix people's tests.