Fixes in tests, improve message regarding slow repr to note environment variable to customize it.

This commit is contained in:
Fabio Zadrozny 2022-09-30 15:01:38 -03:00
parent ac6f5ea6c9
commit fb40a0b002
3 changed files with 30 additions and 8 deletions

View file

@ -471,11 +471,17 @@ class Timer(object):
except:
pass
if attrs_tab_separated:
return 'pydevd warning: Computing repr of %s.%s (%s) was slow (took %.2fs)\n' % (
attrs_tab_separated.replace('\t', '.'), attr_name, attr_type, diff)
return (
'pydevd warning: Computing repr of %s.%s (%s) was slow (took %.2fs).\n'
'Customize report timeout by setting the `PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT` environment variable to a higher timeout (default is: %ss)\n'
) % (
attrs_tab_separated.replace('\t', '.'), attr_name, attr_type, diff, PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT)
else:
return 'pydevd warning: Computing repr of %s (%s) was slow (took %.2fs)\n' % (
attr_name, attr_type, diff)
return (
'pydevd warning: Computing repr of %s (%s) was slow (took %.2fs)\n'
'Customize report timeout by setting the `PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT` environment variable to a higher timeout (default is: %ss)\n'
) % (
attr_name, attr_type, diff, PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT)
def report_if_getting_attr_slow(self, cls, attr_name):
self._report_slow(self._compute_get_attr_slow, cls, attr_name)
@ -485,7 +491,10 @@ class Timer(object):
cls = cls.__name__
except:
pass
return 'pydevd warning: Getting attribute %s.%s was slow (took %.2fs)\n' % (cls, attr_name, diff)
return (
'pydevd warning: Getting attribute %s.%s was slow (took %.2fs)\n'
'Customize report timeout by setting the `PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT` environment variable to a higher timeout (default is: %ss)\n'
) % (cls, attr_name, diff, PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT)
def import_attr_from_module(import_with_attr_access):

View file

@ -952,11 +952,24 @@ def test_case_django_a(case_setup_django):
return env
with case_setup_django.test_file(EXPECTED_RETURNCODE='any', get_environ=get_environ) as writer:
writer.write_add_breakpoint_django(5, None, 'index.html')
writer.write_make_initial_run()
# Wait for the first request that works...
for i in range(4):
try:
t = writer.create_request_thread('my_app')
t.start()
contents = t.wait_for_contents()
contents = contents.replace(' ', '').replace('\r', '').replace('\n', '')
assert contents == '<ul><li>v1:v1</li><li>v2:v2</li></ul>'
break
except:
if i == 3:
raise
continue
writer.write_add_breakpoint_django(5, None, 'index.html')
t = writer.create_request_thread('my_app')
time.sleep(5) # Give django some time to get to startup before requesting the page
t.start()
hit = writer.wait_for_breakpoint_hit(REASON_STOP_ON_BREAKPOINT, line=5)

View file

@ -5425,7 +5425,7 @@ def test_debug_options(case_setup, val):
except ImportError:
pass
else:
gui_event_loop = 'qt5'
gui_event_loop = 'pyside2'
args = dict(
justMyCode=val,
redirectOutput=True, # Always redirect the output regardless of other values.