python-hyper / hpack

HTTP/2 Header Encoding for Python
https://hpack.readthedocs.io/en/latest/
MIT License
72 stars 32 forks source link

Pytest5 one of the tests fail #168

Closed scarabeusiv closed 4 years ago

scarabeusiv commented 5 years ago

The raises approach was changed with pyest5 and some tests need adjusting:

[   34s] =================================== FAILURES ===================================
[   34s] ________________ TestHeaderTable.test_get_by_index_out_of_range ________________
[   34s] 
[   34s] self = <test_table.TestHeaderTable object at 0x7fcc733bc0f0>
[   34s] 
[   34s]     def test_get_by_index_out_of_range(self):
[   34s]         tbl = HeaderTable()
[   34s]         off = len(HeaderTable.STATIC_TABLE)
[   34s]         tbl.add(b'TestName', b'TestValue')
[   34s]         with pytest.raises(InvalidTableIndex) as e:
[   34s]             tbl.get_by_index(off + 2)
[   34s]     
[   34s] >       assert (
[   34s]             "InvalidTableIndex: Invalid table index %d" % (off + 2) in str(e)
[   34s]         )
[   34s] E       AssertionError: assert ('InvalidTableIndex: Invalid table index %d' % (61 + 2)) in '<ExceptionInfo InvalidTableIndex tblen=2>'
[   34s] E        +  where '<ExceptionInfo InvalidTableIndex tblen=2>' = str(<ExceptionInfo InvalidTableIndex tblen=2>)
[   34s] 
[   34s] test/test_table.py:48: AssertionError
[   34s] ============== 1 failed, 82 passed, 4 deselected in 4.64 seconds ===============

maybe just changing str(e) to e.value.formatted would be good enough.

sethmlarson commented 5 years ago

Would you be willing to provide a patch to fix this issue? I'd happily review and merge it. :)

sethmlarson commented 4 years ago

Fixed this in master.