Skip to content
Browse files

switch from attest (no longer maintained) to py.test

  • Loading branch information...
1 parent 50c4739 commit 2948f4e896551ce5f114e58cd0a1be114a722e77 @gvalkov committed Apr 12, 2012
Showing with 26 additions and 47 deletions.
  1. +19 −4 setup.py
  2. +0 −16 tests/__init__.py
  3. +1 −9 tests/test_formatter.py
  4. +6 −18 tests/test_script.py
View
23 setup.py
@@ -2,14 +2,14 @@
# encoding: utf-8
from os import getuid
-from setuptools import setup
+from setuptools import setup, Command
from rsstail.version import version
from os.path import dirname, isdir, join as pjoin
here = dirname(__file__)
requires = ('feedparser>=4.1',)
-tests_require = ('attest', 'scripttest')
+tests_require = ('pytest', 'scripttest')
classifiers = (
'Environment :: Console',
@@ -52,12 +52,26 @@
'install_requires' : requires,
'tests_require' : tests_require,
- 'test_loader' : 'attest:auto_reporter.test_loader',
- 'test_suite' : 'tests.all',
+ 'cmdclass' : {},
'zip_safe' : True,
}
+
+# setup.py test -> py.test tests
+class PyTest(Command):
+ user_options = []
+ def initialize_options(self): pass
+ def finalize_options(self): pass
+ def run(self):
+ from subprocess import call
+ errno = call(('py.test', 'tests'))
+ raise SystemExit(errno)
+
+kw['cmdclass']['test'] = PyTest
+setup(**kw)
+
+
# try to install bash and zsh completions (emphasis on the *try*)
if getuid() == 0:
if isdir('/etc/bash_completion.d'):
@@ -69,4 +83,5 @@
t = ('/usr/share/zsh/functions/Completion/Unix/', ['etc/_rsstail'])
kw['data_files'].append(t)
+
setup(**kw)
View
16 tests/__init__.py
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-# encoding: utf-8
-
-from attest import Tests
-from test_script import script
-from test_formatter import formatter
-
-tests = (
- script,
- formatter,
-)
-
-all = Tests(tests)
-
-if __name__ == '__main__':
- all.main()
View
10 tests/test_formatter.py
@@ -1,14 +1,10 @@
#!/usr/bin/env python
# encoding: utf-8
-from attest import Tests
from rsstail.formatter import Formatter
-formatter = Tests()
-
-@formatter.test
-def placeholder_style_detect():
+def test_placeholder_style_detect():
f = Formatter('{asdf} {zxcv} {qwerty}', None)
assert f.placeholder_style == f.PH_NEW
@@ -23,7 +19,3 @@ def placeholder_style_detect():
f = Formatter('{asdf} {zxcv} %(qwerty)s %(azerty)s', None)
assert f.placeholder_style == f.PH_OLD
-
-
-if __name__ == '__main__':
- formatter.main()
View
24 tests/test_script.py
@@ -6,8 +6,6 @@
from os.path import dirname, abspath, join as pjoin
from functools import partial
-
-from attest import Tests
from scripttest import TestFileEnvironment
@@ -18,22 +16,18 @@
cmd = 'rsstail'
run = partial(env.run, expect_stderr=True)
-script = Tests()
-@script.test
-def run_no_args_no_opts():
+def test_run_no_args_no_opts():
r = run(cmd)
assert r.returncode == 0
assert 'General Options:' in r.stdout
-@script.test
-def run_initial():
+def test_run_initial():
r = run(cmd + ' -e 1 --initial 3 %s' % feed1)
assert len(r.stdout.splitlines()) == 3
-@script.test
-def run_order():
+def test_run_order():
r = run(cmd + ' -e 1 --reverse --title %s' % feed1)
exp = ['Title: pip_python2.6 #1002 (SUCCESS)',
@@ -49,13 +43,11 @@ def run_order():
res = [i.strip(' ') for i in r.stdout.splitlines()]
assert res == list(reversed(exp))
-@script.test
-def run_headings():
+def test_run_headings():
r = run(cmd + ' -e 1 --title --url --no-heading %s' % feed1)
assert ('Title' not in r.stdout) and ('Link' not in r.stdout)
-@script.test
-def run_newer():
+def test_run_newer():
r = run(cmd + ' -e 1 --newer "2012/01/04 11:00:00" %s' % feed1)
assert (len(r.stdout.splitlines())) == 1
@@ -68,11 +60,7 @@ def run_newer():
r = run(cmd + ' -e 1 --newer "2012/01/04 $#@!@#" %s' % feed1, expect_error=True)
assert r.returncode == 1
-#@script.test
-def run_striphtml():
+def test_run_striphtml():
# TODO: find test feed
r = run(cmd + ' -e 1 --desc --striphtml %s' % feed1)
-
-if __name__ == '__main__':
- script.main()

0 comments on commit 2948f4e

Please sign in to comment.
Something went wrong with that request. Please try again.