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

Python tools.assert_is_not_none函数代码示例

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

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



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

示例1: test_has_required_lazy

def test_has_required_lazy():
    m = hdf5storage.Marshallers.TypeMarshaller()
    m.required_parent_modules = ['json']
    m.required_modules = ['json']
    m.python_type_strings = ['ellipsis']
    m.types = ["<type '" + s + "'>" for s in m.python_type_strings]
    for name in m.required_modules:
        assert_not_in(name, sys.modules)
    mc = hdf5storage.MarshallerCollection(lazy_loading=True,
                                          marshallers=[m])
    for name in m.required_modules:
        assert_not_in(name, sys.modules)
    assert mc._has_required_modules[-1]
    assert_false(mc._imported_required_modules[-1])
    mback, has_modules = mc.get_marshaller_for_type_string( \
        m.python_type_strings[0])
    assert_is_not_none(mback)
    assert has_modules
    assert mc._has_required_modules[-1]
    assert mc._imported_required_modules[-1]
    for name in m.required_modules:
        assert_in(name, sys.modules)

    # Do it again, but this time the modules are already loaded so that
    # flag should be set.
    mc = hdf5storage.MarshallerCollection(lazy_loading=True,
                                          marshallers=[m])
    assert mc._has_required_modules[-1]
    assert mc._imported_required_modules[-1]
    mback, has_modules = mc.get_marshaller_for_type_string( \
        m.python_type_strings[0])
    assert_is_not_none(mback)
    assert has_modules
    assert mc._has_required_modules[-1]
    assert mc._imported_required_modules[-1]
开发者ID:sungjinlees,项目名称:hdf5storage,代码行数:35,代码来源:test_marshallers_requiring_modules.py


示例2: test_teams

def test_teams():
    name = "My Uniquely Named Team " + str(uuid.uuid4())
    team = syn.store(Team(name=name, description="A fake team for testing..."))
    schedule_for_cleanup(team)

    found_team = syn.getTeam(team.id)
    assert_equals(team, found_team)

    p = syn.getUserProfile()
    found = None
    for m in syn.getTeamMembers(team):
        if m.member.ownerId == p.ownerId:
            found = m
            break

    assert_is_not_none(found, "Couldn't find user {} in team".format(p.userName))

    # needs to be retried 'cause appending to the search index is asynchronous
    tries = 10
    found_team = None
    while tries > 0:
        try:
            found_team = syn.getTeam(name)
            break
        except ValueError:
            tries -= 1
            if tries > 0:
                time.sleep(1)
    assert_equals(team, found_team)
开发者ID:Sage-Bionetworks,项目名称:synapsePythonClient,代码行数:29,代码来源:test_evaluations.py


示例3: test_learning_curve_from_dir

 def test_learning_curve_from_dir(self):
     
     lc = LearningCurveFromPath(os.path.split(self.fpath)[0])
     assert_is_not_none(lc)
     train_keys, test_keys = lc.parse()
     assert_list_equal(train_keys, ['NumIters', 'Seconds', 'LearningRate', 'loss'])
     assert_list_equal(test_keys, ['NumIters', 'Seconds', 'LearningRate', 'accuracy', 'loss'])
开发者ID:kashefytest,项目名称:caffe_sandbox,代码行数:7,代码来源:test_learning_curve.py


示例4: test_write_batch

def test_write_batch():
    with tmp_db('write_batch') as db:
        # Prepare a batch with some data
        batch = db.write_batch()
        for i in xrange(1000):
            batch.put(('batch-key-%d' % i).encode('UTF-8'), b'value')

        # Delete a key that was also set in the same (pending) batch
        batch.delete(b'batch-key-2')

        # The DB should not have any data before the batch is written
        assert_is_none(db.get(b'batch-key-1'))

        # ...but it should have data afterwards
        batch.write()
        assert_is_not_none(db.get(b'batch-key-1'))
        assert_is_none(db.get(b'batch-key-2'))

        # Batches can be cleared
        batch = db.write_batch()
        batch.put(b'this-is-never-saved', b'')
        batch.clear()
        batch.write()
        assert_is_none(db.get(b'this-is-never-saved'))

        # Batches take write options
        batch = db.write_batch(sync=True)
        batch.put(b'batch-key-sync', b'')
        batch.write()
开发者ID:ecdsa,项目名称:plyvel,代码行数:29,代码来源:test_plyvel.py


示例5: i_create_a_local_prediction_op_kind

def i_create_a_local_prediction_op_kind(step, data=None, operating_kind=None):
    if data is None:
        data = "{}"
    assert_is_not_none(operating_kind)
    data = json.loads(data)
    world.local_prediction = world.local_model.predict( \
        data, operating_kind=operating_kind)
开发者ID:javinp,项目名称:python,代码行数:7,代码来源:compare_predictions_steps.py


示例6: _check_third_party_result_for_approved_user

 def _check_third_party_result_for_approved_user(application_pk_id):
     with DBHelper() as db_helper:
         ret = db_helper.get_third_party_result_by_type(VerifyThirdPartyTypeEnum.JUXINLI_IDCARD, application_pk_id)
     tools.assert_is_not_none(ret)
     tools.assert_equal(2, len(ret))
     tools.assert_equal(ret[0], "EXCHANGE_SUCCESS")
     tools.assert_equal(ret[1], """{"error_code":"31200","error_msg":"此人不在黑名单","result":"{}"}""")
开发者ID:liupeng330,项目名称:robot_framework,代码行数:7,代码来源:TestVerifyJob.py


示例7: __test_save_article

    def __test_save_article(self):
        self.skr_article_data['title'] = compare_title
        self.skr_article_data['content'] = compare_content
        data = json.dumps(self.skr_article_data)
        response = test_app.post('/api/v1/article',
                                 data=data,
                                 content_type='application/json')
        tools.assert_equals(response.status_code, 200)

        json_resp = json.loads(response.data)
        tools.assert_equals(response.status_code, 200)
        tools.assert_is_not_none(json_resp.get('data'))
        tools.assert_is_not_none(json_resp.get('data').get('source'))

        self.tech_article_data['title'] = test_title
        self.tech_article_data['content'] = test_content
        data = json.dumps(self.tech_article_data)
        response = test_app.post('/api/v1/article',
                                 data=data,
                                 content_type='application/json')
        tools.assert_equals(response.status_code, 200)

        self.tesla_article_data['title'] = test_title
        self.tesla_article_data['content'] = test_content
        data = json.dumps(self.tesla_article_data)
        response = test_app.post('/api/v1/article',
                                 data=data,
                                 content_type='application/json')
        tools.assert_equals(response.status_code, 200)

        self.article_url_list.append(self.skr_article_data['url'])
        self.article_url_list.append(self.tech_article_data['url'])
        self.article_url_list.append(self.tesla_article_data['url'])
开发者ID:charlieyyy,项目名称:News-Cluster-Algorithm,代码行数:33,代码来源:test_cluster.py


示例8: _test_format_change

 def _test_format_change(self, to_format):
     controller = self._get_file_controller(MINIMAL_SUITE_PATH)
     assert_is_not_none(controller)
     controller.save_with_new_format(to_format)
     self._assert_removed(MINIMAL_SUITE_PATH)
     path_with_tsv = os.path.splitext(MINIMAL_SUITE_PATH)[0] + '.'+to_format
     self._assert_serialized(path_with_tsv)
开发者ID:HelioGuilherme66,项目名称:RIDE,代码行数:7,代码来源:test_format_change.py


示例9: test_correct

def test_correct():
    """Tests the valid overall process."""
    tmp = NamedTemporaryFile()
    tmp.write("ValidFaultTree\n\n")
    tmp.write("root := g1 | g2 | g3 | g4 | g7 | e1\n")
    tmp.write("g1 := e2 & g3 & g5\n")
    tmp.write("g2 := h1 & g6\n")
    tmp.write("g3 := (g6 ^ e2)\n")
    tmp.write("g4 := @(2, [g5, e3, e4])\n")
    tmp.write("g5 := ~(e3)\n")
    tmp.write("g6 := (e3 | e4)\n\n")
    tmp.write("g7 := g8\n\n")
    tmp.write("g8 := ~e2 & ~e3\n\n")
    tmp.write("p(e1) = 0.1\n")
    tmp.write("p(e2) = 0.2\n")
    tmp.write("p(e3) = 0.3\n")
    tmp.write("s(h1) = true\n")
    tmp.write("s(h2) = false\n")
    tmp.flush()
    fault_tree = parse_input_file(tmp.name)
    assert_is_not_none(fault_tree)
    yield assert_equal, 9, len(fault_tree.gates)
    yield assert_equal, 3, len(fault_tree.basic_events)
    yield assert_equal, 2, len(fault_tree.house_events)
    yield assert_equal, 1, len(fault_tree.undefined_events())
    out = NamedTemporaryFile()
    out.write("<?xml version=\"1.0\"?>\n")
    out.write(fault_tree.to_xml())
    out.flush()
    relaxng_doc = etree.parse("../share/input.rng")
    relaxng = etree.RelaxNG(relaxng_doc)
    with open(out.name, "r") as test_file:
        doc = etree.parse(test_file)
        assert_true(relaxng.validate(doc))
开发者ID:kdm04,项目名称:scram,代码行数:34,代码来源:test_shorthand_to_xml.py


示例10: test_cluster_get

    def test_cluster_get(self):
        """
        测试cluster的get接口

        """

        service = ClusterService('2018/08/15')
        service.save_to_db()

        response = test_app.get('/api/v1/cluster?day=20180815')
        tools.assert_equals(response.status_code, 200)

        json_resp = json.loads(response.data)
        tools.assert_equals(response.status_code, 200)
        tools.assert_is_not_none(json_resp.get('data'))
        data = json_resp.get('data')
        tools.assert_equals(len(data), 2)
        news = data[0]['news']
        tools.assert_equals(data[0]['topic']['title'], news[0]['title'])
        tools.assert_equals(news[0]['title'], news[1]['title'])
        first_topic = data[0]['topic']['title']
        second_topic = data[1]['topic']['title']

        # test update cluster, topic unchanged
        self.skr_article_data['title'] = compare_title
        self.skr_article_data['content'] = compare_content
        self.skr_article_data['url'] = 'http://www.skr.net/yeah/'
        data = json.dumps(self.skr_article_data)
        response = test_app.post('/api/v1/article',
                                 data=data,
                                 content_type='application/json')
        tools.assert_equals(response.status_code, 200)

        service = ClusterService('2018/08/15')
        service.save_to_db()

        response = test_app.get('/api/v1/cluster?day=20180815')
        tools.assert_equals(response.status_code, 200)

        json_resp = json.loads(response.data)
        tools.assert_equals(response.status_code, 200)
        tools.assert_is_not_none(json_resp.get('data'))
        data = json_resp.get('data')
        tools.assert_equals(len(data), 2)

        tools.assert_equals(first_topic, data[0]['topic']['title'])
        tools.assert_equals(second_topic, data[1]['topic']['title'])

        news = data[0]['news']
        tools.assert_equals(data[0]['topic']['title'], news[0]['title'])
        tools.assert_equals(news[0]['title'], news[1]['title'])

        news = data[1]['news']
        tools.assert_equals(data[1]['topic']['title'], news[0]['title'])
        tools.assert_equals(news[0]['title'], news[1]['title'])

        # test length of cluster is correct
        news_count = data[0]['news_count']
        tools.assert_equals(news_count, 2)
        self.__test_send_mail()
开发者ID:charlieyyy,项目名称:News-Cluster-Algorithm,代码行数:60,代码来源:test_cluster.py


示例11: test_doi_config

    def test_doi_config(self):

        account_name = config.get("ckanext.doi.account_name")
        account_password = config.get("ckanext.doi.account_password")

        assert_is_not_none(account_name)
        assert_is_not_none(account_password)
开发者ID:spacelis,项目名称:ckan-ckanext-doi,代码行数:7,代码来源:test_doi.py


示例12: test_simple_origin_matching_on_not_first_origin

    def test_simple_origin_matching_on_not_first_origin(self):
        checker = OriginAuthentication()
        client_auth = checker.check_origin_permission('http://localhost:8000', self.dataset)

        assert_is_not_none(client_auth)
        assert_true(isinstance(client_auth, tuple))
        assert_equal(len(client_auth), 2)
开发者ID:CrowdSpot,项目名称:crowdspot-vagrant-box,代码行数:7,代码来源:tests.py


示例13: test_chorus_dois

    def test_chorus_dois(self, test_data):

        doi = test_data

        # because cookies breaks the cache pickling
        # for doi_start in ["10.1109", "10.1161", "10.1093", "10.1007", "10.1039"]:
        #     if doi.startswith(doi_start):
        requests_cache.uninstall_cache()

        my_pub = pub.lookup_product_by_doi(doi)
        if not my_pub:
            logger.info(u"doi {} not in db, skipping".format(doi))
            return
        my_pub.refresh()

        logger.info(u"https://api.unpaywall.org/v2/{}?email=me".format(doi))
        logger.info(u"doi: https://doi.org/{}".format(doi))
        logger.info(u"license: {}".format(my_pub.best_license))
        logger.info(u"evidence: {}".format(my_pub.best_evidence))
        logger.info(u"host: {}".format(my_pub.best_host))
        if my_pub.error:
            logger.info(my_pub.error)

        assert_equals(my_pub.error, "")
        assert_is_not_none(my_pub.fulltext_url)
开发者ID:Impactstory,项目名称:sherlockoa,代码行数:25,代码来源:test_publication.py


示例14: test_elements_all_plugin_properties

    def test_elements_all_plugin_properties(self):
        page = factories.PageFactory()
        concept = factories.ConceptFactory()
        Element.objects.create(
            display_index=0,
            element_type='PLUGIN',
            concept=concept,
            question='test question',
            answer='',
            required=True,
            image='test',
            audio='ping',
            action='action',
            mime_type='text/javascript',
            page=page
        )

        element = Element.objects.get(concept=concept)

        assert_equals(element.display_index, 0)
        assert_equals(element.element_type, 'PLUGIN')
        assert_equals(element.concept, concept)
        assert_equals(element.question, 'test question')
        assert_equals(element.answer, '')
        assert_equals(element.page, page)
        assert_true(element.required)
        assert_equals(element.image, 'test')
        assert_equals(element.audio, 'ping')
        assert_equals(element.action, 'action')
        assert_equals(element.mime_type, 'text/javascript')
        assert_is_not_none(element.last_modified, None)
        assert_is_not_none(element.created, None)
开发者ID:SanaMobile,项目名称:sana.protocol_builder,代码行数:32,代码来源:test_model_element.py


示例15: test_sql

    def test_sql(self):
        thing = self.magics.sql('-r -f select * from blah where something = 1')
        nt.assert_is_not_none(thing)  # uhm, not sure what to check...
        lst = [{'x': 'y'}, {'e': 'f'}]
        d = {'a': 'b'}
        dct = {
            'zzz': d,
            'yyy': lst
        }

        # params and multiparams
        ret = self.ipydb.execute.return_value
        ret.returns_rows = True
        self.ipython.user_ns = dct
        self.magics.sql('-a zzz -m yyy select * from foo')
        self.ipydb.execute.assert_called_with(
            'select * from foo',
            params=d, multiparams=lst)

        ret.returns_rows = False
        ret.rowount = 2
        self.magics.sql('-a zzz -m yyy select * from foo')

        r = self.magics.sql('-r select * from foo')
        nt.assert_equal(ret, r)
开发者ID:jaysw,项目名称:ipydb,代码行数:25,代码来源:test_magic.py


示例16: test2

    def test2(self):
        """
        it should return a error if an invalid path was given
        """

        ### make requset with invalid path ###

        request = tornado.httpclient.HTTPRequest(\
            url=self.get_url('/document/admin/administrator/invalid/path'),\
            method="GET",
            )

        # wait for response
        self.http_client.fetch(request, self.stop)
        response = self.wait()


        # reason shold be Bad Request
        assert_equals(response.reason,'Bad Request')

        # there where errors
        assert_is_not_none(response.error)

        # it should return this error messsage
        assert_equals(response.body,'tornado threw an exception')
开发者ID:paprockiw,项目名称:dra-tornado,代码行数:25,代码来源:document_test.py


示例17: test_synStore_sftpIntegration

def test_synStore_sftpIntegration():
    """Creates a File Entity on an sftp server and add the external url. """
    filepath = utils.make_bogus_binary_file(1 * MB - 777771)
    try:
        file = syn.store(File(filepath, parent=project))
        file2 = syn.get(file)
        assert file.externalURL == file2.externalURL and urlparse(file2.externalURL).scheme == "sftp"

        tmpdir = tempfile.mkdtemp()
        schedule_for_cleanup(tmpdir)

        ## test filename override
        file2.fileNameOverride = "whats_new_in_baltimore.data"
        file2 = syn.store(file2)
        ## TODO We haven't defined how filename override interacts with
        ## TODO previously cached files so, side-step that for now by
        ## TODO making sure the file is not in the cache!
        syn.cache.remove(file2.dataFileHandleId, delete=True)
        file3 = syn.get(file, downloadLocation=tmpdir)
        assert os.path.basename(file3.path) == file2.fileNameOverride

        ## test that we got an MD5 à la SYNPY-185
        assert_is_not_none(file3.md5)
        fh = syn._getFileHandle(file3.dataFileHandleId)
        assert_is_not_none(fh["contentMd5"])
        assert_equals(file3.md5, fh["contentMd5"])
    finally:
        try:
            os.remove(filepath)
        except Exception:
            print(traceback.format_exc())
开发者ID:thomasyu888,项目名称:synapsePythonClient,代码行数:31,代码来源:test_sftp_upload.py


示例18: i_create_a_local_ensemble_prediction_op

def i_create_a_local_ensemble_prediction_op(step, data=None, operating_point=None):
    if data is None:
        data = "{}"
    assert_is_not_none(operating_point)
    data = json.loads(data)
    world.local_prediction = world.local_ensemble.predict( \
        data, operating_point=operating_point)
开发者ID:javinp,项目名称:python,代码行数:7,代码来源:compare_predictions_steps.py


示例19: test_which

 def test_which(self):
     python_path = which.which('python')
     assert_is_not_none(python_path, 'python is not discovered in the'
                                     ' executable path')
     bogus_path = which.which('bogus')
     assert_is_none(bogus_path, "bogus is found in the executable path"
                                " at: %s" % bogus_path)
开发者ID:ohsu-qin,项目名称:qiutil,代码行数:7,代码来源:test_which.py


示例20: test_customers_create

def test_customers_create():
    fixture = helpers.load_fixture('customers')['create']
    helpers.stub_response(fixture)
    response = helpers.client.customers.create(*fixture['url_params'])
    body = fixture['body']['customers']

    assert_is_instance(response, resources.Customer)
    assert_is_not_none(responses.calls[-1].request.headers.get('Idempotency-Key'))
    assert_equal(response.address_line1, body.get('address_line1'))
    assert_equal(response.address_line2, body.get('address_line2'))
    assert_equal(response.address_line3, body.get('address_line3'))
    assert_equal(response.city, body.get('city'))
    assert_equal(response.company_name, body.get('company_name'))
    assert_equal(response.country_code, body.get('country_code'))
    assert_equal(response.created_at, body.get('created_at'))
    assert_equal(response.danish_identity_number, body.get('danish_identity_number'))
    assert_equal(response.email, body.get('email'))
    assert_equal(response.family_name, body.get('family_name'))
    assert_equal(response.given_name, body.get('given_name'))
    assert_equal(response.id, body.get('id'))
    assert_equal(response.language, body.get('language'))
    assert_equal(response.metadata, body.get('metadata'))
    assert_equal(response.phone_number, body.get('phone_number'))
    assert_equal(response.postal_code, body.get('postal_code'))
    assert_equal(response.region, body.get('region'))
    assert_equal(response.swedish_identity_number, body.get('swedish_identity_number'))
开发者ID:gocardless,项目名称:gocardless-pro-python,代码行数:26,代码来源:customers_integration_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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