Skip to content

Commit

Permalink
Improve testing coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Dec 2, 2016
1 parent b4cb315 commit 63ace51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions psrecord/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def all_children(pr):
children = pr.children()
except AttributeError:
children = pr.get_children()
except Exception:
except Exception: # pragma: no cover
pass

for child in children:
Expand Down Expand Up @@ -147,7 +147,7 @@ def monitor(pid, logfile=None, plot=None, duration=None, interval=None,
pr_status = pr.status()
except TypeError: # psutil < 2.0
pr_status = pr.status
except psutil.NoSuchProcess:
except psutil.NoSuchProcess: # pragma: no cover
break

# Check if process status indicates we should exit
Expand Down Expand Up @@ -198,7 +198,7 @@ def monitor(pid, logfile=None, plot=None, duration=None, interval=None,
log['mem_real'].append(current_mem_real)
log['mem_virtual'].append(current_mem_virtual)

except KeyboardInterrupt:
except KeyboardInterrupt: # pragma: no cover
pass

if logfile:
Expand Down
7 changes: 5 additions & 2 deletions psrecord/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def test_plot(self, tmpdir):
assert os.path.exists(filename)

def test_main(self):
orig = sys.argv[:]
sys.argv = 'psrecord {0} --duration=3'.split()
sys.argv = ['psrecord', '--duration=3', "'sleep 10'"]
main()

def test_main_by_id(self):
sys.argv = ['psrecord', '--duration=3', str(os.getpid())]
main()

0 comments on commit 63ace51

Please sign in to comment.