def test_fake_close(self): fp = mhtml._NoCloseBytesIO() fp.write(b'Value') fp.close() assert fp.getvalue() == b'Value' fp.write(b'Eulav') assert fp.getvalue() == b'ValueEulav'
def test_actual_close(self): fp = mhtml._NoCloseBytesIO() fp.write(b'Value') fp.actual_close() with pytest.raises(ValueError) as excinfo: fp.getvalue() assert str(excinfo.value) == 'I/O operation on closed file.' with pytest.raises(ValueError) as excinfo: fp.write(b'Closed') assert str(excinfo.value) == 'I/O operation on closed file.'