• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tests.TestCase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.TestCase的典型用法代码示例。如果您正苦于以下问题:Python TestCase类的具体用法?Python TestCase怎么用?Python TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.users = [
            self.User(),
            self.User()
        ]
        self.articles = [
            self.Article(),
            self.Article(),
            self.Article(),
            self.Article()
        ]
        self.posts = [
            self.BlogPost(),
            self.BlogPost(),
            self.BlogPost(),
        ]

        self.session.add_all(self.users)
        self.session.add_all(self.articles)
        self.session.add_all(self.posts)
        self.session.commit()

        self.chain = QueryChain(
            [
                self.session.query(self.User).order_by('id'),
                self.session.query(self.Article).order_by('id'),
                self.session.query(self.BlogPost).order_by('id')
            ]
        )
开发者ID:MSusik,项目名称:sqlalchemy-utils,代码行数:30,代码来源:test_query_chain.py


示例2: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)
        text_items = [
            self.Article(name=u'Article 1'),
            self.Article(name=u'Article 2'),
            self.Article(name=u'Article 3'),
            self.Article(name=u'Article 4'),
            self.BlogPost(name=u'BlogPost 1'),
            self.BlogPost(name=u'BlogPost 2'),
            self.BlogPost(name=u'BlogPost 3'),
            self.BlogPost(name=u'BlogPost 4')
        ]
        self.session.add_all(text_items)
        self.session.flush()
        category = self.Category(name=u'Category #1')
        category.articles = text_items[0:2]
        category.blog_posts = text_items[4:7]
        category2 = self.Category(name=u'Category #2')
        category2.articles = text_items[2:4]
        category2.blog_posts = text_items[-1:]
        self.session.add(category)
        self.session.add(category2)
        text_items[0].attachments = [
            self.Attachment(id=22, name=u'Attachment 1'),
            self.Attachment(id=34, name=u'Attachment 2')
        ]
        text_items[0].author = self.User(name=u'John Matrix')
        text_items[1].author = self.User(name=u'John Doe')

        self.session.commit()
开发者ID:cheungpat,项目名称:sqlalchemy-utils,代码行数:30,代码来源:test_join_table_inheritance.py


示例3: setup_method

 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.article = self.Article()
     self.article.name = u'Some article'
     self.article.content = u'Some content'
     self.article.tags.append(self.Tag(name=u'Some tag'))
     self.session.add(self.article)
     self.session.commit()
开发者ID:FelixLoether,项目名称:sqlalchemy-continuum,代码行数:8,代码来源:test_transaction_log.py


示例4: setUp

 def setUp(self):
     TestCase.setUp(self)
     self.logger = Logger(output_dir = test_logdir)
     self.protocol = MockProtocol('aim', 'digsby03')
     self.account = MockAccount('aim', 'digsby03')
     self.self_buddy = MockBuddy('digsby03', self.protocol)
     self.buddy = MockBuddy('digsby01', self.protocol)
     self.convo = MockConversation(buddy = self.buddy, ischat=False, protocol=self.protocol)
开发者ID:AlexUlrich,项目名称:digsby,代码行数:8,代码来源:test_logger.py


示例5: setup_method

 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(Article(name=u'index', content=u'some content'))
     self.session.add(Article(name=u'admin', content=u'admin content'))
     self.session.add(
         Article(name=u'home', content=u'this is the home page')
     )
     self.session.commit()
开发者ID:gonz,项目名称:sqlalchemy-searchable,代码行数:8,代码来源:test_searchable.py


示例6: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)
        flexmock(S3BotoStorage) \
            .should_receive('_get_or_create_bucket') \
            .with_args('some_bucket') \
            .and_return(MockBucket())

        self.storage = S3BotoStorage('some_bucket')
        self.file = S3BotoStorageFile(self.storage, 'some_file')
开发者ID:kvesteri,项目名称:flask-storage,代码行数:9,代码来源:test_amazon.py


示例7: setup_method

 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(
         self.WeightedTextItem(name=u'Gort', content=u'Klaatu barada nikto')
     )
     self.session.add(
         self.WeightedTextItem(name=u'Klaatu', content=u'barada nikto')
     )
     self.session.commit()
开发者ID:Kua-Fu,项目名称:sqlalchemy-searchable,代码行数:9,代码来源:test_weighted_search_vector.py


示例8: setup_method

 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.session.add(
         self.TextMultiItem(name=u'index', content=u'lorem ipsum')
     )
     self.session.add(
         self.TextMultiItem(name=u'ipsum', content=u'admin content')
     )
     self.session.commit()
开发者ID:deviba01,项目名称:SkillsConnect,代码行数:9,代码来源:test_multiple_vectors_per_class.py


示例9: setup_method

    def setup_method(self, method):
        self.type = CompositeType(
            'category',
            [
                sa.Column('scale', NumericRangeType),
                sa.Column('name', sa.String)
            ]
        )

        TestCase.setup_method(self, method)
开发者ID:jace,项目名称:sqlalchemy-utils,代码行数:10,代码来源:test_composite.py


示例10: setup_method

 def setup_method(self, method):
     TestCase.setup_method(self, method)
     self.path = os.path.join(
         os.path.dirname(__file__),
         'uploads',
         'images'
     )
     self.rel_path = os.path.join('uploads', 'images')
     self.storage = FileSystemStorage(os.path.dirname(__file__))
     self.file = 'some_file.txt'
开发者ID:achauve,项目名称:flask-storage-helpers,代码行数:10,代码来源:test_filesystem.py


示例11: setup_method

    def setup_method(self, method):
        self.type = CompositeType(
            'category',
            [
                sa.Column('scale', NumericRangeType),
                sa.Column('name', sa.String)
            ]
        )

        TestCase.setup_method(self, method)
        i18n.get_locale = lambda: babel.Locale('en')
开发者ID:scorphus,项目名称:sqlalchemy-utils,代码行数:11,代码来源:test_composite.py


示例12: setup_method

 def setup_method(self, method):
     TestCase.setup_method(self, method)
     user = self.User(
         name='Someone',
         email='[email protected]',
         age=15,
         fav_numbers=[1, 2, 3]
     )
     self.session.add(user)
     self.session.commit()
     self.user = user
开发者ID:jace,项目名称:sqlalchemy-utils,代码行数:11,代码来源:test_asserts.py


示例13: create_models

    def create_models(self):
        TestCase.create_models(self)

        class User(self.Model):
            __tablename__ = "user"
            __versioned__ = {"base_classes": (self.Model,)}

            id = sa.Column(sa.Integer, autoincrement=True, primary_key=True)
            name = sa.Column(sa.Unicode(255), nullable=False)

        self.User = User
开发者ID:kvesteri,项目名称:sqlalchemy-continuum,代码行数:11,代码来源:test_flask.py


示例14: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)

        self.app.add_url_rule('/users/new',
            view_func=CreateFormView.as_view('edit',
                model_class=self.User,
                form_class=MockForm
            )
        )
        self.app.add_url_rule('/users/<int:id>',
            view_func=ShowView.as_view('user.show', model_class=self.User)
        )
开发者ID:kvesteri,项目名称:flask-generic-views,代码行数:12,代码来源:test_create_form_view.py


示例15: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)

        self.app.add_url_rule('/users/<int:id>/edit',
            view_func=UpdateFormView.as_view('edit',
            model_class=self.User,
            form_class=MockForm),
        )
        self.app.add_url_rule('/user/<int:id>',
            view_func=ShowView.as_view('user.show', model_class=self.User)
        )
        user = self.User(name=u'John Matrix')
        self.db.session.add(user)
        self.db.session.commit()
开发者ID:kvesteri,项目名称:flask-generic-views,代码行数:14,代码来源:test_update_form_view.py


示例16: create_models

    def create_models(self):
        TestCase.create_models(self)

        class TextMultiItem(self.Base):
            __tablename__ = 'textmultiitem'

            id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)

            name = sa.Column(sa.Unicode(255))
            content = sa.Column(sa.UnicodeText)
            name_vector = sa.Column(TSVectorType('name'))
            content_vector = sa.Column(TSVectorType('content'))

        self.TextMultiItem = TextMultiItem
开发者ID:deviba01,项目名称:SkillsConnect,代码行数:14,代码来源:test_multiple_vectors_per_class.py


示例17: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)

        self.app.add_url_rule('/users/<int:id>',
            view_func=UpdateView.as_view('update',
            model_class=self.User,
            validator=lambda a: a),
        )
        self.app.add_url_rule('/users/<int:id>',
            view_func=ShowView.as_view('user.show', model_class=self.User)
        )
        user = self.User(name=u'John Matrix')
        self.db.session.add(user)
        self.db.session.commit()
开发者ID:kvesteri,项目名称:flask-generic-views,代码行数:14,代码来源:test_update_view.py


示例18: setup_method

    def setup_method(self, method):
        @sa.event.listens_for(sa.orm.Session, 'before_flush')
        def before_flush(session, ctx, instances):
            for obj in session.dirty:
                obj.name = u'Updated article'

        self.before_flush = before_flush

        TestCase.setup_method(self, method)
        self.article = self.Article()
        self.article.name = u'Some article'
        self.article.content = u'Some content'
        self.session.add(self.article)
        self.session.commit()
开发者ID:adamchainz,项目名称:sqlalchemy-continuum,代码行数:14,代码来源:test_exotic_listener_chaining.py


示例19: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.app = Flask(__name__)
        self.app.secret_key = 'secret'
        self.app.debug = True
        self.setup_views()
        login_manager = LoginManager()
        login_manager.init_app(self.app)
        self.client = self.app.test_client()
        self.context = self.app.test_request_context()
        self.context.push()

        @login_manager.user_loader
        def load_user(id):
            return self.session.query(self.User).get(id)
开发者ID:FelixLoether,项目名称:sqlalchemy-continuum,代码行数:15,代码来源:test_flask.py


示例20: setup_method

    def setup_method(self, method):
        TestCase.setup_method(self, method)
        self.equipment = [
            self.Equipment(
                id=2, name=u'E 1',
            ),
            self.Equipment(
                id=4, name=u'E 2',
            ),
            self.Equipment(
                id=6, name=u'E 3',
            ),
            self.Equipment(
                id=8, name=u'E 4',
            ),
        ]
        self.buildings = [
            self.Building(id=12, name=u'B 1', equipment=self.equipment[0]),
            self.Building(id=15, name=u'B 2', equipment=self.equipment[1]),
            self.Building(id=19, name=u'B 3'),
        ]
        self.business_premises = [
            self.BusinessPremise(
                id=22,
                name=u'BP 1',
                building=self.buildings[0]
            ),
            self.BusinessPremise(
                id=33,
                name=u'BP 2',
                building=self.buildings[0],
                equipment=self.equipment[2]
            ),
            self.BusinessPremise(
                id=44,
                name=u'BP 3',
                building=self.buildings[2],
                equipment=self.equipment[1]
            ),
        ]

        self.session.add_all(self.buildings)
        self.session.add_all(self.business_premises)
        self.session.add_all(self.equipment)
        self.session.commit()
开发者ID:akash01,项目名称:blog-flask,代码行数:45,代码来源:test_compound_fetching.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python Nbdata.NetworkData类代码示例发布时间:2022-05-27
下一篇:
Python tests.Test类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap