test_compat.py 476 B

12345678910111213141516171819
  1. from os.path import join
  2. from numpy.compat import isfileobj
  3. from numpy.testing import assert_
  4. from numpy.testing import tempdir
  5. def test_isfileobj():
  6. with tempdir(prefix="numpy_test_compat_") as folder:
  7. filename = join(folder, 'a.bin')
  8. with open(filename, 'wb') as f:
  9. assert_(isfileobj(f))
  10. with open(filename, 'ab') as f:
  11. assert_(isfileobj(f))
  12. with open(filename, 'rb') as f:
  13. assert_(isfileobj(f))