Add test of new mmap() OSError catching

This commit is contained in:
Brandon Rhodes 2020-03-26 12:33:59 -04:00
parent dc578f6582
commit 059915a878
1 changed files with 17 additions and 0 deletions

View File

@ -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):