Beispiel #1
0
    def test_method_eq_ne(self):
        sample = [("A", "b"), ("C", "d"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        assert dic.items() == [(k.upper(), v) for k, v in sample]

        assert dic.items() != []
Beispiel #2
0
    def test_method_eq_ne(self):
        sample = [("A", "b"), ("c", "d"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        assert dic.keys() == [k.lower() for k, _ in sample]

        assert dic.keys() != []
Beispiel #3
0
    def test_method_contains(self):
        sample = [("A", "b"), ("c", "d"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        assert "a" in dic.keys()  # noqa: SIM118
        assert "A" in dic.keys()  # noqa: SIM118
        assert "d" not in dic.keys()  # noqa: SIM118
        assert 123 not in dic.keys()  # noqa: SIM118
Beispiel #4
0
    def test_init_with_mapping(self):
        sample = {"A": "b", "c": "d", "e": "f"}
        dic = FrozenTolerantMagicDict(sample)

        assert list(dic.items()) == list({
            "a": "b",
            "c": "d",
            "e": "f"
        }.items())
Beispiel #5
0
    def test_method_xor(self):
        sample = [("a", "b"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        sample2 = [("A", "b"), ("c", "d")]
        dic2 = FrozenTolerantMagicDict(sample2)

        assert dic.keys() ^ dic2.keys() == set(["e"])
Beispiel #6
0
    def test_method_ge(self):
        sample = [("a", "b"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        sample2 = [("a", "b"), ("c", "d")]
        dic2 = FrozenTolerantMagicDict(sample2)

        assert dic.keys() >= dic2.keys()
Beispiel #7
0
    def test_method_sub(self):
        sample = [("a", "b"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        sample2 = [("a", "b"), ("c", "d")]
        dic2 = FrozenTolerantMagicDict(sample2)

        assert dic.items() - dic2.items() == set([("e", "f")])
Beispiel #8
0
    def test_method_reversed(self):
        sample = [("A", "b"), ("c", "d"), ("C", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        assert list(reversed(dic.keys())) == list(
            reversed([k.lower() for k, _ in sample]))
Beispiel #9
0
    def test_method_reversed(self):
        sample = [("a", "b"), ("C", "d"), ("c", "d"), ("E", "f")]
        dic = FrozenTolerantMagicDict(sample)

        assert list(reversed(dic.items())) == list(
            reversed([(k.lower(), v) for k, v in sample]))
Beispiel #10
0
    def test_method_contains(self):
        sample = [("A", "b"), ("c", "d"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        assert ("a", "b") in dic.items()
        assert ("B", "b") not in dic.items()
Beispiel #11
0
    def test_copy(self):
        dic = FrozenTolerantMagicDict([("a", "b"), ("a", "d"), ("a", "f")])

        dic_copy = dic.copy()

        assert dic == dic_copy
Beispiel #12
0
    def test_get_iter(self):
        dic = FrozenTolerantMagicDict([("a", "b"), ("A", "d"), ("a", "f")])

        assert list(dic.get_iter("A")) == ["b", "d", "f"]
Beispiel #13
0
    def test_get_last(self):
        dic = FrozenTolerantMagicDict([("A", "b"), ("a", "d"), ("a", "f")])

        assert dic.get_last("A") == "f"

        assert dic.get_last("b") is None
Beispiel #14
0
    def test_method_getitem(self):
        dic = FrozenTolerantMagicDict([("a", "b"), ("a", "c")])

        assert dic["A"] == "b"
Beispiel #15
0
    def test_init_with_kwargs(self):
        sample = {"a": "b", "c": "d", "e": "f"}
        dic = FrozenTolerantMagicDict(**sample)

        assert sample.items() == dic.items()
Beispiel #16
0
    def test_init_with_iter(self):
        sample = [("A", "b"), ("c", "d"), ("c", "d"), ("e", "f")]
        dic = FrozenTolerantMagicDict(sample)

        assert list(dic.items()) == [(k.lower(), v) for k, v in sample]