cdent / gabbi

Declarative HTTP Testing for Python and anything else
http://gabbi.readthedocs.org/
Other
148 stars 34 forks source link

If content-type is not set, but data is, the error message is incomplete #257

Closed cdent closed 3 years ago

cdent commented 6 years ago

If you try to write data without setting a content-type header, there's no content handler and the error message is not very useful:

      File "/mnt/share/cdentsrc/nova/.tox/functional/local/lib/python2.7/site-packages/gabbi/suitemaker.py", line 95, in do_test
        return test_method(*args, **kwargs)
      File "/mnt/share/cdentsrc/nova/.tox/functional/local/lib/python2.7/site-packages/gabbi/case.py", line 94, in wrapper
        func(self)
      File "/mnt/share/cdentsrc/nova/.tox/functional/local/lib/python2.7/site-packages/gabbi/case.py", line 148, in test_request
        self._run_test()
      File "/mnt/share/cdentsrc/nova/.tox/functional/local/lib/python2.7/site-packages/gabbi/case.py", line 524, in _run_test
        utils.extract_content_type(headers, default='')[0])
      File "/mnt/share/cdentsrc/nova/.tox/functional/local/lib/python2.7/site-packages/gabbi/case.py", line 587, in _test_data_to_string
        'unable to process data to %s' % content_type)
    ValueError: unable to process data to 

If content_type is None, we should provide a different message.