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

Python expect.raises函数代码示例

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

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



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

示例1: test_with_block_closes_runner_after_error

def test_with_block_closes_runner_after_error():
  with expect.raises(KeyError):
    with lola.Runner() as runner:
      raise KeyError()

  with expect.raises(ValueError):
    runner.close()
开发者ID:mgood,项目名称:lola,代码行数:7,代码来源:test_lola.py


示例2: test_issues

    def test_issues(self):
        title = 'Test issue for github3.py'
        with expect.raises(github3.GitHubError):
            # Try to create one without authenticating
            self.g.create_issue(self.sigm, self.todo, title)
            # Try to get individual ones
            self.g.issue(self.sigm, self.todo, 2000)
            self.g.list_user_issues()

        i = self.g.issue(self.sigm, self.todo, 1)
        self.assertIsNotNone(i)
        expect(i).isinstance(github3.issues.Issue)
        expect(i.list_comments()) != []
        # Test listing issues
        list_issues = self.g.list_repo_issues
        expect(list_issues(self.kr, 'requests')) != []
        expect(list_issues(self.sigm, self.todo)).isinstance(list)
        for f in ('assigned', 'created', 'mentioned'):
            self.assertIsNotNone(list_issues(self.sigm, self.todo, f))
        for s in ('open', 'closed'):
            self.assertIsNotNone(list_issues(self.sigm, self.todo, state=s))
        self.assertIsNotNone(list_issues(self.sigm, self.todo, state='closed',
            labels='Bug,Enhancement'))
        for s in ('created', 'updated', 'comments'):
            self.assertIsNotNone(list_issues(self.sigm, self.todo, sort=s))
        for d in ('asc', 'desc'):
            self.assertIsNotNone(list_issues(self.sigm, self.todo,
                state='closed', direction=d))
        self.assertIsNotNone(list_issues(self.sigm, self.todo,
            since='2011-01-01T00:00:01Z'))
开发者ID:davelxmos,项目名称:github3.py,代码行数:30,代码来源:test_github.py


示例3: test_unsupported_comparision

def test_unsupported_comparision():
    from sys import version_info
    repr_name = 'class' if version_info[0] >= 3 else 'type'

    with expect.raises(NotImplementedError, 'Unable to compare Version and '
                       "<%s 'float'>" % repr_name):
        float(3.2) == Version('0.2.0')
开发者ID:takesxi-shimada,项目名称:versionah,代码行数:7,代码来源:test_foreign_comparison.py


示例4: test_dump_xearth_markers

def test_dump_xearth_markers():
    markers = {
        500936: Trigpoint(52.066035, -0.281449, 37.000000, 'Broom Farm'),
        501097: Trigpoint(52.010585, -0.173443, 97.000000, 'Bygrave'),
        505392: Trigpoint(51.910886, -0.186462, 136.000000, 'Sish Lane')
    }
    data = dump_xearth_markers(markers)
    expect(data[0]) == '52.066035 -0.281449 "500936" # Broom Farm, alt 37m'
    expect(data[1]) == '52.010585 -0.173443 "501097" # Bygrave, alt 97m'
    expect(data[2]) == '51.910886 -0.186462 "505392" # Sish Lane, alt 136m'

    data = dump_xearth_markers(markers, 'name')
    expect(data[0]) == '52.066035 -0.281449 "Broom Farm" # 500936, alt 37m'
    expect(data[1]) == '52.010585 -0.173443 "Bygrave" # 501097, alt 97m'
    expect(data[2]) == '51.910886 -0.186462 "Sish Lane" # 505392, alt 136m'

    with expect.raises(ValueError, "Unknown name type 'falseKey'"):
        dump_xearth_markers(markers, 'falseKey')

    points = {
        'Broom Farm': Point(52.066035, -0.281449),
        'Bygrave': Point(52.010585, -0.173443),
        'Sish Lane': Point(51.910886, -0.186462)
    }
    data = dump_xearth_markers(points)
    expect(data[0]) == '52.066035 -0.281449 "Broom Farm"'
    expect(data[1]) == '52.010585 -0.173443 "Bygrave"'
    expect(data[2]) == '51.910886 -0.186462 "Sish Lane"'
开发者ID:encukou,项目名称:upoints,代码行数:28,代码来源:test_utils.py


示例5: test_angle_to_distance

def test_angle_to_distance():
    expect('%.3f' % angle_to_distance(1)) == '111.125'
    expect('%i' % angle_to_distance(360, 'imperial')) == '24863'
    expect('%i' % angle_to_distance(1.0 / 60, 'nautical')) == '1'

    with expect.raises(ValueError, "Unknown units type 'baseless'"):
        '%i' % angle_to_distance(10, 'baseless')
开发者ID:encukou,项目名称:upoints,代码行数:7,代码来源:test_utils.py


示例6: test_gists

    def test_gists(self):
        gists = self.g.list_gists()
        expect(gists) != []

        for g in gists:
            expect(g).isinstance(Gist)
            expect(g.files) >= 0
            expect(g.list_files()).isinstance(list)
            expect(g.forks) >= 0
            self.assertAreNotNone(g, 'created_at', 'description',
                    'git_pull_url', 'git_push_url', 'html_url', 'id')
            expect(g.is_public()).isinstance(bool)
            expect(g.is_starred()).isinstance(bool)
            expect(g.to_json()).isinstance(dict)
            comments = g.list_comments()
            if comments:
                for c in comments:
                    expect(c).isinstance(GistComment)

            expect(g.refresh()).isinstance(bool)
            expect(g.user).isinstance(User)

            with expect.raises(github3.GitHubError):
                g.create_comment('Foo')
                g.delete()
                g.edit()
                g.fork()
                g.star()
                g.unstar()
开发者ID:davelxmos,项目名称:github3.py,代码行数:29,代码来源:test_gist.py


示例7: test___init__

    def test___init__(self):
        test = Point(math.pi / 4, math.pi / 2, angle='radians')
        expect(test.latitude) == 45
        expect(test.longitude) == 90

        test = Point((50, 20, 10), (-1, -3, -12))
        expect('%.3f' % test.latitude) == '50.336'
        expect('%.3f' % test.longitude) == '-1.053'

        with expect.raises(ValueError, 'Unknown angle type None'):
            Point(52.015, -0.221, angle=None)
        with expect.raises(ValueError, 'Invalid latitude value -92'):
            Point(-92, -0.221)
        with expect.raises(ValueError, 'Invalid longitude value 185'):
            Point(52.015, 185)
        with expect.raises(ValueError, 'Unknown units type None'):
            Point(52.015, -0.221, units=None)
开发者ID:encukou,项目名称:upoints,代码行数:17,代码来源:test_point.py


示例8: test_blob

    def test_blob(self):
        r = self.todor
        blob = r.blob("f737918b90118a6aea991f89f444b150a2360393")
        expect(blob).isinstance(Blob)
        self.assertAreNotNone(blob, "content", "decoded", "encoding", "sha", "size")

        with expect.raises(github3.GitHubError):
            r.create_blob("Foo bar bogus", "utf-8")
开发者ID:davelxmos,项目名称:github3.py,代码行数:8,代码来源:test_git.py


示例9: test_requires_auth

 def test_requires_auth(self):
     with expect.raises(github3.GitHubError):
         for g in self.gists:
             g.create_comment('Foo')
             g.delete()
             g.edit()
             g.fork()
             g.star()
             g.unstar()
开发者ID:jsullivanlive,项目名称:github3.py,代码行数:9,代码来源:test_gists.py


示例10: test_refs

    def test_refs(self):
        r = self.todor
        ref = r.ref("heads/development")
        expect(ref).isinstance(Reference)
        self.assertAreNotNone(ref, "object", "ref")

        with expect.raises(github3.GitHubError):
            ref.delete()
            ref.update("31e862095dffa60744f1ce16a431ea040381f053")
开发者ID:davelxmos,项目名称:github3.py,代码行数:9,代码来源:test_git.py


示例11: should_be_able_to_manually_set_ids_only_while_clock_not_started

 def should_be_able_to_manually_set_ids_only_while_clock_not_started(self):
     Synapse.clock.reset()
     neuron = Neuron(id=3)
     expect(neuron.id) == 3
     expect(Synapse(neuron, 10, id=7).id) == 7
     Synapse.clock.start()
     expect(Neuron().id) == 8
     with expect.raises(AssertionError):
         Neuron(id=3)
开发者ID:kippr,项目名称:neato,代码行数:9,代码来源:model_tests.py


示例12: it_allows_only_attributes_listed_in__slots__to_be_assigned

    def it_allows_only_attributes_listed_in__slots__to_be_assigned(self):

        class Eggs(object):
            __slots__ = ["spam"]

        eggs = Eggs()
        eggs.spam = True
        with expect.raises(AttributeError):
            eggs.bacon = True
开发者ID:YAtOff,项目名称:advanced-python2-spec,代码行数:9,代码来源:about_attribute_access.py


示例13: test___repr__

    def test___repr__(self):
        expect(repr(Baken(14.460, 20.680, None, None, None, 0.000, None, None,
                          None, None, None))) == \
            'Baken(14.46, 20.68, None, None, None, 0.0, None, None, None, None, None)'
        expect(repr(Baken(None, None, '2 x Turnstile', None, 50.000, 460.000,
                          'IO93BF', 'A1A', None, 25, None))) == \
            ("Baken(%s, -1.875, '2 x Turnstile', None, 50.0, "
             "460.0, 'IO93BF', 'A1A', None, 25, None)" % 53.229166666666686)

        with expect.raises(LookupError,
                           ('Unable to instantiate baken object, no latitude '
                            'or locator string')):
            Baken(None, None)
开发者ID:encukou,项目名称:upoints,代码行数:13,代码来源:test_baken.py


示例14: test_watching

    def test_watching(self):
        expect(self.g.list_watching(self.sigm)) != []
        with expect.raises(github3.GitHubError):
            self.g.watch(self.sigm, self.todo)
            self.g.unwatch(self.sigm, self.todo)
            self.g.list_watching()
            self.g.is_watching(self.sigm, self.todo)

        if self.auth:
            expect(self._g.watch(self.sigm, self.todo)).isinstance(bool)
            expect(self._g.unwatch(self.sigm, self.todo)).isinstance(bool)
            expect(self._g.list_watching()) != []
            expect(self._g.is_watching(self.sigm, self.todo)) != []
开发者ID:davelxmos,项目名称:github3.py,代码行数:13,代码来源:test_github.py


示例15: test_import_locations

    def test_import_locations(self):
        locations = Locations(open('tests/data/geonames'))
        expect(str(locations[0])) == \
            'Afon Wyre (River Wayrai, River Wyrai, Wyre - N52.317°; W004.167°)'
        expect(str(locations[1])) == \
            'Wyre (Viera - N59.117°; W002.967°)'
        expect(str(locations[2])) == \
            'Wraysbury (Wyrardisbury - N51.450°; W000.550°)'

        with expect.raises(FileFormatError,
                           "Incorrect data format, if you're using a file "
                           'downloaded from geonames.org please report this '
                           'to James Rowe <[email protected]>'):
            Locations(open('tests/data/broken_geonames'))
开发者ID:encukou,项目名称:upoints,代码行数:14,代码来源:test_geonames.py


示例16: test_import_timezones_file

    def test_import_timezones_file(self):
        locations = Locations(None, open('tests/data/geonames_timezones'))
        timezones = locations.timezones
        expect(timezones['Asia/Dubai']) == [240, 240]
        expect(timezones['Asia/Kabul']) == [270, 270]
        expect(timezones['Europe/Andorra']) == [60, 120]

        header_skip_check = Locations(None,
                                      open('tests/data/geonames_timezones_header'))
        expect(header_skip_check) == Locations()

        with expect.raises(FileFormatError,
                           "Incorrect data format, if you're using a file "
                           'downloaded from geonames.org please report this '
                           'to James Rowe <[email protected]>'):
            Locations(None, open('tests/data/geonames_timezones_broken'))
开发者ID:encukou,项目名称:upoints,代码行数:16,代码来源:test_geonames.py


示例17: test_following

    def test_following(self):
        expect(self.g.list_followers('kennethreitz')) != []
        expect(self.g.list_following('kennethreitz')) != []
        with expect.raises(github3.GitHubError):
            self.g.is_following(self.sigm)
            self.g.follow(self.sigm)
            self.g.unfollow(self.sigm)
            self.g.list_followers()
            self.g.list_following()

        if self.auth:
            expect(self._g.is_following(self.sigm)).isinstance(bool)
            expect(self._g.follow(self.sigm)).isinstance(bool)
            expect(self._g.unfollow(self.sigm)).isinstance(bool)
            expect(self._g.list_followers()) != []
            expect(self._g.list_following()) != []
开发者ID:davelxmos,项目名称:github3.py,代码行数:16,代码来源:test_github.py


示例18: it_raises_exception_when_they_decrease

        def it_raises_exception_when_they_decrease(project2):
            project2.update(dict(unit=5))

            with expect.raises(ValueError):
                project2.update(dict(unit=4))

            expect(project2.metrics) == dict(
                current=dict(
                    unit=4.0,
                    integration=3.4,
                    overall=5.6,
                ),
                minimum=dict(
                    unit=5.0,
                    integration=3.4,
                    overall=5.6,
                ),
            )
开发者ID:jacebrowning,项目名称:coverage-space,代码行数:18,代码来源:test_models_project.py


示例19: test_login

    def test_login(self):
        # Test "regular" auth
        self.g.login(*self.fake_auth)
        h = github3.login(*self.fake_auth)
        for i in [self.g, h]:
            expect(self.fake_auth) == i._session.auth
        # Test "oauth" auth
        self.g.login(token=self.fake_oauth)
        h = github3.login('', '', token=self.fake_oauth)
        for i in [self.g, h]:
            expect(i._session.headers['Authorization']) == 'token ' +\
                self.fake_oauth

        with expect.raises(github3.GitHubError):
            self.g.user()

        if self.auth:
            self.assertIsNotNone(self._g.user())
开发者ID:davelxmos,项目名称:github3.py,代码行数:18,代码来源:test_github.py


示例20: test_distance

    def test_distance(self):
        home = Point(52.015, -0.221)
        dest = Point(52.6333, -2.5)
        expect('%i kM' % home.distance(dest)) == '169 kM'
        expect('%i kM' % home.distance(dest, method='sloc')) == '169 kM'

        with expect.raises(ValueError, "Unknown method type 'Invalid'"):
            home.distance(dest, method='Invalid')

        start = Point(36.1200, -86.6700)
        dest = Point(33.9400, -118.4000)
        expect('%i kM' % start.distance(dest)) == '2884 kM'
        start.units = 'imperial'
        expect('%i mi' % start.distance(dest)) == '1792 mi'
        start.units = 'nautical'
        expect('%i nmi' % start.distance(dest)) == '1557 nmi'
        start.units = 'metric'
        expect('%i kM' % start.distance(dest, method='sloc')) == '2884 kM'
开发者ID:encukou,项目名称:upoints,代码行数:18,代码来源:test_point.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python expects.equal函数代码示例发布时间:2022-05-24
下一篇:
Python expecter.expect函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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