Exemplo n.º 1
0
    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
Exemplo n.º 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:
            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
Exemplo n.º 3
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:
            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
Exemplo n.º 4
0
def test_try_cast__list_to_int():
    assert_equal(utils.try_cast([1, 2, 3], int), [1, 2, 3])
Exemplo n.º 5
0
def test_try_cast__bad_str_to_int():
    assert_equal(utils.try_cast("x17", int), "x17")
Exemplo n.º 6
0
def test_try_cast__good_str_to_int():
    assert_equal(utils.try_cast("17", int), 17)
Exemplo n.º 7
0
def test_try_cast__float_to_int():
    assert_equal(utils.try_cast(17.3, int), 17)
Exemplo n.º 8
0
def test_try_cast__int_to_int():
    assert_equal(utils.try_cast(17, int), 17)
Exemplo n.º 9
0
def test_try_cast__good_str_to_int():
    assert_equal(utils.try_cast("17", int), 17)
Exemplo n.º 10
0
def test_try_cast__float_to_int():
    assert_equal(utils.try_cast(17.3, int), 17)
Exemplo n.º 11
0
def test_try_cast__int_to_int():
    assert_equal(utils.try_cast(17, int), 17)
Exemplo n.º 12
0
def test_try_cast__list_to_int():
    assert_equal(utils.try_cast([1, 2, 3], int), [1, 2, 3])
Exemplo n.º 13
0
def test_try_cast__bad_str_to_int():
    assert_equal(utils.try_cast("x17", int), "x17")