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

Python utils.load函数代码示例

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

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



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

示例1: test_reject

    def test_reject(self):
        class Issue(object):
            def __init__(self, dictionary):
                self.__dict__ = dictionary

        def _get_issue(issue_id):
            return self.client.github.issues.show(self.config["github"]["repo"], issue_id)

        test_pr_id = 1
        reject_message = u"Merge failed"

        # TODO(LB): temporary -- repoen the pull request for this test
        # Remove this line once github mocking is in place
        self.expect(Issue(utils.load(utils.testdata("issue_open.json"))["issue"]))
        self.client.github.issues.reopen(self.config["github"]["repo"], test_pr_id)
        # verify the issue is open
        issue = _get_issue(test_pr_id)
        self.assertEqual(u"open", issue.state)

        # TODO(LB): need to mock up github here as well; see test_comment()
        client = StubbedGithub(config=self.config, conn_class=FakeGithub)
        client.config.github_core_team = "test team 1"
        pull_request = client.pull_requests.values()[0]

        self.expect(Issue(utils.load(utils.testdata("issue_closed.json"))["issue"]))
        rejected_issue = pull_request.close(reject_message)
        self.assertEqual(u"closed", rejected_issue.state)
开发者ID:hub-cap,项目名称:roundabout,代码行数:27,代码来源:github_unittest.py


示例2: test_comment

    def test_comment(self):
        """
        Adds a comment to a test issue and verifies the comment is added.
        TODO(LB): need to change the test setup so we're mocking the github 
        stuff for this (or else the tests run as slow as Chris's Mom).
        """

        class Comment(object):
            def __init__(self, dictionary):
                self.__dict__ = dictionary

        client = StubbedGithub(config=self.config, conn_class=FakeGithub)
        client.config["github"]["core_team"] = "test team 1"
        pull_request = client.pull_requests.values()[0]

        test_issue_id = 12345
        comment_text = u"test comment text"

        # add the comment
        self.expect(utils.load(utils.testdata("comment.json")))
        comment_result = pull_request.comment(comment_text)

        # now verify the comment was added
        self.expect([Comment(x) for x in utils.load(utils.testdata("comments.json"))["comments"]])
        comments = self.client.github.issues.comments(self.config["github"]["repo"], test_issue_id)

        # filter the comments list by id
        comment = [x for x in comments if x.id == comment_result["id"]]

        # should only be one comment here
        self.assertTrue(len(comment) == 1)
        comment = comment[0]

        self.assertEqual(comment_text, comment.body)
开发者ID:hub-cap,项目名称:roundabout,代码行数:34,代码来源:github_unittest.py


示例3: test_create_a_new_pull_request

    def test_create_a_new_pull_request(self):
        pr_str = utils.load(utils.testdata('new_pull_request.json'))
        pr = pull_request.PullRequest(pr_str, self.pr_path)

        self.assertNothingRaised(pr.save,)
        self.assertTrue(os.path.exists(os.path.join(self.pr_path, "2", "pull.js")))
        pr2 = pull_request.PullRequest.load(os.path.join(self.pr_path, "2"))
        self.assertEqual(pr._pull_request, pr2._pull_request)
开发者ID:mcgrue,项目名称:roundabout,代码行数:8,代码来源:test_pull_request.py


示例4: test_delete_key

    def test_delete_key(self):
        self.request.return_value = generate_response(None, 204)

        self.login()
        with patch.object(github3.github.GitHub, 'key') as key:
            key.return_value = github3.users.Key(load('key'), self.g)
            assert self.g.delete_key(10) is True

        assert self.request.called is True
开发者ID:palfrey,项目名称:github3.py,代码行数:9,代码来源:test_github.py


示例5: test_issue_137

 def test_issue_137(self):
     """
     GitHub sometimes returns `pull` as part of of the `html_url` for Issue
     requests.
     """
     i = Issue(load('issue_137'))
     self.assertEqual(
         i.html_url,
         "https://github.com/sigmavirus24/github3.py/pull/1")
     self.assertEqual(i.repository, ("sigmavirus24", "github3.py"))
开发者ID:CamDavidsonPilon,项目名称:github3.py,代码行数:10,代码来源:test_issues.py


示例6: test_iter_issue_comments

    def test_iter_issue_comments(self):
        pull = github3.pulls.PullRequest(load('pull19'))
        self.response('pull19_comment', _iter=True)
        self.get(pull.links['comments'])

        c = next(pull.iter_issue_comments())
        assert isinstance(c, github3.issues.comment.IssueComment)
        self.mock_assertions()

        assert repr(c).startswith('<Issue Comment')
开发者ID:esacteksab,项目名称:github3.py,代码行数:10,代码来源:test_pulls.py


示例7: test_issue

    def test_issue(self):
        self.response('issue', 200)
        self.get('https://api.github.com/repos/sigmavirus24/github3.py/'
                 'issues/1')

        assert self.g.issue(None, None, 0) is None
        with patch.object(github3.github.GitHub, 'repository') as repo:
            repo.return_value = github3.repos.Repository(load('repo'))
            i = self.g.issue('user', 'repo', 1)

        expect(i).isinstance(github3.issues.Issue)
        self.mock_assertions()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:12,代码来源:test_github.py


示例8: test_iter_repo_issues

    def test_iter_repo_issues(self):
        self.response('issue', _iter=True)
        self.get('https://api.github.com/repos/sigmavirus24/github3.py/'
                 'issues')

        with patch.object(github3.GitHub, 'repository') as repo:
            repo.return_value = github3.repos.Repository(load('repo'),
                                                         self.g)
            i = next(self.g.iter_repo_issues('sigmavirus24', 'github3.py'))

        expect(i).isinstance(github3.issues.Issue)
        self.mock_assertions()
开发者ID:n1k0,项目名称:github3.py,代码行数:12,代码来源:test_github.py


示例9: test_update_user

    def test_update_user(self):
        self.login()
        args = ('Ian Cordasco', '[email protected]', 'www.blog.com', 'company',
                'loc', True, 'bio')

        with patch.object(github3.github.GitHub, 'user') as user:
            with patch.object(github3.users.User, 'update') as upd:
                user.return_value = github3.users.User(load('user'), self.g)
                upd.return_value = True
                expect(self.g.update_user(*args)).is_True()
                expect(user.called).is_True()
                expect(upd.called).is_True()
                upd.assert_called_with(*args)
开发者ID:WheresWardy,项目名称:github3.py,代码行数:13,代码来源:test_github.py


示例10: test_pull_request

    def test_pull_request(self):
        self.response('pull')
        self.get('https://api.github.com/repos/sigmavirus24/'
                 'github3.py/pulls/18')
        pr = None

        with patch.object(github3.github.GitHub, 'repository') as repo:
            repo.return_value = github3.repos.Repository(load('repo'))
            pr = self.g.pull_request('sigmavirus24', 'github3.py', 18)

        expect(pr).isinstance(github3.pulls.PullRequest)

        self.mock_assertions()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:13,代码来源:test_github.py


示例11: test_iter_starred

    def test_iter_starred(self):
        self.response('repo', _iter=True)
        self.get('https://api.github.com/user/starred')
        self.conf.update(params={})

        self.login()
        expect(next(self.g.iter_starred())).isinstance(
            github3.repos.Repository)
        self.mock_assertions()

        with patch.object(github3.github.GitHub, 'user') as user:
            user.return_value = github3.users.User(load('user'))
            self.get('https://api.github.com/users/sigmavirus24/starred')
            expect(next(self.g.iter_starred('sigmavirus24'))).isinstance(
                github3.repos.Repository)
            self.mock_assertions()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:16,代码来源:test_github.py


示例12: test_iter_subscriptions

    def test_iter_subscriptions(self):
        self.response('repo', _iter=True)
        self.get('https://api.github.com/user/subscriptions')
        self.conf.update(params={'per_page': 100})

        self.login()
        assert isinstance(next(self.g.iter_subscriptions()),
                          github3.repos.Repository)
        self.mock_assertions()

        with patch.object(github3.github.GitHub, 'user') as user:
            user.return_value = github3.users.User(load('user'))
            self.get('https://api.github.com/users/sigmavirus24/'
                     'subscriptions')
            assert isinstance(next(self.g.iter_subscriptions('sigmavirus24')),
                              github3.repos.Repository)
            self.mock_assertions()
开发者ID:CamDavidsonPilon,项目名称:github3.py,代码行数:17,代码来源:test_github.py


示例13: test_create_issue

    def test_create_issue(self):
        self.response('issue', 201)

        self.login()
        i = self.g.create_issue(None, None, None)
        assert i is None
        assert self.request.called is False

        i = self.g.create_issue('user', 'repo', '')
        assert i is None
        assert self.request.called is False

        with patch.object(github3.GitHub, 'repository') as repo:
            repo.return_value = github3.repos.Repository(
                load('repo'), self.g)
            i = self.g.create_issue('user', 'repo', 'Title')

        expect(i).isinstance(github3.issues.Issue)
        assert self.request.called is True
开发者ID:WheresWardy,项目名称:github3.py,代码行数:19,代码来源:test_github.py


示例14: test_iter_subscriptions

    def test_iter_subscriptions(self):
        self.request.return_value = generate_response('repo', _iter=True)
        self.args = ('GET', 'https://api.github.com/user/subscriptions')
        self.conf.update(params=None)

        self.login()
        expect(next(self.g.iter_subscriptions())).isinstance(
            github3.repos.Repository)
        self.mock_assertions()

        with patch.object(github3.github.GitHub, 'user') as user:
            user.return_value = github3.users.User(load('user'))
            self.args = ('GET',
                         'https://api.github.com/users/sigmavirus24/'
                         'subscriptions'
                         )
            expect(next(self.g.iter_subscriptions('sigmavirus24'))).isinstance(
                github3.repos.Repository)
            self.mock_assertions()
开发者ID:palfrey,项目名称:github3.py,代码行数:19,代码来源:test_github.py


示例15: test_update_label

    def test_update_label(self):
        self.response('label')
        self.patch(self.api + 'labels/Bug')
        self.conf = {'data': {'name': 'big_bug', 'color': 'fafafa'}}

        self.assertRaises(github3.GitHubError, self.repo.update_label, 'foo', 'bar')
        self.not_called()

        self.login()
        with patch.object(repos.Repository, 'label') as l:
            l.return_value = None
            assert self.repo.update_label('foo', 'bar') is False
            self.not_called()

        with patch.object(repos.Repository, 'label') as l:
            l.return_value = github3.issues.label.Label(load('label'), self.g)
            assert self.repo.update_label('big_bug', 'fafafa')

        self.mock_assertions()
开发者ID:esacteksab,项目名称:github3.py,代码行数:19,代码来源:test_repos.py


示例16: test_iter_following

    def test_iter_following(self):
        self.response('user', _iter=True)
        self.get('https://api.github.com/users/sigmavirus24/following')
        self.conf.update(params={'per_page': 100})

        self.assertRaises(github3.GitHubError, self.g.iter_following)
        assert self.request.called is False

        with patch.object(github3.github.GitHub, 'user') as ghuser:
            ghuser.return_value = github3.users.User(load('user'))
            u = next(self.g.iter_following('sigmavirus24'))
            assert isinstance(u, github3.users.User)
            self.mock_assertions()

            self.login()
            v = next(self.g.iter_following())
            assert isinstance(v, github3.users.User)
            self.get('https://api.github.com/user/following')
            self.mock_assertions()
开发者ID:CamDavidsonPilon,项目名称:github3.py,代码行数:19,代码来源:test_github.py


示例17: test_update_label

    def test_update_label(self):
        self.response('label', 200)
        self.patch(self.api + 'labels/bug')
        self.conf = {'data': {'name': 'big_bug', 'color': 'fafafa'}}

        with expect.githuberror():
            self.repo.update_label('foo', 'bar')
        self.not_called()

        self.login()
        with patch.object(github3.repos.Repository, 'label') as l:
            l.return_value = None
            expect(self.repo.update_label('foo', 'bar')).is_False()
            self.not_called()

        with patch.object(github3.repos.Repository, 'label') as l:
            l.return_value = github3.issues.Label(load('label'), self.g)
            expect(self.repo.update_label('big_bug', 'fafafa')).is_True()

        self.mock_assertions()
开发者ID:dahlia,项目名称:github3.py,代码行数:20,代码来源:test_repos.py


示例18: test_iter_following

    def test_iter_following(self):
        self.response('user', _iter=True)
        self.get('https://api.github.com/users/sigmavirus24/following')
        self.conf.update(params=None)

        with expect.githuberror():
            next(self.g.iter_following())
        assert self.request.called is False

        with patch.object(github3.github.GitHub, 'user') as ghuser:
            ghuser.return_value = github3.users.User(load('user'))
            u = next(self.g.iter_following('sigmavirus24'))
            expect(u).isinstance(github3.users.User)
            self.mock_assertions()

            self.login()
            v = next(self.g.iter_following())
            expect(v).isinstance(github3.users.User)
            self.get('https://api.github.com/user/following')
            self.mock_assertions()
开发者ID:WheresWardy,项目名称:github3.py,代码行数:20,代码来源:test_github.py


示例19: __init__

 def __init__(self, methodName='runTest'):
     super(TestOrganization, self).__init__(methodName)
     self.org = github3.orgs.Organization(load('org'))
     self.api = "https://api.github.com/orgs/github3py"
开发者ID:esacteksab,项目名称:github3.py,代码行数:4,代码来源:test_orgs.py


示例20: __init__

 def __init__(self, methodName='runTest'):
     super(TestRepository, self).__init__(methodName)
     self.repo = github3.repos.Repository(load('repo'))
开发者ID:lyddonb,项目名称:github3.py,代码行数:3,代码来源:test_repos.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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