Skip to content
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

Compatibility with Python 3.11 #25

Closed
frenzymadness opened this issue Mar 29, 2022 · 6 comments
Closed

Compatibility with Python 3.11 #25

frenzymadness opened this issue Mar 29, 2022 · 6 comments

Comments

@frenzymadness
Copy link
Contributor

Hello.

It seems that stack_data is not compatible with Python 3.11 (alpha 6 currently). We are preparing RPM packages in Fedora with Python 3.11 and this one fails to build.

FAILED tests/test_core.py::test_variables - AssertionError: assert None == <ast.Call object at 0x7feb2ba61f30>
FAILED tests/test_core.py::test_example - assert 'bar at line ... \nx = 1 \n\n' == 'bar at line ... \nx = 1 \n\n'
FAILED tests/test_core.py::test_pygments_example - AssertionError: assert 'Terminal256F...=========\n\n' == 'Terminal256F...=========\n\n'
FAILED tests/test_formatter.py::test_example - AssertionError
Complete results

GLOB sdist-make: /home/lbalhar/Software/stack_data/setup.py
py311 create: /home/lbalhar/Software/stack_data/.tox/py311
py311 inst: /home/lbalhar/Software/stack_data/.tox/.tmp/package/1/stack_data-0.2.1.dev1+g2720c4d.d20220329.zip
py311 installed: asttokens==2.0.5,attrs==21.4.0,Cython==0.29.28,executing==0.8.3,iniconfig==1.1.1,littleutils==0.2.2,packaging==21.3,pluggy==1.0.0,pure-eval==0.2.2,py==1.11.0,Pygments==2.11.2,pyparsing==3.0.7,pytest==7.1.1,six==1.16.0,stack-data @ file:///home/lbalhar/Software/stack_data/.tox/.tmp/package/1/stack_data-0.2.1.dev1%2Bg2720c4d.d20220329.zip,tomli==2.0.1,typeguard==2.13.3
py311 run-test-pre: PYTHONHASHSEED='3398780068'
py311 run-test: commands[0] | pytest
==================================================================================== test session starts =====================================================================================
platform linux -- Python 3.11.0a6, pytest-7.1.1, pluggy-1.0.0
cachedir: .tox/py311/.pytest_cache
rootdir: /home/lbalhar/Software/stack_data
plugins: typeguard-2.13.3
collected 16 items                                                                                                                                                                           

tests/test_core.py ...F......FF                                                                                                                                                        [ 75%]
tests/test_formatter.py F                                                                                                                                                              [ 81%]
tests/test_utils.py ...                                                                                                                                                                [100%]

========================================================================================== FAILURES ==========================================================================================
_______________________________________________________________________________________ test_variables _______________________________________________________________________________________

    def test_variables():
        options = Options(before=1, after=0)
        assert repr(options) == 'Options(after=0, before=1, include_signature=False, ' \
                                'max_lines_per_piece=6, pygments_formatter=None)'
    
        def foo(arg, _arg2: str = None, *_args, **_kwargs):
            y = 123986
            str(y)
            x = {982347298304}
            str(x)
            return (
                FrameInfo(inspect.currentframe(), options),
                arg,
                arg,
            )[0]
    
        frame_info = foo('this is arg')
    
        assert sum(line.is_current for line in frame_info.lines) == 1
    
        body = frame_info.scope.body
    
        tup = body[-1].value.value.elts
        call = tup[0]
>       assert frame_info.executing.node == call
E       AssertionError: assert None == <ast.Call object at 0x7feb2ba61f30>
E        +  where None = <executing.executing.Executing object at 0x7feb2c2eb9d0>.node
E        +    where <executing.executing.Executing object at 0x7feb2c2eb9d0> = FrameInfo(<frame at 0x7feb2b992c00, file '/home/lbalhar/Software/stack_data/tests/test_core.py', line 216, code foo>).executing

tests/test_core.py:230: AssertionError
________________________________________________________________________________________ test_example ________________________________________________________________________________________

    def test_example():
        from .samples.example import bar
        result = bar()
        print(result)
>       assert result == """\
    bar at line 27
    --------------
      25 | def bar():
      26 |     <var>names</var> = {}
      27 >     <exec>exec("result = foo()", globals(), <var>names</var>)</exec>
      28 |     return <var>names</var>["result"]
    names = {}
    
    <module> at line 1
    ------------------
    
    foo at line 20
    --------------
       6 | def foo():
    (...)
       8 |     <var>lst</var> = [1]
      10 |     <var>lst</var>.insert(0, <var>x</var>)
      11 |     <var>lst</var>.append(
      12 |         <var>[</var>
      13 | <var>            1,</var>
    (...)
      18 | <var>            6</var>
      19 | <var>        ][0]</var>)
      20 >     result = <exec>print_stack(</exec>
      21 |              <exec>)</exec>
      22 |     return result
    [
                1,
                2,
                3,
                4,
                5,
                6
            ][0] = 1
    lst = [1, 1, 1]
    x = 1
    
    """
E       assert 'bar at line ... \nx = 1 \n\n' == 'bar at line ... \nx = 1 \n\n'
E         Skipping 82 identical leading characters in diff, use -v to show
E         -  27 >     <exec>exec("result = foo()", globals(), <var>names</var>)</exec>
E         ?           ------                                                   -------
E         +  27 >     exec("result = foo()", globals(), <var>names</var>)
E             28 |     return <var>names</var>["result"]
E           names = {} 
E           ...
E         
E         ...Full output truncated (34 lines hidden), use '-vv' to show

tests/test_core.py:575: AssertionError
------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------
bar at line 27
--------------
  25 | def bar():
  26 |     <var>names</var> = {}
  27 >     exec("result = foo()", globals(), <var>names</var>)
  28 |     return <var>names</var>["result"]
names = {} 

<module> at line 1
------------------

foo at line 20
--------------
   6 | def foo():
(...)
   8 |     <var>lst</var> = [1]
  10 |     <var>lst</var>.insert(0, <var>x</var>)
  11 |     <var>lst</var>.append(
  12 |         <var>[</var>
  13 | <var>            1,</var>
(...)
  18 | <var>            6</var>
  19 | <var>        ][0]</var>)
  20 >     result = print_stack(
  21 |              )
  22 |     return result
[
            1,
            2,
            3,
            4,
            5,
            6
        ][0] = 1 
lst = [1, 1, 1] 
x = 1 


___________________________________________________________________________________ test_pygments_example ____________________________________________________________________________________

    def test_pygments_example():
        from .samples.pygments_example import bar
        result = bar()
        print(result)
>       assert result == """\
    Terminal256Formatter native:
    
      13 | \x1b[38;5;70;01mdef\x1b[39;00m\x1b[38;5;252m \x1b[39m\x1b[38;5;68mbar\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252m)\x1b[39m\x1b[38;5;252m:\x1b[39m
      14 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;252mx\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;252m=\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;67m1\x1b[39m
      15 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;31mstr\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252mx\x1b[39m\x1b[38;5;252m)\x1b[39m
      17 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;214m@deco\x1b[39m
      18 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;70;01mdef\x1b[39;00m\x1b[38;5;252m \x1b[39m\x1b[38;5;68mfoo\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252m)\x1b[39m\x1b[38;5;252m:\x1b[39m
      19 | \x1b[38;5;252m        \x1b[39m\x1b[38;5;70;01mpass\x1b[39;00m
    -----
      25 | \x1b[38;5;70;01mdef\x1b[39;00m\x1b[38;5;252m \x1b[39m\x1b[38;5;68mdeco\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252mf\x1b[39m\x1b[38;5;252m)\x1b[39m\x1b[38;5;252m:\x1b[39m
      26 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;252mf\x1b[39m\x1b[38;5;252m.\x1b[39m\x1b[38;5;252mresult\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;252m=\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;252mprint_stack\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252m)\x1b[39m
      27 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;70;01mreturn\x1b[39;00m\x1b[38;5;252m \x1b[39m\x1b[38;5;252mf\x1b[39m
    -----
    
    ====================
    
    Terminal256Formatter <class \'stack_data.core.style_with_executing_node.<locals>.NewStyle\'>:
    
      13 | \x1b[38;5;70;01mdef\x1b[39;00m\x1b[38;5;252m \x1b[39m\x1b[38;5;68mbar\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252m)\x1b[39m\x1b[38;5;252m:\x1b[39m
      14 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;252mx\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;252m=\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;67m1\x1b[39m
      15 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;31mstr\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252mx\x1b[39m\x1b[38;5;252m)\x1b[39m
      17 | \x1b[38;5;252;48;5;58m    \x1b[39;49m\x1b[38;5;214;48;5;58m@deco\x1b[39;49m
      18 | \x1b[38;5;252;48;5;58m    \x1b[39;49m\x1b[38;5;70;48;5;58;01mdef\x1b[39;49;00m\x1b[38;5;252;48;5;58m \x1b[39;49m\x1b[38;5;68;48;5;58mfoo\x1b[39;49m\x1b[38;5;252;48;5;58m(\x1b[39;49m\x1b[38;5;252;48;5;58m)\x1b[39;49m\x1b[38;5;252;48;5;58m:\x1b[39;49m
      19 | \x1b[38;5;252;48;5;58m        \x1b[39;49m\x1b[38;5;70;48;5;58;01mpass\x1b[39;49;00m
    -----
      25 | \x1b[38;5;70;01mdef\x1b[39;00m\x1b[38;5;252m \x1b[39m\x1b[38;5;68mdeco\x1b[39m\x1b[38;5;252m(\x1b[39m\x1b[38;5;252mf\x1b[39m\x1b[38;5;252m)\x1b[39m\x1b[38;5;252m:\x1b[39m
      26 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;252mf\x1b[39m\x1b[38;5;252m.\x1b[39m\x1b[38;5;252mresult\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;252m=\x1b[39m\x1b[38;5;252m \x1b[39m\x1b[38;5;252;48;5;58mprint_stack\x1b[39;49m\x1b[38;5;252;48;5;58m(\x1b[39;49m\x1b[38;5;252;48;5;58m)\x1b[39;49m
      27 | \x1b[38;5;252m    \x1b[39m\x1b[38;5;70;01mreturn\x1b[39;00m\x1b[38;5;252m \x1b[39m\x1b[38;5;252mf\x1b[39m
    -----
    
    ====================
    
    TerminalFormatter native:
    
      13 | \x1b[34mdef\x1b[39;49;00m \x1b[32mbar\x1b[39;49;00m():
      14 |     x = \x1b[34m1\x1b[39;49;00m
      15 |     \x1b[36mstr\x1b[39;49;00m(x)
      17 |     \x1b[90m@deco\x1b[39;49;00m
      18 |     \x1b[34mdef\x1b[39;49;00m \x1b[32mfoo\x1b[39;49;00m():
      19 |         \x1b[34mpass\x1b[39;49;00m
    -----
      25 | \x1b[34mdef\x1b[39;49;00m \x1b[32mdeco\x1b[39;49;00m(f):
      26 |     f.result = print_stack()
      27 |     \x1b[34mreturn\x1b[39;49;00m f
    -----
    
    ====================
    
    TerminalFormatter <class \'stack_data.core.style_with_executing_node.<locals>.NewStyle\'>:
    
      13 | \x1b[34mdef\x1b[39;49;00m \x1b[32mbar\x1b[39;49;00m():
      14 |     x = \x1b[34m1\x1b[39;49;00m
      15 |     \x1b[36mstr\x1b[39;49;00m(x)
      17 |     \x1b[90m@deco\x1b[39;49;00m
      18 |     \x1b[34mdef\x1b[39;49;00m \x1b[32mfoo\x1b[39;49;00m():
      19 |         \x1b[34mpass\x1b[39;49;00m
    -----
      25 | \x1b[34mdef\x1b[39;49;00m \x1b[32mdeco\x1b[39;49;00m(f):
      26 |     f.result = print_stack()
      27 |     \x1b[34mreturn\x1b[39;49;00m f
    -----
    
    ====================
    
    TerminalTrueColorFormatter native:
    
      13 | \x1b[38;2;106;184;37;01mdef\x1b[39;00m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;68;127;207mbar\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m\x1b[38;2;208;208;208m:\x1b[39m
      14 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;208;208;208mx\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208m=\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;54;119;169m1\x1b[39m
      15 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;36;144;157mstr\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208mx\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m
      17 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;255;165;0m@deco\x1b[39m
      18 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;106;184;37;01mdef\x1b[39;00m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;68;127;207mfoo\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m\x1b[38;2;208;208;208m:\x1b[39m
      19 | \x1b[38;2;208;208;208m        \x1b[39m\x1b[38;2;106;184;37;01mpass\x1b[39;00m
    -----
      25 | \x1b[38;2;106;184;37;01mdef\x1b[39;00m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;68;127;207mdeco\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208mf\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m\x1b[38;2;208;208;208m:\x1b[39m
      26 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;208;208;208mf\x1b[39m\x1b[38;2;208;208;208m.\x1b[39m\x1b[38;2;208;208;208mresult\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208m=\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208mprint_stack\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m
      27 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;106;184;37;01mreturn\x1b[39;00m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208mf\x1b[39m
    -----
    
    ====================
    
    TerminalTrueColorFormatter <class \'stack_data.core.style_with_executing_node.<locals>.NewStyle\'>:
    
      13 | \x1b[38;2;106;184;37;01mdef\x1b[39;00m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;68;127;207mbar\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m\x1b[38;2;208;208;208m:\x1b[39m
      14 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;208;208;208mx\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208m=\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;54;119;169m1\x1b[39m
      15 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;36;144;157mstr\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208mx\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m
      17 | \x1b[38;2;208;208;208;48;2;68;68;0m    \x1b[39;49m\x1b[38;2;255;165;0;48;2;68;68;0m@deco\x1b[39;49m
      18 | \x1b[38;2;208;208;208;48;2;68;68;0m    \x1b[39;49m\x1b[38;2;106;184;37;48;2;68;68;0;01mdef\x1b[39;49;00m\x1b[38;2;208;208;208;48;2;68;68;0m \x1b[39;49m\x1b[38;2;68;127;207;48;2;68;68;0mfoo\x1b[39;49m\x1b[38;2;208;208;208;48;2;68;68;0m(\x1b[39;49m\x1b[38;2;208;208;208;48;2;68;68;0m)\x1b[39;49m\x1b[38;2;208;208;208;48;2;68;68;0m:\x1b[39;49m
      19 | \x1b[38;2;208;208;208;48;2;68;68;0m        \x1b[39;49m\x1b[38;2;106;184;37;48;2;68;68;0;01mpass\x1b[39;49;00m
    -----
      25 | \x1b[38;2;106;184;37;01mdef\x1b[39;00m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;68;127;207mdeco\x1b[39m\x1b[38;2;208;208;208m(\x1b[39m\x1b[38;2;208;208;208mf\x1b[39m\x1b[38;2;208;208;208m)\x1b[39m\x1b[38;2;208;208;208m:\x1b[39m
      26 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;208;208;208mf\x1b[39m\x1b[38;2;208;208;208m.\x1b[39m\x1b[38;2;208;208;208mresult\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208m=\x1b[39m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208;48;2;68;68;0mprint_stack\x1b[39;49m\x1b[38;2;208;208;208;48;2;68;68;0m(\x1b[39;49m\x1b[38;2;208;208;208;48;2;68;68;0m)\x1b[39;49m
      27 | \x1b[38;2;208;208;208m    \x1b[39m\x1b[38;2;106;184;37;01mreturn\x1b[39;00m\x1b[38;2;208;208;208m \x1b[39m\x1b[38;2;208;208;208mf\x1b[39m
    -----
    
    ====================
    
    HtmlFormatter native:
    
      13 | <span class="k">def</span> <span class="nf">bar</span><span class="p">():</span>
      14 |     <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span>
      15 |     <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
      17 |     <span class="nd">@deco</span>
      18 |     <span class="k">def</span> <span class="nf">foo</span><span class="p">():</span>
      19 |         <span class="k">pass</span>
    -----
      25 | <span class="k">def</span> <span class="nf">deco</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
      26 |     <span class="n">f</span><span class="o">.</span><span class="n">result</span> <span class="o">=</span> <span class="n">print_stack</span><span class="p">()</span>
      27 |     <span class="k">return</span> <span class="n">f</span>
    -----
    
    ====================
    
    HtmlFormatter <class \'stack_data.core.style_with_executing_node.<locals>.NewStyle\'>:
    
      13 | <span class="k">def</span> <span class="nf">bar</span><span class="p">():</span>
      14 |     <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span>
      15 |     <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
      17 | <span class=" -ExecutingNode">    </span><span class="nd nd-ExecutingNode">@deco</span><span class=" -ExecutingNode"></span>
      18 | <span class=" -ExecutingNode">    </span><span class="k k-ExecutingNode">def</span><span class=" -ExecutingNode"> </span><span class="nf nf-ExecutingNode">foo</span><span class="p p-ExecutingNode">():</span><span class=" -ExecutingNode"></span>
      19 | <span class=" -ExecutingNode">        </span><span class="k k-ExecutingNode">pass</span><span class=" -ExecutingNode"></span>
    -----
      25 | <span class="k">def</span> <span class="nf">deco</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
      26 |     <span class="n">f</span><span class="o">.</span><span class="n">result</span> <span class="o">=</span> <span class="n n-ExecutingNode">print_stack</span><span class="p p-ExecutingNode">()</span>
      27 |     <span class="k">return</span> <span class="n">f</span>
    -----
    
    ====================
    
    """
E       AssertionError: assert 'Terminal256F...=========\n\n' == 'Terminal256F...=========\n\n'
E         Skipping 1484 identical leading characters in diff, use -v to show
E         -     @deco
E         ?           --------        ---            --------          ---
E         +     @deco
E         -   18 |     def foo():
E         ?                  --------        ---            --------         ---               --------     ---           --------  ...
E         
E         ...Full output truncated (126 lines hidden), use '-vv' to show

tests/test_core.py:620: AssertionError
------------------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------------------
Terminal256Formatter native:

  13 | def bar():
  14 |     x = 1
  15 |     str(x)
  17 |     @deco
  18 |     def foo():
  19 |         pass
-----
  25 | def deco(f):
  26 |     f.result = print_stack()
  27 |     return f
-----

====================

Terminal256Formatter <class 'stack_data.core.style_with_executing_node.<locals>.NewStyle'>:

  13 | def bar():
  14 |     x = 1
  15 |     str(x)
  17 |     @deco
  18 |     def foo():
  19 |         pass
-----
  25 | def deco(f):
  26 |     f.result = print_stack()
  27 |     return f
-----

====================

TerminalFormatter native:

  13 | def bar():
  14 |     x = 1
  15 |     str(x)
  17 |     @deco
  18 |     def foo():
  19 |         pass
-----
  25 | def deco(f):
  26 |     f.result = print_stack()
  27 |     return f
-----

====================

TerminalFormatter <class 'stack_data.core.style_with_executing_node.<locals>.NewStyle'>:

  13 | def bar():
  14 |     x = 1
  15 |     str(x)
  17 |     @deco
  18 |     def foo():
  19 |         pass
-----
  25 | def deco(f):
  26 |     f.result = print_stack()
  27 |     return f
-----

====================

TerminalTrueColorFormatter native:

  13 | def bar():
  14 |     x = 1
  15 |     str(x)
  17 |     @deco
  18 |     def foo():
  19 |         pass
-----
  25 | def deco(f):
  26 |     f.result = print_stack()
  27 |     return f
-----

====================

TerminalTrueColorFormatter <class 'stack_data.core.style_with_executing_node.<locals>.NewStyle'>:

  13 | def bar():
  14 |     x = 1
  15 |     str(x)
  17 |     @deco
  18 |     def foo():
  19 |         pass
-----
  25 | def deco(f):
  26 |     f.result = print_stack()
  27 |     return f
-----

====================

HtmlFormatter native:

  13 | <span class="k">def</span> <span class="nf">bar</span><span class="p">():</span>
  14 |     <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span>
  15 |     <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
  17 |     <span class="nd">@deco</span>
  18 |     <span class="k">def</span> <span class="nf">foo</span><span class="p">():</span>
  19 |         <span class="k">pass</span>
-----
  25 | <span class="k">def</span> <span class="nf">deco</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
  26 |     <span class="n">f</span><span class="o">.</span><span class="n">result</span> <span class="o">=</span> <span class="n">print_stack</span><span class="p">()</span>
  27 |     <span class="k">return</span> <span class="n">f</span>
-----

====================

HtmlFormatter <class 'stack_data.core.style_with_executing_node.<locals>.NewStyle'>:

  13 | <span class="k">def</span> <span class="nf">bar</span><span class="p">():</span>
  14 |     <span class="n">x</span> <span class="o">=</span> <span class="mi">1</span>
  15 |     <span class="nb">str</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
  17 |     <span class="nd">@deco</span>
  18 |     <span class="k">def</span> <span class="nf">foo</span><span class="p">():</span>
  19 |         <span class="k">pass</span>
-----
  25 | <span class="k">def</span> <span class="nf">deco</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
  26 |     <span class="n">f</span><span class="o">.</span><span class="n">result</span> <span class="o">=</span> <span class="n">print_stack</span><span class="p">()</span>
  27 |     <span class="k">return</span> <span class="n">f</span>
-----

====================


________________________________________________________________________________________ test_example ________________________________________________________________________________________

capsys = <_pytest.capture.CaptureFixture object at 0x7feb29ed7710>

    def test_example(capsys):
        from .samples.formatter_example import bar, print_stack1, format_stack1, format_frame, f_string
    
        @contextmanager
        def check_example(name):
            yield
            stderr = capsys.readouterr().err
            compare_to_file(stderr, name)
    
>       with check_example("variables"):

tests/test_formatter.py:38: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.11/contextlib.py:144: in __exit__
    next(self.gen)
tests/test_formatter.py:36: in check_example
    compare_to_file(stderr, name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

text = 'Traceback (most recent call last):\n File "formatter_example.py", line 21, in foo\n       9 | x = 1\n      10 | lst =...     + []\n            + [] = [1]\nlst = [1]\nn = 0\nn - 1 = -1\nn > 0 = False\nstr(lst) = \'[1]\'\nx = 1\nTypeError\n'
name = 'variables'

    def compare_to_file(text, name):
        filename = os.path.join(
            os.path.dirname(__file__),
            'golden_files',
            name + '.txt',
        )
        if os.environ.get('FIX_STACK_DATA_TESTS'):
            string_to_file(text, filename)
        else:
            expected_output = file_to_string(filename)
>           assert text == expected_output
E           AssertionError

tests/utils.py:16: AssertionError
====================================================================================== warnings summary ======================================================================================
.tox/py311/lib/python3.11/site-packages/pyximport/pyximport.py:51
  /home/lbalhar/Software/stack_data/.tox/py311/lib/python3.11/site-packages/pyximport/pyximport.py:51: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    import imp

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ===================================================================================
FAILED tests/test_core.py::test_variables - AssertionError: assert None == <ast.Call object at 0x7feb2ba61f30>
FAILED tests/test_core.py::test_example - assert 'bar at line ... \nx = 1 \n\n' == 'bar at line ... \nx = 1 \n\n'
FAILED tests/test_core.py::test_pygments_example - AssertionError: assert 'Terminal256F...=========\n\n' == 'Terminal256F...=========\n\n'
FAILED tests/test_formatter.py::test_example - AssertionError
========================================================================== 4 failed, 12 passed, 1 warning in 2.59s ===========================================================================
ERROR: InvocationError for command /home/lbalhar/Software/stack_data/.tox/py311/bin/pytest (exited with code 1)
__________________________________________________________________________________________ summary ___________________________________________________________________________________________
ERROR:   py311: commands failed
@frenzymadness
Copy link
Contributor Author

The core problem of the two first tests is very likely related to: alexmojaki/executing#30 It seems that the patch from alexmojaki/executing#31 is not complete enough to make stack_data work with Python 3.11.

@alexmojaki
Copy link
Owner

Released support in stack_data 0.5.1 (along with executing 1.1.0 ofc)

@alexmojaki
Copy link
Owner

cc @aroberge

@aroberge
Copy link
Contributor

@alexmojaki Many thanks.

I have just checked it (with the newest executing version) with the existing tests I have for Python 3.6 to 3.11; I am still skipping many 3.11 tests as I have not touched the tests files. However, I did notice that the tests take about 2 to 3 times as long to run now for Python 3.6 to 3.10. They used to run in about 8 +/- 1 seconds. Now they take about 20 seconds. Of 400 or so tests, the longest one, that has many asserts by itself now takes more than 3 seconds.

Caveat: I have been refactoring some parts of the code this morning and perhaps this is the source of the slowdown - even though I cannot see why that would be as the changes I made should have been neutral in terms of execution time.

@alexmojaki
Copy link
Owner

@aroberge this should probably be a new issue. Anyway, it should be easy to check what happens if you run the tests with executing versions 1.0.0 and 1.1.0 without changing your own code.

@aroberge
Copy link
Contributor

aroberge commented Sep 25, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants