Exemplo n.º 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'
Exemplo n.º 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'
Exemplo n.º 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.'
Exemplo n.º 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.'