def test_version_comparison(self): alllangs = ['java', 'js', 'ruby', 'python'] for lval, rval, lang, result in self.versions: if lang == 'all': testlangs = alllangs else: testlangs = [lang] for language in testlangs: print(('{} {} {}, Expected: {}'.format(lval, rval, language, result))) if type(result) == bool: self.assertEqual( result, compare_versions(lval, rval, language=language)) else: did_exception = False try: compare_versions(lval, rval, language=language) did_exception = False except: did_exception = True self.assertEqual(True, did_exception)
def test_not_greater_than(greater_than_versions_high, right, lang): assert compare_versions(greater_than_versions_high, right, lang) is False
def test_not_lesser_than(lesser_than_versions_low, right, lang): assert compare_versions(lesser_than_versions_low, right, lang) is False
def test_greater_than_rc(greater_than_rc_versions, right, lang): assert compare_versions(greater_than_rc_versions, right, lang) is True
def test_lesser_than_rc(lesser_than_rc_versions, right, lang): assert compare_versions(lesser_than_rc_versions, right, lang) is True
def test_doesnt_match_generic_languages(self, left, right, lang): assert compare_versions(left, right, lang) is False
def test_matches_generic_languages(self, left, right, lang): assert compare_versions(left, right, lang) is True
def test_error_matches(self, left, right, lang): with pytest.raises(Exception): compare_versions(left, right, lang)
def test_unsupported(self): with pytest.raises(Exception): compare_versions("> 1.0", "1.0", "VimScript")
def test_doesnt_match(self, left, right, lang): assert compare_versions(left, right, lang) is False