bug fix: version comparison is not lexographic.

Use distutils.version to compare version strings.
This commit is contained in:
Job Evers-Meltzer 2016-07-25 12:25:10 -05:00
parent ea5d31b530
commit d0bc383a79
2 changed files with 5 additions and 1 deletions

View file

@ -1,6 +1,7 @@
import binascii
from datetime import datetime
from decimal import Decimal
import distutils.version
import locale
import logging.handlers
import mimetypes
@ -2314,4 +2315,4 @@ def get_version_from_tag(tag):
def compare_versions(a, b):
"""Returns True if version a is more recent than version b"""
return a > b
return distutils.version.StrictVersion(a) > distutils.version.StrictVersion(b)

View file

@ -36,3 +36,6 @@ class MiscTests(unittest.TestCase):
def test_error_is_thrown_when_version_cant_be_parsed(self):
with self.assertRaises(Exception):
LBRYDaemon.get_version_from_tag('garbage')
def test_compare_versions_isnot_lexographic(self):
self.assertTrue(LBRYDaemon.compare_versions('0.3.10', '0.3.6'))