Ejemplo n.º 1
0
class TestDefine:
    @pytest.mark.parametrize("name, value, prop, expected", (
        ("ANSWER", None, "as_build_flag", "-DANSWER"),
        ("ANSWER", None, "as_macro", "#define ANSWER"),
        ("ANSWER", None, "as_tuple", ("ANSWER", None)),
        ("ANSWER", 42, "as_build_flag", "-DANSWER=42"),
        ("ANSWER", 42, "as_macro", "#define ANSWER 42"),
        ("ANSWER", 42, "as_tuple", ("ANSWER", 42)),
    ))
    def test_properties(self, name, value, prop, expected):
        target = core.Define(name, value)

        actual = getattr(target, prop)

        assert actual == expected

    @pytest.mark.parametrize("comparison, other, expected", (
        ("__eq__", core.Define(name="FOO", value=42), True),
        ("__eq__", core.Define(name="FOO", value=13), False),
        ("__eq__", core.Define(name="FOO"), False),
        ("__eq__", core.Define(name="BAR", value=42), False),
        ("__eq__", core.Define(name="BAR"), 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.Define(name="FOO", value=42)

        actual = getattr(target, comparison)(other)

        assert actual == expected
Ejemplo n.º 2
0
    def test_comparison(self, comparison, other, expected):
        target = core.Define(name="FOO", value=42)

        actual = getattr(target, comparison)(other)

        assert actual == expected
Ejemplo n.º 3
0
    def test_properties(self, name, value, prop, expected):
        target = core.Define(name, value)

        actual = getattr(target, prop)

        assert actual == expected