Repository navigation
Global variables are not explained on failure #171
Description
Activity
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):
I think in some cases it can result in too verbose output, especially when using builtins where you don't really want to have extra information on "len", "callable" etc. But even if this cannot be cut out, it's still useful to present globals. Not a big code change, is it?
Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub):
I started doing this this weekend but just made more tests fail, I now realise I was making it more complicated then needed (I think). In visit_Name I was trying to create a new test which checked the name was not in the builtin names (and failed). However it's probably fine and easier to just remove the test for globals/locals.
Anyway, I don't mind if you make this change. My knowledge of how to build code using AST is rather limited...
Original comment by Floris Bruynooghe (BitBucket: flub, GitHub: flub):
The attached patch has one test failure:
__________________________________ TestAssertionRewrite.test_attribute ___________________________________ self = <test_assertrewrite.TestAssertionRewrite instance at 0x1210440> def test_attribute(self): class X(object): g = 3 ns = {"X" : X, "x" : X()} def f(): assert not x.g > assert getmsg(f, ns) == """assert not 3 + where 3 = x.g""" E assert 'assert not 3... 0x12d4d90>.g' == 'assert not 3\...where 3 = x.g' E assert not 3 E - + where 3 = <test_assertrewrite.X object at 0x12d4d90>.g E + + where 3 = x.g testing/test_assertrewrite.py:245: AssertionErrorWhich is exactly the last issue you mention, I think it might be possible to add another test to the display logic which checks if the name is a class and is a global. Do you reckon this is the right approach to keep persuing? It'll probably need a special case for a module as well.
- addedtype: bugproblem that needs to be addressedproblem that needs to be addressed
on Jun 15, 2015 - added a commit that references this issue
on May 27, 2023
Originally reported by: Floris Bruynooghe (BitBucket: flub, GitHub: flub)
A global variable is not expanded in the explanation on failure:
Results in:
I would expect the "E" line to say "assert 7 == 42".