Esempio 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'
Esempio 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'
Esempio 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.'
Esempio 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.'