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


Python tools.assert_is_not_none函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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