Skip to content

Commit

Permalink
fix handling of file not found
Browse files Browse the repository at this point in the history
  • Loading branch information
rokroskar committed May 12, 2017
1 parent bd8404f commit 0cfab53
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_sparkjob.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import pytest
import os
import sparkhpc
import sys

if sys.version_info.major == 2:
fnfe = (OSError, IOError)
elif sys.version_info.major == 3:
fnfe = FileNotFoundError

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



@pytest.fixture(autouse=True)
def change_homedir(monkeypatch):
monkeypatch.setattr(os.path, 'expanduser', lambda user: testdir)
Expand Down Expand Up @@ -44,7 +52,7 @@ def sj(monkeypatch, request):

try:
os.remove(os.path.join(testdir,'.sparkhpc1'))
except FileNotFoundError:
except fnfe:
pass

def test_job_submission(sj):
Expand Down Expand Up @@ -98,7 +106,7 @@ def test_jobid_start(sj):
assert(sj.master_ui()) == 'http://1.1.1.1:8080'

# this should fail
with pytest.raises(FileNotFoundError):
with pytest.raises(fnfe):
sj2 = sj.__class__(jobid=100)


Expand Down

0 comments on commit 0cfab53

Please sign in to comment.