Skip to content

Commit

Permalink
Fixing test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessica Mizzi committed Mar 6, 2015
1 parent b2c18c0 commit 0155591
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions khmer/kfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ def check_file_status(file_path, force):
AND if the file is NOT a fifo/block/named pipe then a warning is printed
and sys.exit(1) is called
"""
mode = None

if file_path is '-':
return
try:
mode = os.stat(file_path).st_mode
except OSError:
print >>sys.stderr, "ERROR: Input file %s does not exist; exiting" % \
print >>sys.stderr, "ERROR: Input file %s does not exist" % \
file_path

if not force:
print >>sys.stderr, "Exiting"
sys.exit(1)
else:
return

# block devices will be nonzero
if S_ISBLK(mode) or S_ISFIFO(mode):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,20 @@ def test_extract_hashbits_info():

def test_check_file_status_kfile():
fn = utils.get_temp_filename('thisfiledoesnotexist')
check_file_status_exited = False
try:
check_file_status(fn, False)
assert True
except OSError as e:
print >>sys.stder, '...failed to remove {fn}'.format(fn)
except SystemExit:
check_file_status_exited = True
assert check_file_status_exited


def test_check_file_status_kfile_force():
fn = utils.get_temp_filename('thisfiledoesnotexist')
try:
check_file_status(fn, True)
assert False
check_file_status(fn, True)
except OSError as e:
print >>sys.stderr, '...failed to remove {fn}'.format(fn)
assert False


FakeFQRead = collections.namedtuple('Read', ['name', 'quality', 'sequence'])
Expand Down

0 comments on commit 0155591

Please sign in to comment.