Skip to content

Hard to tell what went wrong when a text content object is broken #111

@thomir

Description

@thomir

I see lots of stack traces such as this one:

Traceback

Traceback (most recent call last):
  File "/usr/bin/autopilot3", line 9, in <module>
    load_entry_point('autopilot==1.5.0', 'console_scripts', 'autopilot3')()
  File "/usr/lib/python3/dist-packages/autopilot/run.py", line 729, in main
    test_app.run()
  File "/usr/lib/python3/dist-packages/autopilot/run.py", line 617, in run
    action()
  File "/usr/lib/python3/dist-packages/autopilot/run.py", line 681, in run_tests
    test_result = test_suite.run(result)
  File "/usr/lib/python3.4/unittest/suite.py", line 125, in run
    test(result)
  File "/usr/lib/python3.4/unittest/case.py", line 625, in __call__
    return self.run(*args, **kwds)
  File "/usr/lib/python3/dist-packages/testscenarios/testcase.py", line 62, in run
    test.run(result)
  File "/usr/lib/python3/dist-packages/testscenarios/testcase.py", line 65, in run
    return super(WithScenarios, self).run(result)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 585, in run
    return self.__RunTest(self, self.exception_handlers).run(result)
  File "/usr/lib/python3/dist-packages/testtools/runtest.py", line 74, in run
    return self._run_one(actual_result)
  File "/usr/lib/python3/dist-packages/testtools/runtest.py", line 88, in _run_one
    return self._run_prepared_result(ExtendedToOriginalDecorator(result))
  File "/usr/lib/python3/dist-packages/testtools/runtest.py", line 107, in _run_prepared_result
    handler(self.case, self.result, e)
  File "/usr/lib/python3/dist-packages/testtools/testcase.py", line 558, in _report_failure
    result.addFailure(self, details=self.getDetails())
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 1149, in addFailure
    return self.decorated.addFailure(test, err)
  File "/usr/lib/python3/dist-packages/autopilot/testresult.py", line 78, in addFailure
    return super(type(self), self).addFailure(test, err, details)
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 1546, in addFailure
    return self.decorated.addFailure(test, err, details=details)
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 1322, in addError
    self._convert(test, err, details, 'fail')
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 1350, in _convert
    test_tags=self.current_tags, timestamp=now)
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 408, in status
    super(CopyStreamResult, self).status(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 649, in status
    self.on_test(self._inprogress.pop(key))
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 742, in _gather_test
    self._handle_status[test_dict['status']](case)
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 761, in _fail
    message = _details_to_str(case._details, special="traceback")
  File "/usr/lib/python3/dist-packages/testtools/testresult/real.py", line 1752, in _details_to_str
    text = content.as_text().strip()
  File "/usr/lib/python3/dist-packages/testtools/content.py", line 94, in as_text
    return _u('').join(self.iter_text())
  File "/usr/lib/python3/dist-packages/testtools/content.py", line 118, in _iter_text
    yield decoder.decode(bytes)
  File "/usr/lib/python3.4/encodings/latin_1.py", line 26, in decode
    return codecs.latin_1_decode(input,self.errors)[0]
TypeError: 'NoneType' does not support the buffer interface

... where testtools attempts to convert a content object to a string, only to find that even though the content type of the content object is 'text', the content object returns something other than text.

This has been partially fixed in a separate PR that makes the text_content function more picky about what it accepts, but I think we should also catch the raised exception, and re-raise with the name of the content object being processed.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions