allow for rc in version values

This commit is contained in:
Job Evers-Meltzer 2016-11-19 16:58:40 -06:00
parent e03db79f79
commit 3d7dee1208
2 changed files with 6 additions and 5 deletions

View file

@ -1,12 +1,13 @@
import base64 import base64
import datetime import datetime
import distutils.version
import logging import logging
import random import random
import os import os
import socket import socket
import sys import sys
import pkg_resources
from lbrynet.core.cryptoutils import get_lbry_hash_obj from lbrynet.core.cryptoutils import get_lbry_hash_obj
@ -61,10 +62,7 @@ def is_valid_blobhash(blobhash):
def version_is_greater_than(a, b): def version_is_greater_than(a, b):
"""Returns True if version a is more recent than version b""" """Returns True if version a is more recent than version b"""
try: return pkg_resources.parse_version(a) > pkg_resources.parse_version(b)
return distutils.version.StrictVersion(a) > distutils.version.StrictVersion(b)
except ValueError:
return distutils.version.LooseVersion(a) > distutils.version.LooseVersion(b)
def deobfuscate(obfustacated): def deobfuscate(obfustacated):

View file

@ -17,6 +17,9 @@ class CompareVersionTest(unittest.TestCase):
def test_version_can_have_four_parts(self): def test_version_can_have_four_parts(self):
self.assertTrue(utils.version_is_greater_than('1.3.9.1', '1.3.9')) self.assertTrue(utils.version_is_greater_than('1.3.9.1', '1.3.9'))
def test_release_is_greater_than_rc(self):
self.assertTrue(utils.version_is_greater_than('1.3.9', '1.3.9rc0'))
class ObfuscationTest(unittest.TestCase): class ObfuscationTest(unittest.TestCase):
def test_deobfuscation_reverses_obfuscation(self): def test_deobfuscation_reverses_obfuscation(self):