aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bachelier <laurent@bachelier.name>2014-08-22 22:03:47 +0200
committerLaurent Bachelier <laurent@bachelier.name>2014-08-22 22:03:47 +0200
commitde7a5b6e1cf122585ba9a6ada70fb4748415834e (patch)
tree18204f373e84472c60978797665e630b1a8860d5
parentRelease 1.0.0 (diff)
downloadrtorrent-notify-de7a5b6e1cf122585ba9a6ada70fb4748415834e.tar.xz
Make tests run without nose and hacks
-rw-r--r--rtorrentnotify/test.py71
-rw-r--r--setup.cfg4
-rwxr-xr-xsetup.py11
3 files changed, 40 insertions, 46 deletions
diff --git a/rtorrentnotify/test.py b/rtorrentnotify/test.py
index 701a2b1..ee250e0 100644
--- a/rtorrentnotify/test.py
+++ b/rtorrentnotify/test.py
@@ -1,42 +1,41 @@
-#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from StringIO import StringIO
+from unittest import TestCase
from rtorrentnotify import Event, Events
-def test_db():
- maxitems = 20
- db = StringIO()
- events = Events(db, maxitems)
- events.load()
- for n in range(1, 42):
- events.append(Event('LOL', 'cat %s' % n))
- e = Event('B', 'b')
- events.append(e)
- events.save()
-
- events = Events(db)
- events.load()
- assert events._events[0].datetime.ctime() == e.datetime.ctime()
- assert len(unicode(events).splitlines()) == maxitems
-
-
-def test_add():
- events = Events(None)
- events.append(Event('LOL', 'cat'))
- events.append(Event('LOL', 'cat'))
- out = unicode(events)
- assert len(out.splitlines()) == 2
-
-
-def test_rss():
- events = Events(None)
- events.append(Event('a', 'b'))
- events.append(Event('c', u'héhéhé'))
-
- feed = events.build_rss()
- out = StringIO()
- feed.write_xml(out, "utf-8")
- out = out.getvalue()
- assert 'guid' in out
+class Tests(TestCase):
+ def test_db(self):
+ maxitems = 20
+ db = StringIO()
+ events = Events(db, maxitems)
+ events.load()
+ for n in range(1, 42):
+ events.append(Event('LOL', 'cat %s' % n))
+ e = Event('B', 'b')
+ events.append(e)
+ events.save()
+
+ events = Events(db)
+ events.load()
+ assert events._events[0].datetime.ctime() == e.datetime.ctime()
+ assert len(unicode(events).splitlines()) == maxitems
+
+ def test_add(self):
+ events = Events(None)
+ events.append(Event('LOL', 'cat'))
+ events.append(Event('LOL', 'cat'))
+ out = unicode(events)
+ assert len(out.splitlines()) == 2
+
+ def test_rss(self):
+ events = Events(None)
+ events.append(Event('a', 'b'))
+ events.append(Event('c', u'héhéhé'))
+
+ feed = events.build_rss()
+ out = StringIO()
+ feed.write_xml(out, "utf-8")
+ out = out.getvalue()
+ assert 'guid' in out
diff --git a/setup.cfg b/setup.cfg
index b47319c..b9f54ba 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -3,3 +3,7 @@ match = ^test
verbosity = 2
detailed-errors = 1
where = rtorrentnotify
+
+[pytest]
+python_files=test.py
+addopts = -sv
diff --git a/setup.py b/setup.py
index 31964e5..34dc4a9 100755
--- a/setup.py
+++ b/setup.py
@@ -1,15 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Hack to prevent stupid "TypeError: 'NoneType' object is not callable" error
-# in multiprocessing/util.py _exit_function when running `python
-# setup.py test` (see
-# http://www.eby-sarna.com/pipermail/peak/2010-May/003357.html)
-try:
- import multiprocessing
-except ImportError:
- pass
-
from setuptools import setup, find_packages
setup(
@@ -23,7 +14,7 @@ setup(
packages=find_packages(),
entry_points={'console_scripts': ['rtorrent-notify = rtorrentnotify.cli:main']},
install_requires=['PyRSS2Gen'],
- test_suite='nose.collector',
+ test_suite='rtorrentnotify.test',
tests_require='nose>=1.0',
classifiers=[
'License :: OSI Approved :: MIT License',