Last active
December 11, 2015 03:48
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jshintprint_exc()