Пример #1
0
class TestLibrary:
    @pytest.mark.parametrize("name, value, prop, expected", (
        ("mylib", None, "as_lib_dep", "mylib"),
        ("mylib", None, "as_tuple", ("mylib", None)),
        ("mylib", "1.2.3", "as_lib_dep", "[email protected]"),
        ("mylib", "1.2.3", "as_tuple", ("mylib", "1.2.3")),
    ))
    def test_properties(self, name, value, prop, expected):
        target = core.Library(name, value)

        actual = getattr(target, prop)

        assert actual == expected

    @pytest.mark.parametrize("comparison, other, expected", (
        ("__eq__", core.Library(name="libfoo", version="1.2.3"), True),
        ("__eq__", core.Library(name="libfoo", version="1.2.4"), False),
        ("__eq__", core.Library(name="libbar", version="1.2.3"), False),
        ("__eq__", 1000, NotImplemented),
        ("__eq__", "1000", NotImplemented),
        ("__eq__", True, NotImplemented),
        ("__eq__", object(), NotImplemented),
        ("__eq__", None, NotImplemented),
    ))
    def test_comparison(self, comparison, other, expected):
        target = core.Library(name="libfoo", version="1.2.3")

        actual = getattr(target, comparison)(other)

        assert actual == expected
Пример #2
0
    def test_comparison(self, comparison, other, expected):
        target = core.Library(name="libfoo", version="1.2.3")

        actual = getattr(target, comparison)(other)

        assert actual == expected
Пример #3
0
    def test_properties(self, name, version, repository, prop, expected):
        target = core.Library(name, version, repository)

        actual = getattr(target, prop)

        assert actual == expected
Пример #4
0
    def test_properties(self, name, value, prop, expected):
        target = core.Library(name, value)

        actual = getattr(target, prop)

        assert actual == expected