def setUp(self):
"""set up the test
"""
import transaction
from pyramid import paster, testing
from webtest import TestApp
from stalker import db
from stalker.db.session import DBSession
testing.setUp()
import os
import stalker_pyramid
app = paster.get_app(
os.path.join(
os.path.dirname(
stalker_pyramid.__path__[0],
),
'testing.ini'
).replace('\\', '/')
)
self.test_app = TestApp(app)
# patch DBSession commit, to let the db.init() work
# with its calls to DBSession.commit()
_orig_commit = DBSession.commit
DBSession.commit = transaction.commit
db.setup(app.registry.settings)
db.init()
# restore DBSession.commit
DBSession.commit = _orig_commit
from stalker import User
self.admin = User.query.filter(User.name == 'admin').first()
评论列表
文章目录