test_compat.py 542 B

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