当前位置: 首页>>代码示例>>Python>>正文


Python MagicMock.strip方法代码示例

本文整理汇总了Python中unittest.mock.MagicMock.strip方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.strip方法的具体用法?Python MagicMock.strip怎么用?Python MagicMock.strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.mock.MagicMock的用法示例。


在下文中一共展示了MagicMock.strip方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_categories_with_user

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import strip [as 别名]
    def test_get_categories_with_user(self):
        """
        get_categoriesタグで特定のユーザーの持つカテゴリーが取り出せる
        """
        t = Template(
            "{% load blogs_tags %}"
            "{% get_categories user as categories %}"
        )
        CategoryFactory(author=self.users['children'])
        CategoryFactory(author=self.users['children'], label="日記")
        CategoryFactory(author=self.users['seele'])
        CategoryFactory()
        patterns = (
            ('adam', 0),
            ('seele', 1),
            ('nerv', 0),
            ('children', 2),
            ('wille', 0),
            ('anonymous', 0),
            ('author', 0),
        )
        r = MagicMock()
        for username, ncategories in patterns:
            c = Context(dict(request=r, user=self.users[username]))
            r = t.render(c)
            # get_blog_entries は何も描画しない
            self.assertEqual(r.strip(), "")

            self.assertEqual(len(c['categories']), ncategories)
开发者ID:Clpsplug,项目名称:Kawaz3rd,代码行数:31,代码来源:test_templatetags.py

示例2: test_get_categories

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import strip [as 别名]
    def test_get_categories(self):
        """
        get_categoriesタグで全てのユーザーの持つカテゴリーが取り出せる
        """
        t = Template(
            "{% load blogs_tags %}"
            "{% get_categories as categories %}"
        )
        CategoryFactory()
        CategoryFactory()
        CategoryFactory()
        CategoryFactory()
        patterns = (
            ('adam', 4),
            ('seele', 4),
            ('nerv', 4),
            ('children', 4),
            ('wille', 4),
            ('anonymous', 4),
            ('author', 4),
        )
        r = MagicMock()
        for username, ncategories in patterns:
            c = Context(dict(request=r))
            r = t.render(c)
            # get_blog_entries は何も描画しない
            self.assertEqual(r.strip(), "")

            self.assertEqual(len(c['categories']), ncategories)
开发者ID:Clpsplug,项目名称:Kawaz3rd,代码行数:31,代码来源:test_templatetags.py

示例3: _render_stars_template

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import strip [as 别名]
 def _render_stars_template(self, username, object):
     t = Template(
         "{% load stars_tags %}"
         "{% get_stars object as stars %}"
     )
     r = MagicMock()
     r.user = self.users[username]
     c = Context(dict(request=r, object=object))
     r = t.render(c)
     # get_stars は何も描画しない
     self.assertEqual(r.strip(), "")
     return c['stars']
开发者ID:Clpsplug,项目名称:Kawaz3rd,代码行数:14,代码来源:test_templatetags.py

示例4: _render_template_with_author

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import strip [as 别名]
 def _render_template_with_author(self, username, author):
     t = Template(
         "{% load blogs_tags %}"
         "{% get_published_entries_of user as entries %}"
     )
     r = MagicMock()
     r.user = self.users[username]
     c = Context(dict(request=r, user=author))
     r = t.render(c)
     # get_blog_entries は何も描画しない
     self.assertEqual(r.strip(), "")
     return c['entries']
开发者ID:Clpsplug,项目名称:Kawaz3rd,代码行数:14,代码来源:test_templatetags.py

示例5: _render_template_with_member

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import strip [as 别名]
 def _render_template_with_member(self, username, member):
     t = Template(
         "{% load projects_tags %}"
         "{% get_published_projects_members_of member as projects %}"
     )
     r = MagicMock()
     r.user = self.users[username]
     c = Context(dict(request=r, member=member))
     r = t.render(c)
     # get_blog_projects は何も描画しない
     self.assertEqual(r.strip(), "")
     return c['projects']
开发者ID:Clpsplug,项目名称:Kawaz3rd,代码行数:14,代码来源:test_templatetags.py

示例6: _render_endpoint_template

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import strip [as 别名]
 def _render_endpoint_template(self, object):
     t = Template(
         "{{% load stars_tags %}}"
         "{{% get_star_endpoint {} as star_endpoint %}}".format(
             "object"
         )
     )
     r = MagicMock()
     c = Context(dict(request=r, object=object))
     r = t.render(c)
     # get_star_endpoint は何も描画しない
     self.assertEqual(r.strip(), "")
     return c['star_endpoint']
开发者ID:Clpsplug,项目名称:Kawaz3rd,代码行数:15,代码来源:test_templatetags.py

示例7: _render_template

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import strip [as 别名]
 def _render_template(self, username, lookup=''):
     t = Template(
         "{{% load events_tags %}}"
         "{{% get_events {} as events %}}".format(
             "'{}'".format(lookup) if lookup else ''
         )
     )
     r = MagicMock()
     r.user = self.users[username]
     c = Context(dict(request=r))
     r = t.render(c)
     # get_blog_events は何も描画しない
     self.assertEqual(r.strip(), "")
     return c['events']
开发者ID:Clpsplug,项目名称:Kawaz3rd,代码行数:16,代码来源:test_templatetags.py


注:本文中的unittest.mock.MagicMock.strip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。