def version(self): if self._version is None: output = _do_call(self._call) match = self._rege.search(output) if not match: raise VersionRequirementError("Could not determine version of '%s', searching for %s: %s" \ % (self.name, repr(self._rege.pattern), repr(output))) self._version = tuple(try_cast(value, int) for value in match.groups()) return self._version
def version(self): """The version determined for the application / library. If the version could not be determined, a VersionRequirementError is raised, describing the cause of the problem. """ if self._version is None: output = _do_call(self._call) # Raise an exception if the JRE is outdated, even if the # version could be determined (likely a false positive match). self._check_for_outdated_jre(output) match = self._rege.search(output) if not match: self._raise_failure(output) self._version = tuple(0 if value is None else try_cast(value, int) for value in match.groups()) return self._version
def test_try_cast__list_to_int(): assert_equal(utils.try_cast([1, 2, 3], int), [1, 2, 3])
def test_try_cast__bad_str_to_int(): assert_equal(utils.try_cast("x17", int), "x17")
def test_try_cast__good_str_to_int(): assert_equal(utils.try_cast("17", int), 17)
def test_try_cast__float_to_int(): assert_equal(utils.try_cast(17.3, int), 17)
def test_try_cast__int_to_int(): assert_equal(utils.try_cast(17, int), 17)