Skip to content
Snippets Groups Projects
Commit cecf3c23 authored by David Verelst's avatar David Verelst
Browse files

ugly hack: FileNotFoundError absent in PY2

parent 9ae2e0c5
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,14 @@ from wetb.utils.caching import cache_function
from collections import OrderedDict
#HOURS_PR_20YEAR = 20 * 365 * 24
# hack around FileNotFoundError not being in Python2
try:
FileNotFoundError
except NameError as e:
class FileNotFoundError(OSError):
pass
def Weibull(u, k, start, stop, step):
C = 2 * u / np.sqrt(np.pi)
cdf = lambda x :-np.exp(-(x / C) ** k)
......
......@@ -74,8 +74,14 @@ class TestDLCHighLevel(unittest.TestCase):
self.assertTrue(k in self.dlc_hl.sensor_info().keys(), k)
def test_fail_on_res_not_fount(self):
self.dlc_hl = DLCHighLevel(testfilepath + 'DLC_test.xlsx', fail_on_resfile_not_found=True)
self.assertRaisesRegex(FileNotFoundError, "Result files for dlc='12', wsp='6', wdir='-10' not found")
# hack around FileNotFoundError not being in Python2.7
try:
self.dlc_hl = DLCHighLevel(testfilepath + 'DLC_test.xlsx',
fail_on_resfile_not_found=True)
except Exception as e:
# FileNotFoundError on Py3.3+ inherits from IOError
assert isinstance(e.__cause__, IOError)
# self.assertRaises(FileNotFoundError, "Result files for dlc='12', wsp='6', wdir='-10' not found")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment