本文整理汇总了Python中pyramid.testing.cleanUp函数的典型用法代码示例。如果您正苦于以下问题:Python cleanUp函数的具体用法?Python cleanUp怎么用?Python cleanUp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cleanUp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
import datetime
from zope.interface import directlyProvides
from karl.content.interfaces import IBlogEntry
cleanUp()
karltesting.registerSettings()
# Create dummy site skel
community = karltesting.DummyCommunity()
site = community.__parent__.__parent__
profiles = testing.DummyModel()
site["profiles"] = profiles
self.profile = profiles["member"] = karltesting.DummyProfile()
profiles["creator"] = karltesting.DummyProfile()
community["blog"] = testing.DummyModel()
blogentry = testing.DummyModel(text="This is a test")
blogentry.created = datetime.datetime(2010, 5, 12, 2, 42)
blogentry.creator = 'member'
community["blog"]["blogentry"] = blogentry
blogentry["attachments"] = testing.DummyModel()
blogentry.title = "Blog Entry"
blogentry.docid = 0
directlyProvides(blogentry, IBlogEntry)
self.blogentry = blogentry
blogentry["comments"] = testing.DummyModel()
self.comment = self._add_comment(blogentry)
示例2: setUp
def setUp(self):
testing.cleanUp()
batch = [testing.DummyModel(title="foo"), testing.DummyModel(title="bar")]
class DummyGetImagesBatch(object):
def __call__(self, context, request, **search_params):
self.called = (context, request, search_params)
return dict(
entries=batch,
batch_start=search_params["batch_start"],
batch_size=search_params["batch_size"],
total=5,
)
self.dummy_get_images_batch = DummyGetImagesBatch()
def dummy_get_images_info(image, request):
return image.title
self.dummy_get_images_info = dummy_get_images_info
from karl.views.imagedrawer import batch_images
def wrapped_batch_images(*arg, **kw):
kw["get_image_info"] = self.dummy_get_images_info
kw["get_images_batch"] = self.dummy_get_images_batch
return batch_images(*arg, **kw)
self.dummy_batch_images = wrapped_batch_images
示例3: setUp
def setUp(self):
cleanUp()
context = testing.DummyModel(sessions=DummySessions())
self.context = context
request = testing.DummyRequest()
request.environ['repoze.browserid'] = '1'
self.request = request
示例4: setUp
def setUp(self):
cleanUp()
# Set up a dummy community files folder
from karl.content.interfaces import ICommunityRootFolder
from karl.testing import DummyCommunity
from karl.testing import DummyProfile
from zope.interface import directlyProvides
community = DummyCommunity()
files = community["files"] = testing.DummyModel()
directlyProvides(files, ICommunityRootFolder)
site = community.__parent__.__parent__
profiles = site["profiles"] = testing.DummyModel()
chris = profiles["chris"] = DummyProfile()
chris.title = "Chris Rossi"
self.context = files
# Register dummy catalog
from zope.interface import Interface
from karl.models.interfaces import ICatalogSearch
karl.testing.registerAdapter(dummy_catalog_search, Interface,
ICatalogSearch)
# Register atom entry adapter
from karl.views.interfaces import IAtomEntry
from karl.content.views.atom import CommunityFileAtomEntry
karl.testing.registerAdapter(
CommunityFileAtomEntry, (Interface, Interface),
IAtomEntry)
karl.testing.registerDummyRenderer('karl.views:templates/atomfeed.pt')
示例5: collective_generic_webbuilder_tearDown
def collective_generic_webbuilder_tearDown(self):
""" cleanUp() is required to clear out the application registry
between tests
"""
for s in _LAUNCHED_SERVERS:
s.tearDown()
testing.cleanUp()
示例6: setUp
def setUp(self):
testing.cleanUp()
from karl.models import site
self._save_WeightedText = site.WeightedText
site.WeightedText = None
示例7: setUp
def setUp(self):
testing.cleanUp()
self.root = root = karltesting.DummyModel()
root['profiles'] = profiles = karltesting.DummyModel()
root.users = karltesting.DummyUsers()
root['a'] = a = karltesting.DummyModel(creator='chris')
root['b'] = b = karltesting.DummyModel(modified_by='chris')
class DummySearchAdapter(object):
def __init__(self, context):
pass
def __call__(self, **kw):
resolver = lambda x: root.get(x)
if kw.get('creator') == 'chris':
return 1, ['a'], resolver
if kw.get('modified_by') == 'chris':
return 1, ['b'], resolver
return 0, [], resolver
from zope.interface import Interface
from karl.models.interfaces import ICatalogSearch
karltesting.registerAdapter(DummySearchAdapter, (Interface, Interface),
ICatalogSearch)
karltesting.registerAdapter(DummySearchAdapter, (Interface,),
ICatalogSearch)
root.catalog = catalog = karltesting.DummyModel()
catalog['creator'] = DummyCatalogIndex()
catalog['modified_by'] = DummyCatalogIndex()
示例8: layer_tearDown
def layer_tearDown(self):
""" cleanUp() is required to clear out the application registry
between tests
"""
for s in utils._LAUNCHED_SERVERS:
s.tearDown()
testing.cleanUp()
示例9: setUp
def setUp(self):
cleanUp()
import os
try:
# avoid spew from chameleon logger?
os.unlink(self._getTemplatePath('minimal.txt.py'))
except:
pass
示例10: setUp
def setUp(self):
testing.cleanUp()
self.context = context = testing.DummyModel()
context.catalog = DummyCatalog()
context['path'] = testing.DummyModel()
context['path']['to'] = testing.DummyModel()
context['path']['to']['item'] = testing.DummyModel()
示例11: setUp
def setUp(self):
cleanUp()
self._register()
context = DummyNewsItem(sessions=DummySessions())
context.title = 'Foo'
self.context = context
request = testing.DummyRequest()
request.environ['repoze.browserid'] = '1'
self.request = request
示例12: setUp
def setUp(self):
testing.cleanUp()
request = testing.DummyRequest()
request.environ['repoze.browserid'] = '1'
self.request = request
sessions = DummySessions()
context = testing.DummyModel(sessions=sessions)
self.context = context
registerLayoutProvider()
示例13: layer_setUp
def layer_setUp(self):
""" cleanUp() is required to clear out the application registry
between tests (done in setUp for good measure too)
"""
testing.cleanUp()
config = testing.setUp()
config.include('pyramid_zcml')
for zcml in CGWG_ZCMLS:
config.load_zcml('collective.generic.webbuilder:%s' % zcml)
示例14: setUp
def setUp(self):
testing.cleanUp()
karl.testing.registerSettings(mailin_trace_file='foo/bar')
from karl.content.views import blog
self._save_os = blog.os
blog.os = self
self._exists = False
示例15: setUp
def setUp(self):
testing.cleanUp()
from karl.content.models import blog
self._save_os = blog.os
blog.os = self
self._utime_called = None
self._exists = set()
karl.testing.registerSettings(mailin_trace_file='trace_file')