示例#1
0
 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'
示例#2
0
 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'
示例#3
0
 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.'
示例#4
0
 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.'