Exemplo n.º 1
0
def cmp_version(this, other, op=">="):
    """
    Compare two version strings with the given operator ``op``
    >>> assert cmp_version("1.1.1", "1.1.0") and not cmp_version("1.1.1", "1.1.0", op="==")
    """
    from pkg_resources import parse_version
    from monty.operator import operator_from_str
    op = operator_from_str(op)
    return op(parse_version(this), parse_version(other))
Exemplo n.º 2
0
 def test_something(self):
     assert operator_from_str("==")(1, 1) and operator_from_str("+")(1,
                                                                     1) == 2