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

Python tools.assert_equals函数代码示例

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

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



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

示例1: test_edit_issue

    def test_edit_issue(self):
        # goto issue show page
        env = {'REMOTE_USER': self.owner['name'].encode('ascii')}
        response = self.app.get(
            url=toolkit.url_for('issues_show',
                                dataset_id=self.dataset['id'],
                                issue_number=self.issue['number']),
            extra_environ=env,
        )
        # click the edit link
        response = response.click(linkid='issue-edit-link', extra_environ=env)
        # fill in the form
        form = response.forms['issue-edit']
        form['title'] = 'edited title'
        form['description'] = 'edited description'
        # save the form
        response = helpers.webtest_submit(form, 'save', extra_environ=env)
        response = response.follow()
        # make sure it all worked
        assert_in('edited title', response)
        assert_in('edited description', response)

        result = helpers.call_action('issue_show',
                                     dataset_id=self.dataset['id'],
                                     issue_number=self.issue['number'])
        assert_equals(u'edited title', result['title'])
        assert_equals(u'edited description', result['description'])
开发者ID:SaintRamzes,项目名称:ckanext-issues,代码行数:27,代码来源:test_edit.py


示例2: test_get_many_objects

    def test_get_many_objects(self):
        ct_ct = ContentType.objects.get_for_model(ContentType)
        site_ct = ContentType.objects.get_for_model(Site)

        objs = utils.get_cached_objects([(ct_ct.id, ct_ct.id), (ct_ct.id, site_ct.id), (site_ct.id, 1)])

        tools.assert_equals([ct_ct, site_ct, Site.objects.get(pk=1)], objs)
开发者ID:MikeLing,项目名称:ella,代码行数:7,代码来源:test_cache.py


示例3: test_after_each_step_is_executed_before_each_step

def test_after_each_step_is_executed_before_each_step():
    "terrain.before.each_step and terrain.after.each_step decorators"
    world.step_states = []
    @before.each_step
    def set_state_to_before(step):
        world.step_states.append('before')
        expected = 'Given I append "during" to states'
        if step.sentence != expected:
            raise TypeError('%r != %r' % (step.sentence, expected))

    @step('append "during" to states')
    def append_during_to_step_states(step):
        world.step_states.append("during")

    @after.each_step
    def set_state_to_after(step):
        world.step_states.append('after')
        expected = 'Given I append "during" to states'
        if step.sentence != expected:
            raise TypeError('%r != %r' % (step.sentence, expected))

    feature = Feature.from_string(FEATURE1)
    feature.run()

    assert_equals(world.step_states, ['before', 'during', 'after'])
开发者ID:DominikGuzei,项目名称:lettuce,代码行数:25,代码来源:test_terrain.py


示例4: test_role_user_state3_perms

    def test_role_user_state3_perms(self):
        """
        Testing user permission in state3.
        """
        api_key = self.__login("user", "pass3")
        headers = self.__build_headers("user", api_key)

        test_author = Author.objects.create(id=100, name="dumb_name")

        set_state(test_author, self.state3)

        response = self.client.post("/admin-api/author/", data=self.new_author,
            content_type='application/json', **headers)
        tools.assert_equals(response.status_code, 201)

        response = self.client.get("/admin-api/author/100/", **headers)
        tools.assert_equals(response.status_code, 200)

        response = self.client.put("/admin-api/author/100/", data=self.new_author,
            content_type='application/json', **headers)
        tools.assert_equals(response.status_code, 401)

        response = self.client.patch("/admin-api/author/100/", data=self.new_author,
            content_type='application/json', **headers)
        tools.assert_equals(response.status_code, 401)

        response = self.client.delete("/admin-api/author/100/", **headers)
        tools.assert_equals(response.status_code, 401)

        self.__logout(headers)
开发者ID:SanomaCZ,项目名称:ella-hub,代码行数:30,代码来源:test_authorization.py


示例5: test_create_object_from_doc

    def test_create_object_from_doc(self):
        new_object = provider_batch_data.create_objects_from_doc(self.old_doc)

        matching = ProviderBatchData.query.filter_by(provider="pmc").first()
        assert_equals(matching.provider, "pmc")

        assert_equals(matching.aliases, self.old_doc["aliases"])
开发者ID:Impactstory,项目名称:total-impact-core,代码行数:7,代码来源:test_provider_batch_data.py


示例6: test_class_tags

def test_class_tags():
    xblock = XBlock(None, None)
    assert_equals(xblock._class_tags, set())

    class Sub1Block(XBlock):
        pass

    sub1block = Sub1Block(None, None)
    assert_equals(sub1block._class_tags, set())

    @XBlock.tag("cat dog")
    class Sub2Block(Sub1Block):
        pass

    sub2block = Sub2Block(None, None)
    assert_equals(sub2block._class_tags, set(["cat", "dog"]))

    class Sub3Block(Sub2Block):
        pass

    sub3block = Sub3Block(None, None)
    assert_equals(sub3block._class_tags, set(["cat", "dog"]))

    @XBlock.tag("mixin")
    class MixinBlock(XBlock):
        pass

    class Sub4Block(MixinBlock, Sub3Block):
        pass

    sub4block = Sub4Block(None, None)
    assert_equals(sub4block._class_tags, set(["cat", "dog", "mixin"]))
开发者ID:AkademieOlympia,项目名称:XBlock,代码行数:32,代码来源:test_core.py


示例7: test_import_class

def test_import_class():
    assert_raises(ImproperlyConfigured, import_class,
                  'rapidsms.tests.router.test_base.BadClassName')
    assert_raises(ImproperlyConfigured, import_class,
                  'rapidsms.tests.router.bad_module.MockRouter')
    assert_equals(import_class('rapidsms.tests.router.test_base.MockRouter'),
                  MockRouter)
开发者ID:cheekybastard,项目名称:rapidsms,代码行数:7,代码来源:test_base.py


示例8: test_indentation

def test_indentation():
    """Test correct indentation in groups"""
    count = 40
    gotoutput = pretty.pretty(MyList(range(count)))
    expectedoutput = "MyList(\n" + ",\n".join("   %d" % i for i in range(count)) + ")"

    nt.assert_equals(gotoutput, expectedoutput)
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:7,代码来源:test_pretty.py


示例9: check_triangulation

def check_triangulation(embedding, expected_embedding):
    res_embedding, _ = triangulate_embedding(embedding, True)
    assert_equals(res_embedding.get_data(), expected_embedding,
                  "Expected embedding incorrect")
    res_embedding, _ = triangulate_embedding(embedding, False)
    assert_equals(res_embedding.get_data(), expected_embedding,
                  "Expected embedding incorrect")
开发者ID:networkx,项目名称:networkx,代码行数:7,代码来源:test_planar_drawing.py


示例10: test_render_any_markup_formatting

def test_render_any_markup_formatting():
    assert_equals(h.render_any_markup('README.md', '### foo\n'
                                      '    <script>alert(1)</script> bar'),
                  '<div class="markdown_content"><h3 id="foo">foo</h3>\n'
                  '<div class="codehilite"><pre><span class="nt">'
                  '&lt;script&gt;</span>alert(1)<span class="nt">'
                  '&lt;/script&gt;</span> bar\n</pre></div>\n\n</div>')
开发者ID:abhinavthomas,项目名称:allura,代码行数:7,代码来源:test_helpers.py


示例11: test_package_create

 def test_package_create(self):
     idf.plugin_v4.create_country_codes()
     result = helpers.call_action('package_create', name='test_package',
                                  custom_text='this is my custom text',
                                  country_code='uk')
     nt.assert_equals('this is my custom text', result['custom_text'])
     nt.assert_equals([u'uk'], result['country_code'])
开发者ID:6779660,项目名称:ckan,代码行数:7,代码来源:test_example_idatasetform.py


示例12: test_storage_url_not_exists

def test_storage_url_not_exists(mock_storage):
    mock_storage.exists.return_value = False
    mock_storage.url.return_value = '/static/data_dir/file.png'

    assert_equals('"/static/data_dir/file.png"', replace_static_urls(STATIC_SOURCE, DATA_DIRECTORY))
    mock_storage.exists.assert_called_once_with('file.png')
    mock_storage.url.assert_called_once_with('data_dir/file.png')
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:7,代码来源:test_static_replace.py


示例13: test_process_url_data_dir_exists

def test_process_url_data_dir_exists():
    base = '"/static/{data_dir}/file.png"'.format(data_dir=DATA_DIRECTORY)

    def processor(original, prefix, quote, rest):  # pylint: disable=unused-argument,missing-docstring
        return quote + 'test' + rest + quote

    assert_equals(base, process_static_urls(base, processor, data_dir=DATA_DIRECTORY))
开发者ID:Certific-NET,项目名称:edx-platform,代码行数:7,代码来源:test_static_replace.py


示例14: check_inheritable_attribute

    def check_inheritable_attribute(self, attribute, value):
        # `attribute` isn't a basic attribute of Sequence
        assert_false(hasattr(SequenceDescriptor, attribute))

        # `attribute` is added by InheritanceMixin
        assert_true(hasattr(InheritanceMixin, attribute))

        root = SequenceFactory.build(policy={attribute: str(value)})
        ProblemFactory.build(parent=root)

        # InheritanceMixin will be used when processing the XML
        assert_in(InheritanceMixin, root.xblock_mixins)

        seq = self.process_xml(root)

        assert_equals(seq.unmixed_class, SequenceDescriptor)
        assert_not_equals(type(seq), SequenceDescriptor)

        # `attribute` is added to the constructed sequence, because
        # it's in the InheritanceMixin
        assert_equals(value, getattr(seq, attribute))

        # `attribute` is a known attribute, so we shouldn't include it
        # in xml_attributes
        assert_not_in(attribute, seq.xml_attributes)
开发者ID:bryanlandia,项目名称:edx-platform,代码行数:25,代码来源:test_xml_module.py


示例15: test_serialize

    def test_serialize(self):
        """Objects are serialized to JSON-compatible objects"""

        def epoch(obj):
            """Convert to JS Epoch time"""
            return int(time.mktime(obj.timetuple())) * 1000

        types = [('test', str, 'test'),
                 (pd.Timestamp('2013-06-08'), int,
                  epoch(pd.Timestamp('2013-06-08'))),
                 (datetime.utcnow(), int, epoch(datetime.utcnow())),
                 (1, int, 1),
                 (1.0, float, 1.0),
                 (np.float32(1), float, 1.0),
                 (np.int32(1), int, 1),
                 (np.float64(1), float, 1.0),
                 (np.int64(1), int, 1)]

        for puts, pytype, gets in types:
            nt.assert_equal(Data.serialize(puts), gets)

        class BadType(object):
            """Bad object for type warning"""

        test_obj = BadType()
        with nt.assert_raises(LoadError) as err:
            Data.serialize(test_obj)
        nt.assert_equals(err.exception.message,
                         'cannot serialize index of type BadType')
开发者ID:brinkar,项目名称:vincent,代码行数:29,代码来源:test_vega.py


示例16: test_maxi_savings_account

def test_maxi_savings_account():
    bank = Bank()
    checkingAccount = Account(MAXI_SAVINGS)
    bank.addCustomer(Customer("Bill").openAccount(checkingAccount))
    year_behind = datetime.datetime.now() - datetime.timedelta(365)
    checkingAccount.deposit(3000.0, year_behind)
    assert_equals(bank.totalInterestPaid(), 150.0)
开发者ID:igors123998,项目名称:abc-bank-python,代码行数:7,代码来源:bank_tests.py


示例17: test_115

def test_115(connpath):
    v = connect(connpath, await_params=True)

    # Dummy callback
    def mavlink_callback(*args):
        mavlink_callback.count += 1
    mavlink_callback.count = 0

    # Set the callback.
    v.set_mavlink_callback(mavlink_callback)

    # Change the vehicle into STABILIZE mode
    v.mode = VehicleMode("STABILIZE")
    # NOTE wait crudely for ACK on mode update
    time.sleep(3)

    # Expect the callback to have been called
    assert mavlink_callback.count > 0

    # Unset the callback.
    v.unset_mavlink_callback()
    savecount = mavlink_callback.count

    # Disarm. A callback of None should not throw errors
    v.armed = False
    # NOTE wait crudely for ACK on mode update
    time.sleep(3)

    # Expect the callback to have been called
    assert_equals(savecount, mavlink_callback.count)

    # Re-arm should not throw errors.
    v.armed = True
    # NOTE wait crudely for ACK on mode update
    time.sleep(3)
开发者ID:BimoBimo,项目名称:dronekit-python,代码行数:35,代码来源:test_115.py


示例18: test_autocall_binops

def test_autocall_binops():
    """See https://github.com/ipython/ipython/issues/81"""
    ip.magic('autocall 2')
    f = lambda x: x
    ip.user_ns['f'] = f
    try:
        yield nt.assert_equals(ip.prefilter('f 1'),'f(1)')
        for t in ['f +1', 'f -1']:
            yield nt.assert_equals(ip.prefilter(t), t)

        # Run tests again with a more permissive exclude_regexp, which will
        # allow transformation of binary operations ('f -1' -> 'f(-1)').
        pm = ip.prefilter_manager
        ac = AutocallChecker(shell=pm.shell, prefilter_manager=pm,
                             config=pm.config)
        try:
            ac.priority = 1
            ac.exclude_regexp = r'^[,&^\|\*/]|^is |^not |^in |^and |^or '
            pm.sort_checkers()

            yield nt.assert_equals(ip.prefilter('f -1'), 'f(-1)')
            yield nt.assert_equals(ip.prefilter('f +1'), 'f(+1)')
        finally:
            pm.unregister_checker(ac)
    finally:
        ip.magic('autocall 0')
        del ip.user_ns['f']
开发者ID:123jefferson,项目名称:MiniBloq-Sparki,代码行数:27,代码来源:test_prefilter.py


示例19: test_children_metaclass

def test_children_metaclass():

    class HasChildren(object):
        __metaclass__ = ChildrenModelMetaclass

        has_children = True

    class WithoutChildren(object):
        __metaclass__ = ChildrenModelMetaclass

    class InheritedChildren(HasChildren):
        pass

    assert HasChildren.has_children
    assert not WithoutChildren.has_children
    assert InheritedChildren.has_children

    assert hasattr(HasChildren, 'children')
    assert not hasattr(WithoutChildren, 'children')
    assert hasattr(InheritedChildren, 'children')

    assert isinstance(HasChildren.children, List)
    assert_equals(Scope.children, HasChildren.children.scope)
    assert isinstance(InheritedChildren.children, List)
    assert_equals(Scope.children, InheritedChildren.children.scope)
开发者ID:AkademieOlympia,项目名称:XBlock,代码行数:25,代码来源:test_core.py


示例20: test_multi_set

 def test_multi_set(self):
     params = {
         'aa':1,
         'bb':2,
         'cc':3,
         'dd':4,
     }
     a = self.client.multi_set(**params)
     assert_equals(a,4)
     b = self.client.get('aa')
     assert_equals(b,'1')
     b = self.client.get('bb')
     assert_equals(b,'2')
     b = self.client.get('cc')
     assert_equals(b,'3')
     b = self.client.get('dd')
     assert_equals(b,'4')                        
     d = self.client.delete('aa')
     assert_true(d)
     d = self.client.delete('bb')
     assert_true(d)        
     d = self.client.delete('cc')
     assert_true(d)        
     d = self.client.delete('dd')
     assert_true(d)
开发者ID:qwang2505,项目名称:ssdb-py,代码行数:25,代码来源:test_client.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tools.assert_false函数代码示例发布时间:2022-05-27
下一篇:
Python tools.assert_equal函数代码示例发布时间: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