Commits

Anonymous committed 4f25d8b

init checkin of nose-growl

Comments (0)

Files changed (9)

nose-growl/AUTHORS

+Victor Ng

nose-growl/Makefile

+pypi:
+	python setup.py sdist bdist_egg upload -s 
+
+clean:
+	rm -rf dist build *egg-info
+	find . -name "*.pyc" | xargs rm
+

nose-growl/README.txt

+Nose Growl plugin
+=================
+
+nosetests --with-growl
+
+Enable growl notifiications on testsuite start and completion with simple reports
+in the notification windows.
+
+Contact: 
+    Victor Ng <crankycoder@gmail.com>
+ 
Add a comment to this file

nose-growl/nosegrowl/__init__.py

Empty file added.

Add a comment to this file

nose-growl/nosegrowl/dialog-cancel.png

Added
New image
Add a comment to this file

nose-growl/nosegrowl/dialog-ok.png

Added
New image

nose-growl/nosegrowl/growler.py

+"""
+nose plugin for easy testing of django projects and apps. Sets up a test
+database (or schema) and installs apps from test settings file before tests
+are run, and tears the test database (or schema) down after all tests are run.
+"""
+__author = 'Jason Pellerin'
+__version__ = '0.1'
+
+import atexit
+import logging
+import os, sys
+import re
+import datetime
+
+from nose.plugins import Plugin
+from pkg_resources import resource_string
+import nose.case
+
+from nose.importer import add_path
+
+log = logging.getLogger('nose.plugins.nosegrowl')
+
+from Growl import GrowlNotifier, GROWL_NOTIFICATIONS_DEFAULT
+
+class SimpleNotifier(object):
+    def __init__(self, app_name='PyTest'):
+        self.app_icon = resource_string('nosegrowl', 'python.png')
+        self.ok_icon = resource_string('nosegrowl', 'dialog-ok.png')
+        self.fail_icon = resource_string('nosegrowl', 'dialog-cancel.png')
+
+        self.growl = GrowlNotifier(applicationName=app_name,
+                notifications=[GROWL_NOTIFICATIONS_DEFAULT],
+                applicationIcon=self.app_icon)
+
+    def register(self):
+        self.growl.register()
+
+    def start(self, title, description):
+        self.notify(title, description, icon=self.app_icon)
+
+    def success(self, title, description):
+        self.notify(title, description, icon=self.ok_icon)
+
+    def fail(self, title, description):
+        self.notify(title=title, description=description, icon=self.fail_icon)
+        
+    def notify(self, title, description, icon=None, sticky=False):
+        self.growl.notify(noteType=GROWL_NOTIFICATIONS_DEFAULT,
+            title=title,
+            description=description,
+            icon=icon,
+            sticky=sticky)
+
+class NoseGrowl(Plugin):
+    """
+    Enable Growl notifications
+    """
+    name = 'growl'
+
+    def begin(self):
+        growl = SimpleNotifier()
+        growl.register()
+        self.start_time = datetime.datetime.now()
+        growl.start("Starting tests...", 'Started at : [%s]' % self.start_time.isoformat())
+
+    def finalize(self, result=None):
+        """
+        Clean up any created database and schema.
+        """
+        growl = SimpleNotifier()
+        fail_msg = '\n'.join(["Failed: %s" % name for name, ex in result.failures])
+        err_msg = '\n'.join(["Error: %s" % name for name, ex in result.errors])
+
+        big_msg = '\n'.join([fail_msg, err_msg])
+
+        self.finish_time = datetime.datetime.now()
+            
+        delta = self.finish_time - self.start_time
+        endtime_msg = 'Completed in  %s.%s seconds' % (delta.seconds, delta.microseconds)
+        if result.wasSuccessful():
+            growl.success("%s tests run ok" % result.testsRun, endtime_msg)
+        else:
+            growl.fail("%s tests. %s failed. %s errors." % (result.testsRun, len(result.failures), len(result.errors)), "%s\n%s" % (big_msg, endtime_msg))
Add a comment to this file

nose-growl/nosegrowl/python.png

Added
New image

nose-growl/setup.py

+from setuptools import setup, find_packages
+
+setup(
+    name='NoseGrowl',
+    version='0.4pre',
+    author='Victor Ng',
+    author_email = 'victor.ng@monkeybeanonline.com',
+    description = 'nose plugin for Growl notifications',
+    install_requires=['nose>=0.10', 'py-growl'],
+    url = "http://poli-cms.googlecode.com/svn/nose-growl/",
+    license = 'GNU LGPL',
+    packages = find_packages(exclude=['tests']),
+    zip_safe = False,
+    include_package_data = True,
+    package_data = { 
+        'nosegrowl': ['*.png'], 
+    },
+    entry_points = {
+        'nose.plugins': [
+            'growl = nosegrowl.growler:NoseGrowl'
+            ]
+        }
+    )
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.