sigmavirus24 / github3.py

Hi, I'm a library for interacting with GItHub's REST API in a convenient and ergonomic way. I work on Python 3.6+.
https://github3.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.2k stars 401 forks source link

Multiple errors in all versions of Python on develop branch #278

Closed esacteksab closed 10 years ago

esacteksab commented 10 years ago

Not sure if this is me or ? Ran this on multiple machines, all versions of Python (see tox.ini)

$ pip freeze
argparse==1.2.1
betamax==0.4.0
betamax-matchers==0.1.0
mock==1.0.1
py==1.4.24
pytest==2.6.2
requests==2.4.1
tox==1.7.2
uritemplate.py==0.2.0
virtualenv==1.11.6
wheel==0.21.0
wsgiref==0.1.2

py34 create: /home/bmorriso/localrepo/github3.py/.tox/py34
py34 installdeps: requests>=1.2.3, coverage>=3.5.2, mock>=1.0.1
py34 inst: /home/bmorriso/localrepo/github3.py/.tox/dist/github3.py-0.9.1.zip
py34 runtests: PYTHONHASHSEED='1179804555'
py34 runtests: commands[0] | python setup.py test
running test
running egg_info
writing dependency_links to github3.py.egg-info/dependency_links.txt
writing github3.py.egg-info/PKG-INFO
writing requirements to github3.py.egg-info/requires.txt
writing top-level names to github3.py.egg-info/top_level.txt
reading manifest file 'github3.py.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching '*.pyc'
no previously-included directories found matching 'docs/_build'
writing manifest file 'github3.py.egg-info/SOURCES.txt'
running build_ext
.............................................................................................................................................................................................................................................................................................................................................................................................................................F..F.F...........................F...............................................
============================================== FAILURES ===============================================
_____________________________ TestGitHub.test_search_code_with_text_match _____________________________

self = <tests.integration.test_github.TestGitHub testMethod=test_search_code_with_text_match>

    def test_search_code_with_text_match(self):
        """Test the ability to use the code search endpoint"""
        cassette_name = self.cassette_name('search_code_with_text_match')
        with self.recorder.use_cassette(cassette_name,
                                        match_requests_on=self.match_on):
            result_iterator = self.gh.search_code(
                ('HTTPAdapter in:file language:python'
                 ' repo:kennethreitz/requests'),
                text_match=True
                )
>           code_result = next(result_iterator)

tests/integration/test_github.py:239: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
github3/structs.py:93: in __next__
    return next(self.__i__)
github3/structs.py:59: in __iter__
    headers=headers)
github3/models.py:130: in _get
    return self._session.get(url, **kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:463: in get
    return self.request('GET', url, **kwargs)
github3/session.py:81: in request
    response = super(GitHubSession, self).request(*args, **kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:451: in request
    resp = self.send(prep, **send_kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:557: in send
    r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <betamax.adapter.BetamaxAdapter object at 0x7f24081ace48>, request = <PreparedRequest [GET]>
stream = False, timeout = None, verify = True, cert = None, proxies = {}

    def send(self, request, stream=False, timeout=None, verify=True,
             cert=None, proxies=None):
        interaction = None

        if not self.cassette:
            raise BetamaxError('No cassette was specified or found.')

        if self.cassette.interactions:
            interaction = self.cassette.find_match(request)

        if not interaction and self.cassette.is_recording():
            interaction = self.send_and_record(
                request, stream, timeout, verify, cert, proxies
                )

        if not interaction:
            raise BetamaxError(unhandled_request_message(request,
>                                                        self.cassette))
E           betamax.exceptions.BetamaxError: A request was made that could not be handled.
E           
E           A request was made to https://api.github.com/search/code?per_page=100&q=HTTPAdapter+in%3Afile+language%3Apython+repo%3Akennethreitz%2Frequests that could not be found in GitHub_search_code_with_text_match.
E           
E           The settings on the cassette are:
E           
E               - record_mode: once
E               - match_options ['method', 'uri', 'gh3-headers'].

/home/bmorriso/localrepo/github3.py/betamax-0.4.0-py3.4.egg/betamax/adapter.py:91: BetamaxError
_________________________ TestGitHub.test_search_repositories_with_text_match _________________________

self = <tests.integration.test_github.TestGitHub testMethod=test_search_repositories_with_text_match>

    def test_search_repositories_with_text_match(self):
        """Test the ability to use the repository search endpoint"""
        self.token_login()
        cassette_name = self.cassette_name('search_repositories_text_match')
        with self.recorder.use_cassette(cassette_name,
                                        match_requests_on=self.match_on):
            repos = self.gh.search_repositories('github3 language:python',
                                                text_match=True)
>           repo_result = next(repos)

tests/integration/test_github.py:295: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
github3/structs.py:93: in __next__
    return next(self.__i__)
github3/structs.py:59: in __iter__
    headers=headers)
github3/models.py:130: in _get
    return self._session.get(url, **kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:463: in get
    return self.request('GET', url, **kwargs)
github3/session.py:81: in request
    response = super(GitHubSession, self).request(*args, **kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:451: in request
    resp = self.send(prep, **send_kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:557: in send
    r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <betamax.adapter.BetamaxAdapter object at 0x7f24080bfda0>, request = <PreparedRequest [GET]>
stream = False, timeout = None, verify = True, cert = None, proxies = {}

    def send(self, request, stream=False, timeout=None, verify=True,
             cert=None, proxies=None):
        interaction = None

        if not self.cassette:
            raise BetamaxError('No cassette was specified or found.')

        if self.cassette.interactions:
            interaction = self.cassette.find_match(request)

        if not interaction and self.cassette.is_recording():
            interaction = self.send_and_record(
                request, stream, timeout, verify, cert, proxies
                )

        if not interaction:
            raise BetamaxError(unhandled_request_message(request,
>                                                        self.cassette))
E           betamax.exceptions.BetamaxError: A request was made that could not be handled.
E           
E           A request was made to https://api.github.com/search/repositories?per_page=100&q=github3+language%3Apython that could not be found in GitHub_search_repositories_text_match.
E           
E           The settings on the cassette are:
E           
E               - record_mode: once
E               - match_options ['method', 'uri', 'gh3-headers'].

/home/bmorriso/localrepo/github3.py/betamax-0.4.0-py3.4.egg/betamax/adapter.py:91: BetamaxError
____________________________ TestGitHub.test_search_users_with_text_match _____________________________

self = <tests.integration.test_github.TestGitHub testMethod=test_search_users_with_text_match>

    def test_search_users_with_text_match(self):
        """Test the ability to use the user search endpoint"""
        cassette_name = self.cassette_name('search_users_with_text_match')
        with self.recorder.use_cassette(cassette_name,
                                        match_requests_on=self.match_on):
            users = self.gh.search_users('tom followers:>1000',
                                         text_match=True)
>           user_result = next(users)

tests/integration/test_github.py:261: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
github3/structs.py:93: in __next__
    return next(self.__i__)
github3/structs.py:59: in __iter__
    headers=headers)
github3/models.py:130: in _get
    return self._session.get(url, **kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:463: in get
    return self.request('GET', url, **kwargs)
github3/session.py:81: in request
    response = super(GitHubSession, self).request(*args, **kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:451: in request
    resp = self.send(prep, **send_kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:557: in send
    r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <betamax.adapter.BetamaxAdapter object at 0x7f2408082630>, request = <PreparedRequest [GET]>
stream = False, timeout = None, verify = True, cert = None, proxies = {}

    def send(self, request, stream=False, timeout=None, verify=True,
             cert=None, proxies=None):
        interaction = None

        if not self.cassette:
            raise BetamaxError('No cassette was specified or found.')

        if self.cassette.interactions:
            interaction = self.cassette.find_match(request)

        if not interaction and self.cassette.is_recording():
            interaction = self.send_and_record(
                request, stream, timeout, verify, cert, proxies
                )

        if not interaction:
            raise BetamaxError(unhandled_request_message(request,
>                                                        self.cassette))
E           betamax.exceptions.BetamaxError: A request was made that could not be handled.
E           
E           A request was made to https://api.github.com/search/users?per_page=100&q=tom+followers%3A%3E1000 that could not be found in GitHub_search_users_with_text_match.
E           
E           The settings on the cassette are:
E           
E               - record_mode: once
E               - match_options ['method', 'uri', 'gh3-headers'].

/home/bmorriso/localrepo/github3.py/betamax-0.4.0-py3.4.egg/betamax/adapter.py:91: BetamaxError
_______________________ TestGitHubSession.test_two_factor_authentication_works ________________________

self = <tests.integration.test_session.TestGitHubSession testMethod=test_two_factor_authentication_works>

    def test_two_factor_authentication_works(self):
        two_factor_auth = lambda: '862478'
        self.basic_login()
        self.gh.login(two_factor_callback=two_factor_auth)

        cassette_name = self.cassette_name('two_factor_authentication')
        assert isinstance(self.session, github3.session.GitHubSession)

        match = ['method', 'uri', 'gh3-headers']
        with self.recorder.use_cassette(cassette_name,
                                        match_requests_on=match):
>           r = self.session.get('https://api.github.com/users/sigmavirus24')

tests/integration/test_session.py:18: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:463: in get
    return self.request('GET', url, **kwargs)
github3/session.py:81: in request
    response = super(GitHubSession, self).request(*args, **kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:451: in request
    resp = self.send(prep, **send_kwargs)
.tox/py34/lib/python3.4/site-packages/requests/sessions.py:557: in send
    r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <betamax.adapter.BetamaxAdapter object at 0x7f24080c72b0>, request = <PreparedRequest [GET]>
stream = False, timeout = None, verify = True, cert = None, proxies = {}

    def send(self, request, stream=False, timeout=None, verify=True,
             cert=None, proxies=None):
        interaction = None

        if not self.cassette:
            raise BetamaxError('No cassette was specified or found.')

        if self.cassette.interactions:
            interaction = self.cassette.find_match(request)

        if not interaction and self.cassette.is_recording():
            interaction = self.send_and_record(
                request, stream, timeout, verify, cert, proxies
                )

        if not interaction:
            raise BetamaxError(unhandled_request_message(request,
>                                                        self.cassette))
E           betamax.exceptions.BetamaxError: A request was made that could not be handled.
E           
E           A request was made to https://api.github.com/users/sigmavirus24 that could not be found in GitHubSession_two_factor_authentication.
E           
E           The settings on the cassette are:
E           
E               - record_mode: once
E               - match_options ['method', 'uri', 'gh3-headers'].

/home/bmorriso/localrepo/github3.py/betamax-0.4.0-py3.4.egg/betamax/adapter.py:91: BetamaxError
4 failed, 490 passed in 4.10 seconds
ERROR: InvocationError: '/home/bmorriso/localrepo/github3.py/.tox/py34/bin/python setup.py test'

Let me know if I should break these errors up into their own issue(s) or if it "works for me (you)".

sigmavirus24 commented 10 years ago

This is totally believable. If I remember correctly it's due to requests 2.4.0 having Connection: keep-alive as a header sent on every request. This is fixed in 1.0-alpha but I didn't bother backporting to develop since all the action happens on 1.0-alpha. This issue should stay open though.

Also 1.0-alpha is stable enough that I should eventually rename it 1.0-beta.