示例#1
0
文件: testing.py 项目: gonzex/abipy
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))
示例#2
0
 def test_something(self):
     assert operator_from_str("==")(1, 1) and operator_from_str("+")(1,
                                                                     1) == 2