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

Updated pytest-timeout changes internal functions #1620

Open
juliangilbey opened this issue Jul 5, 2024 · 0 comments
Open

Updated pytest-timeout changes internal functions #1620

juliangilbey opened this issue Jul 5, 2024 · 0 comments

Comments

@juliangilbey
Copy link

pytest-timeout version 2.3.0 has changed two internal functions that debugpy uses in its tests:

  • write_title() has been removed (used in tests/logs.py)
  • dump_stacks() now takes an argument (terminal)

I have addressed the first one in Debian in a hackish way:

--- a/tests/logs.py                                                             
+++ b/tests/logs.py                                                             
@@ -4,7 +4,7 @@                                                                 
                                                                                
 import io                                                                      
 import os                                                                      
-import pytest_timeout                                                          
+from _pytest._io import TerminalWriter                                         
 import sys                                                                     
                                                                                
 from debugpy.common import json, log                                           
@@ -27,5 +27,6 @@                                                               
                 pass                                                           
             else:                                                              
                 path = os.path.relpath(path, log.log_dir)                      
-                pytest_timeout.write_title(path)                               
+                out = TerminalWriter()                                         
+                out.sep("+", title=path)                                       
                 print(s, file=sys.stderr)                                      

but see pytest-dev/pytest#10436 for a warning about this approach. For the second, I've done this:

--- a/tests/pytest_hooks.py                                                     
+++ b/tests/pytest_hooks.py                                                     
@@ -61,4 +61,4 @@                                                               
 # we want to print the pydevd log as well. This is not a normal pytest hook - \
we                                                                              
 # just detour pytest_timeout.dump_stacks directly.                             
 _dump_stacks = pytest_timeout.dump_stacks                                      
-pytest_timeout.dump_stacks = lambda: (_dump_stacks(), logs.dump())             
+pytest_timeout.dump_stacks = lambda term: (_dump_stacks(term), logs.dump())    
@judej judej assigned debonte and unassigned debonte Oct 14, 2024
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

2 participants