Changeset 5ea6c14 in mod_gnutls


Ignore:
Timestamp:
Jan 5, 2020, 7:10:53 AM (3 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master
Children:
a274959
Parents:
459a982
Message:

Clarify exception message for unexpected headers

Using the representation means the text will include quotes if the
value is a string, but not around None. Also add doctests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/tests.py

    r459a982 r5ea6c14  
    242242
    243243    def check_headers(self, headers):
     244        """
     245        >>> r1 = TestRequest(path='/test.txt',
     246        ...                  expect={ 'headers': {'X-Forbidden-Header': None,
     247        ...                                       'X-Required-Header': 'Hi!' }})
     248        >>> r1.check_headers({ 'X-Required-Header': 'Hi!' })
     249        >>> r1.check_headers({ 'X-Required-Header': 'Hello!' })
     250        Traceback (most recent call last):
     251        ...
     252        mgstest.TestExpectationFailed: Unexpected value in header X-Required-Header: 'Hello!', expected 'Hi!'
     253        >>> r1.check_headers({ 'X-Forbidden-Header': 'Hi!' })
     254        Traceback (most recent call last):
     255        ...
     256        mgstest.TestExpectationFailed: Unexpected value in header X-Forbidden-Header: 'Hi!', expected None
     257        """
    244258        for name, expected in self.expect['headers'].items():
    245259            value = headers.get(name)
     
    247261            if value != expected:
    248262                raise TestExpectationFailed(
    249                     f'Unexpected value in header {name}: "{value}", '
    250                     f'expected "{expected}"')
     263                    f'Unexpected value in header {name}: {value!r}, '
     264                    f'expected {expected!r}')
    251265
    252266    def check_body(self, body):
Note: See TracChangeset for help on using the changeset viewer.