openwisp / openwisp-utils

Python and Django utilities shared between different openwisp modules
https://openwisp.io/docs/dev/utils/
BSD 3-Clause "New" or "Revised" License
74 stars 72 forks source link

[bug] Timelogging test runner breaks down if docstring is used in a slow test #124

Closed nepython closed 4 years ago

nepython commented 4 years ago

I was testing some changes in a test in openwisp_monitoring and thought of using a docstring to better explain a test. That's when I noticed TimeLoggingTestRunner doesn't work with docstrings, due to one particular line. Below is the traceback, it can be easily reproduced by introducing a docstring in any slow test.

Traceback (most recent call last):
  File "tests/test_project/tests/test_test_utils.py", line 51, in test_time_logging_runner
    runner.run_suite(suite)
  File "/home/hardik/.local/lib/python3.6/site-packages/django/test/runner.py", line 630, in run_suite
    return runner.run(suite)
  File "/usr/lib/python3.6/unittest/runner.py", line 180, in run
    stopTestRun()
  File "/home/hardik/openwisp/openwisp-utils/openwisp_utils/tests.py", line 66, in stopTestRun
    self.display_slow_tests()
  File "/home/hardik/openwisp/openwisp-utils/openwisp_utils/tests.py", line 51, in display_slow_tests
    name, module = name.split()
ValueError: too many values to unpack (expected 2)

Though I haven't seen much usage of docstring in tests in openwisp, still there shouldn't be a limitation, in my opinion. I will try to fix this and submit a patch.

nemesifier commented 4 years ago

@nepython on some occasions we do use docstrings