test_isfile.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import os
  2. import sys
  3. from pathlib import Path
  4. import pytest
  5. import numpy as np
  6. from numpy.testing import assert_
  7. ROOT = Path(np.__file__).parents[0]
  8. FILES = [
  9. ROOT / "py.typed",
  10. ROOT / "__init__.pyi",
  11. ROOT / "ctypeslib" / "__init__.pyi",
  12. ROOT / "_core" / "__init__.pyi",
  13. ROOT / "f2py" / "__init__.pyi",
  14. ROOT / "fft" / "__init__.pyi",
  15. ROOT / "lib" / "__init__.pyi",
  16. ROOT / "linalg" / "__init__.pyi",
  17. ROOT / "ma" / "__init__.pyi",
  18. ROOT / "matrixlib" / "__init__.pyi",
  19. ROOT / "polynomial" / "__init__.pyi",
  20. ROOT / "random" / "__init__.pyi",
  21. ROOT / "testing" / "__init__.pyi",
  22. ]
  23. if sys.version_info < (3, 12):
  24. FILES += [ROOT / "distutils" / "__init__.pyi"]
  25. @pytest.mark.thread_unsafe(
  26. reason="os.path has a thread-safety bug (python/cpython#140054). "
  27. "Expected to only be a problem in 3.14.0"
  28. )
  29. class TestIsFile:
  30. def test_isfile(self):
  31. """Test if all ``.pyi`` files are properly installed."""
  32. for file in FILES:
  33. assert_(os.path.isfile(file))