diff --git a/jplephem/test.py b/jplephem/test.py index 8cee8c5..fea542a 100644 --- a/jplephem/test.py +++ b/jplephem/test.py @@ -8,6 +8,7 @@ smaller and more feature-oriented suite can be run with:: python -m unittest discover jplephem """ +import mmap import numpy as np import sys import tempfile @@ -188,6 +189,22 @@ class TestDAFRealFile(TestDAFBytesIO): return f +def fake_mmap_that_raises_OSError(*args, **kw): + raise OSError('mmap() not supported on this platform') + +class TestDAFRealFileWithoutMMap(TestDAFRealFile): + # Where "Real" = "written to disk with a real file descriptor + # instead of an in-memory BytesIO". And we turn off mmap() to + # simulate platforms like pyodide. + + def setUp(self): + self.mmap = mmap.mmap + mmap.mmap = fake_mmap_that_raises_OSError + + def tearDown(self): + mmap.mmap = self.mmap + + class _CommonTests(object): def check0(self, xyz, xyzdot=None):