Пример #1
0
    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
Пример #2
0
    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
Пример #3
0
def test_try_cast__list_to_int():
    assert_equal(utils.try_cast([1, 2, 3], int), [1, 2, 3])
Пример #4
0
def test_try_cast__bad_str_to_int():
    assert_equal(utils.try_cast("x17", int), "x17")
Пример #5
0
def test_try_cast__good_str_to_int():
    assert_equal(utils.try_cast("17", int), 17)
Пример #6
0
def test_try_cast__float_to_int():
    assert_equal(utils.try_cast(17.3, int), 17)
Пример #7
0
def test_try_cast__int_to_int():
    assert_equal(utils.try_cast(17, int), 17)
Пример #8
0
def test_try_cast__int_to_int():
    assert utils.try_cast(17, int) == 17
Пример #9
0
def test_try_cast__list_to_int():
    assert utils.try_cast([1, 2, 3], int) == [1, 2, 3]
Пример #10
0
def test_try_cast__bad_str_to_int():
    assert utils.try_cast("x17", int) == "x17"
Пример #11
0
def test_try_cast__good_str_to_int():
    assert utils.try_cast("17", int) == 17
Пример #12
0
def test_try_cast__float_to_int():
    assert utils.try_cast(17.3, int) == 17