Commits

Philip Jenvey committed d371087

o convert to webtest
o use nose.SkipTest to avoid tests on environments that lack the required
extras
o use nose.collector for setup.py test

Comments (0)

Files changed (7)

 verbose=True
 verbosity=2
 with-doctest=True
-with-coverage=True
-cover-erase=True
-cover-tests=True
-cover-package=beaker
+# Disabled here as they're invalid to setup.py test
+#with-coverage=True
+#cover-erase=True
+#cover-tests=True
+#cover-package=beaker
       packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
       zip_safe=False,
       install_requires=[],
-      extras_require = {
+      extras_require={
           'crypto':["pycryptopp>=0.3.0"]
       },
+      test_suite='nose.collector',
+      tests_require=['nose', 'webtest'],
       entry_points="""
           [paste.filter_factory]
           beaker_session = beaker.middleware:session_filter_factory

tests/test_cache.py

 # coding: utf-8
-from paste.fixture import *
 from beaker.middleware import CacheMiddleware
 from beaker.cache import Cache
+from webtest import TestApp
 
 def simple_app(environ, start_response):
     clear = False

tests/test_database.py

 # coding: utf-8
-from paste.fixture import *
+from beaker.cache import clsmap, Cache
 from beaker.middleware import CacheMiddleware
-from beaker.cache import Cache
+from nose import SkipTest
+from webtest import TestApp
+
+if 'ext:database' not in clsmap:
+    raise SkipTest("'sqlalchemy' is not installed, can't test database "
+                   "backend")
 
 db_url = 'sqlite:///test.db'
 

tests/test_increment.py

 import re
 import os
 
-from paste.fixture import TestApp
 from beaker.middleware import SessionMiddleware
+from webtest import TestApp
 
 loc = os.path.sep.join([os.path.dirname(os.path.abspath(__file__)), 'sessions'])
 
     app = TestApp(SessionMiddleware(simple_app))
     res = app.get('/nosave')
     assert 'current value is: 1' in res
-    assert [] == res.all_headers('Set-Cookie')
+    assert [] == res.headers.getall('Set-Cookie')
     res = app.get('/nosave')
     assert 'current value is: 1' in res
     
     res = app.get('/')
     assert 'current value is: 1' in res
-    assert len(res.all_headers('Set-Cookie')) > 0
+    assert len(res.headers.getall('Set-Cookie')) > 0
     res = app.get('/')
-    assert [] == res.all_headers('Set-Cookie')
+    assert [] == res.headers.getall('Set-Cookie')
     assert 'current value is: 2' in res
 
 def test_load_session_by_id():

tests/test_memcached.py

 # coding: utf-8
-from paste.fixture import *
+from beaker.cache import clsmap, Cache
 from beaker.middleware import CacheMiddleware
-from beaker.cache import Cache
+from nose import SkipTest
+from webtest import TestApp
+
+if 'ext:memcached' not in clsmap:
+    raise SkipTest("'memcache' or 'cmemcache' is not installed, can't test "
+                   "memcached backend")
 
 mc_url = '127.0.0.1'