Skip to content

Instantly share code, notes, and snippets.

@borntyping
Last active December 11, 2015 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borntyping/4540428 to your computer and use it in GitHub Desktop.
Save borntyping/4540428 to your computer and use it in GitHub Desktop.
Runs nosetests using sniffer, but drops much of the output and avoids reloading python modules
#!/usr/bin/env python
from os import getcwd
from sys import argv
from subprocess import Popen
from pynotify import init, Notification
from sniffer.broadcasters import PynotifyEmitter
from sniffer.main import run
from sniffer.runner import Sniffer
try:
import yanc
except ImportError:
yanc = None
class MySniffer(Sniffer):
title = "nosetests"
def __init__(self, *args, **kwargs):
super(MySniffer, self).__init__(*args, **kwargs)
init(self.title)
def run(self):
arguments = ['nosetests'] + argv[1:]
if yanc: arguments.append('--with-yanc')
return Popen(arguments, cwd=getcwd()).wait() == 0
def _run(self):
"""Calls self.run() and wraps for errors."""
try:
if self.run():
Notification(self.title, "Tests succeeded").show()
else:
Notification(self.title, "Tests failed!").show()
except StandardError:
import traceback
traceback.print_exc()
self._stop()
raise
except Exception:
self._stop()
raise
return True
def clear_on_run(self):
super(MySniffer, self).clear_on_run(None)
run(sniffer_instance=MySniffer(), wait_time=1)
Copy link

ghost commented Apr 9, 2014

jshintprint_exc()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment