Skip to content

Commit

Permalink
Fix Python3 problem when checking for new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Siemens authored and msiemens committed Aug 31, 2015
1 parent 4107474 commit 6991262
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion PyGitUp/gitup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
###############################################################################

# Python libs
import codecs
import errno
import sys
import os
Expand Down Expand Up @@ -400,7 +401,8 @@ def version_info(self):

try:
# Get version information from the PyPI JSON API
details = json.loads(urlopen(PYPI_URL).read().decode('utf-8'))
reader = codecs.getreader('utf-8')
details = json.load(reader(urlopen(PYPI_URL)))
online_version = details['info']['version']
except (HTTPError, URLError, ValueError):
recent = True # To not disturb the user with HTTP/parsing errors
Expand Down
36 changes: 36 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# System imports
import socket

# 3rd party libs
from nose.plugins.skip import SkipTest
from nose.tools import *

# PyGitup imports
from tests import capture

test_name = 'version'


def test_version():
""" Run 'git up': Check version """
try:
import pkg_resources as pkg
except ImportError:
raise SkipTest('pip not installed')

try:
socket.gethostbyname('pypi.python.org')
except socket.error:
raise SkipTest('Can\'t connect to PYPI')

from PyGitUp.gitup import GitUp
with capture() as [stdout, _]:
GitUp(sparse=True).version_info()
stdout = stdout.getvalue()

package = pkg.get_distribution('git-up')
local_version_str = package.version

assert_in(local_version_str, stdout)


0 comments on commit 6991262

Please sign in to comment.