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: try: output = _do_call(self._call) except OSError as error: self._raise_failure(error) if isinstance(output, bytes): output = output.decode("utf-8", "replace") # 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 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: try: output = _do_call(self._call) except OSError as error: self._raise_failure(error) # 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)
def test_try_cast__int_to_int(): assert utils.try_cast(17, int) == 17
def test_try_cast__list_to_int(): assert utils.try_cast([1, 2, 3], int) == [1, 2, 3]
def test_try_cast__bad_str_to_int(): assert utils.try_cast("x17", int) == "x17"
def test_try_cast__good_str_to_int(): assert utils.try_cast("17", int) == 17
def test_try_cast__float_to_int(): assert utils.try_cast(17.3, int) == 17