Skip to content

Commit 0cfab53

Browse files
committed
fix handling of file not found
1 parent bd8404f commit 0cfab53

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/test_sparkjob.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import pytest
22
import os
33
import sparkhpc
4+
import sys
5+
6+
if sys.version_info.major == 2:
7+
fnfe = (OSError, IOError)
8+
elif sys.version_info.major == 3:
9+
fnfe = FileNotFoundError
410

511
def find_bindir():
612
for root, subdirs, files in os.walk('.'):
@@ -17,6 +23,8 @@ def find_bindir():
1723
INFO:sparkhpc.sparkjob:[start_cluster] master running at spark://1.1.1.1:7077
1824
INFO:sparkhpc.sparkjob:[start_cluster] master UI available at http://1.1.1.1:8080"""
1925

26+
27+
2028
@pytest.fixture(autouse=True)
2129
def change_homedir(monkeypatch):
2230
monkeypatch.setattr(os.path, 'expanduser', lambda user: testdir)
@@ -44,7 +52,7 @@ def sj(monkeypatch, request):
4452

4553
try:
4654
os.remove(os.path.join(testdir,'.sparkhpc1'))
47-
except FileNotFoundError:
55+
except fnfe:
4856
pass
4957

5058
def test_job_submission(sj):
@@ -98,7 +106,7 @@ def test_jobid_start(sj):
98106
assert(sj.master_ui()) == 'http://1.1.1.1:8080'
99107

100108
# this should fail
101-
with pytest.raises(FileNotFoundError):
109+
with pytest.raises(fnfe):
102110
sj2 = sj.__class__(jobid=100)
103111

104112

0 commit comments

Comments
 (0)