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

Python specter.expect函数代码示例

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

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



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

示例1: can_update

    def can_update(self):
        model = TestModel()
        model.thing = 'bam'

        model.update(thing='other')

        expect(model.thing).to.equal('other')
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:7,代码来源:helpers.py


示例2: should_take_into_account_conditional_probability

            def should_take_into_account_conditional_probability(self):
                user_tz = ['Eastern (US & Canada)', 'Pacific (US & Canada)']
                l1_time = [9, 9]
                l1_day = [0, 1]
                l2_time = [9, 9]
                l2_day = [3, 4]
                l3_time = [None, 9]
                l3_day = [None, 5]
                schedule_type = [2, 3]

                training_data = pd.DataFrame({ 'user_tz': user_tz,
                    'l1_time': l1_time,
                    'l1_day': l1_day,
                    'l2_time': l2_time,
                    'l2_day': l2_day,
                    'l3_time': l3_time,
                    'l3_day': l3_day,
                    'schedule_type': schedule_type
                    })

                business_forecast = [{'schedule_type': 2,
                         'user_tz': 'Eastern (US & Canada)',
                         'frequency': 1 },
                         {'schedule_type': 3,
                         'user_tz': 'Pacific (US & Canada)',
                         'frequency': 2 }]

                model = GeneralProbModel()

                model.fit(training_data)
                p = model.predict(business_forecast)
                expect(True).to.equal(True)
开发者ID:Edderic,项目名称:udacity-machine-learning-nanodegree,代码行数:32,代码来源:models_spec.py


示例3: handles_predicting_cases_it_has_not_seen_before

            def handles_predicting_cases_it_has_not_seen_before(self):
                user_tz = ['Eastern (US & Canada)', 'Pacific (US & Canada)']
                l1_time = [9, 9]
                l1_day = [0, 1]
                l2_time = [9, 9]
                l2_day = [3, 4]
                l3_time = [None, 9]
                l3_day = [None, 5]
                schedule_type = [2, 3]

                training_data = pd.DataFrame({ 'user_tz': user_tz,
                    'l1_time': l1_time,
                    'l1_day': l1_day,
                    'l2_time': l2_time,
                    'l2_day': l2_day,
                    'l3_time': l3_time,
                    'l3_day': l3_day,
                    'schedule_type': schedule_type
                    })

                business_forecast = [{'schedule_type': 1,
                         'user_tz': 'Eastern (US & Canada)',
                         'frequency': 1 },
                         {'schedule_type': 4,
                         'user_tz': 'Pacific (US & Canada)',
                         'frequency': 2 }]

                model = GeneralProbModel()

                model.fit(training_data)
                p = model.predict(business_forecast)

                expect(True).to.equal(True)
开发者ID:Edderic,项目名称:udacity-machine-learning-nanodegree,代码行数:33,代码来源:models_spec.py


示例4: transmute_to_and_from_with_custom_serializer

    def transmute_to_and_from_with_custom_serializer(self):
        mapping = TestWrappedModel()
        mapping.test = "bam"

        json_str = '{"#item": {"test": "bam"}}'

        class Custom(object):
            @classmethod
            def dumps(cls, value):
                value['#item']['test'] = 'allthethings'
                return json.dumps(value)

            @classmethod
            def loads(cls, value):
                loaded = json.loads(json_str)
                loaded['#item']['test'] = 'magic'
                return loaded

        result = JsonTransmuter.transmute_to(
            mapping,
            encoder=Custom
        )
        expect(result).to.equal('{"#item": {"test": "allthethings"}}')

        result = JsonTransmuter.transmute_from(
            json_str,
            TestWrappedModel,
            decoder=Custom
        )
        expect(result.test).to.equal('magic')
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:30,代码来源:json_transmuter.py


示例5: can_delete_job

    def can_delete_job(self):
        post_resp = self._post_job()
        job_id = post_resp.json['job_id']

        resp = self.app.delete('/v1/tenant/jobs/{0}'.format(job_id),
                               expect_errors=True)
        expect(resp.status_int).to.equal(200)
开发者ID:CloudRift,项目名称:Rift,代码行数:7,代码来源:jobs.py


示例6: should_not_have_weird_hours

            def should_not_have_weird_hours(self):
                user_tz = ['Eastern (US & Canada)', 'Pacific (US & Canada)']
                l1_time = [9, 9]
                l2_time = [9, 9]
                l3_time = [None, 9]

                training_data = pd.DataFrame({ 'user_tz': user_tz,
                    'l1_time': l1_time,
                    'l2_time': l2_time
                    })

                business_forecast = [{'schedule_type': 2,
                         'timezone': 'Eastern (US & Canada)',
                         'frequency': 1 },
                         {'schedule_type': 3,
                         'timezone': 'Pacific (US & Canada)',
                         'frequency': 2 }]

                smart_heuristic_model = SmartHeuristicModel()
                smart_heuristic_model.fit(training_data)

                schedule = smart_heuristic_model.\
                        generate_sample_schedule(business_forecast)
                _sum = schedule._table_df.sum().sum()
                expect(_sum).to.equal(8)
开发者ID:Edderic,项目名称:udacity-machine-learning-nanodegree,代码行数:25,代码来源:models_spec.py


示例7: cannot_be_instantiated

 def cannot_be_instantiated(self):
     try:
         result = AbstractPlugin()
     except TypeError:
         # Expected
         result = None
     expect(result).to.be_none()
开发者ID:CloudRift,项目名称:Rift,代码行数:7,代码来源:abstract_plugin.py


示例8: transmute_to_and_from_with_unknown_type

    def transmute_to_and_from_with_unknown_type(self):
        class CustomType(object):
            def __init__(self, something):
                self.something = something

        class TestMappedModel(JsonMappedModel):
            __mapping__ = {
                'test': Attr('test', CustomType),
            }

        model = TestMappedModel()
        model.test = CustomType('thing')

        serialized = '{}'

        result = JsonTransmuter.transmute_to(model)
        expect(result).to.equal(serialized)

        result = JsonTransmuter.transmute_from(
            '{"test": {"something": "thing"}}',
            TestMappedModel
        )

        attr = getattr(result, 'test', None)
        expect(attr).to.be_none()
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:25,代码来源:json_transmuter.py


示例9: can_authenticate

        def can_authenticate(self, post_func):
            post_func.return_value = get_keystone_v2_auth_resp()

            creds = self.auth.authenticate()

            expect(creds.get('token', None)).to.equal('some_token')
            expect(creds.get('project_id', None)).to.equal('some_tenant')
开发者ID:jmvrbanac,项目名称:requests-cloud-auth,代码行数:7,代码来源:rackspace.py


示例10: transmute_to_with_empty_submodel

    def transmute_to_with_empty_submodel(self):
        model = TestChildMapping()
        model.child = None

        result = JsonTransmuter.transmute_to(model, to_string=False)

        expect(result.get('child')).to.be_none()
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:7,代码来源:json_transmuter.py


示例11: transmute_to_with_different_attr_naming

    def transmute_to_with_different_attr_naming(self):
        model = TestDifferentAttrNaming()
        model.my_thing = 'something'

        result = JsonTransmuter.transmute_to(model, to_string=False)

        expect(result['my-thing']).to.equal('something')
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:7,代码来源:json_transmuter.py


示例12: can_authenticate

        def can_authenticate(self, post_func):
            r = get_keystone_v2_auth_resp()
            post_func.return_value = r

            self.auth(r)

            expect(r.headers.get('X-Auth-Token')).to.equal('some_token')
            expect(r.headers.get('X-Project-Id')).to.equal('some_tenant')
开发者ID:jmvrbanac,项目名称:requests-cloud-auth,代码行数:8,代码来源:keystone.py


示例13: raises_exception_on_unsupported_provider

    def raises_exception_on_unsupported_provider(self, get_target, get_driver):
        target = self.TARGET_WITH_UNSUPPORTED_PROVIDER
        driver_stub = self._get_libcloud_driver_stub([])
        get_target.return_value = target
        get_driver.return_value = driver_stub

        expect(self.plugin.execute_action, [self.job, self.action]) \
            .to.raise_a(Exception)
开发者ID:CloudRift,项目名称:Rift,代码行数:8,代码来源:nova.py


示例14: raises_exception_on_invalid_address

    def raises_exception_on_invalid_address(self, get_target, get_driver):
        target = self.TARGET_WITH_IP_ADDRESS
        driver_stub = self._get_libcloud_driver_stub([])
        get_target.return_value = target
        get_driver.return_value = driver_stub

        expect(self.plugin.execute_action, [self.job, self.action]) \
            .to.raise_a(Exception)
开发者ID:CloudRift,项目名称:Rift,代码行数:8,代码来源:nova.py


示例15: run_requires_a_project_cfg

    def run_requires_a_project_cfg(self):
        config._config = None

        try:
            app.main(['run', 'bam'])
        except SystemExit:
            err_msg = 'Error: Could not file project configuration!'
            expect(err_msg).to.be_in(self.stdout.getvalue())
开发者ID:sdoumbouya,项目名称:ansible-flow,代码行数:8,代码来源:app.py


示例16: can_connect_with_args

    def can_connect_with_args(self):
        self.ssh_client.connect(
            host='sample.host',
            port=80,
            credentials=self.ssh_credentials)

        expect(self.ssh_client.host).to.equal('sample.host')
        expect(self.ssh_client.port).to.equal(80)
开发者ID:CloudRift,项目名称:Rift,代码行数:8,代码来源:ssh.py


示例17: transmute_to_missing_required_attr_raises

    def transmute_to_missing_required_attr_raises(self):
        model = TestRequiredMappedModel()
        model.test = 1

        expect(
            JsonTransmuter.transmute_to,
            [model]
        ).to.raise_a(RequiredAttributeError)
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:8,代码来源:json_transmuter.py


示例18: transmute_from_with_all_required_attrs

    def transmute_from_with_all_required_attrs(self):
        result = JsonTransmuter.transmute_from(
            '{"test": 1, "other": 2}',
            TestRequiredMappedModel,
        )

        expect(result.test).to.equal(1)
        expect(result.other).to.equal(2)
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:8,代码来源:json_transmuter.py


示例19: transmute_from_with_missing_required_attr_raises

 def transmute_from_with_missing_required_attr_raises(self):
     expect(
         JsonTransmuter.transmute_from,
         [
             '{"test": 1}',
             TestRequiredMappedModel
         ]
     ).to.raise_a(RequiredAttributeError)
开发者ID:jmvrbanac,项目名称:alchemize,代码行数:8,代码来源:json_transmuter.py


示例20: can_recreate

        def can_recreate(self):
            # Calling without an environment existing
            venv.argument_handler('recreate', None)
            expect(os.path.exists(venv.ENV_PATH)).to.be_true()

            # Calling again now that the environment exists
            venv.argument_handler('recreate', None)
            expect(os.path.exists(venv.ENV_PATH)).to.be_true()
开发者ID:sdoumbouya,项目名称:ansible-flow,代码行数:8,代码来源:venv.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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