Beispiel #1
0
 def test_asdict_key(self):
     dict_a = {'foo': 1}
     dict_b = {'foo': 2}
     self.assertEqual(asdict([dict_a, dict_b], key='foo'), {
         1: dict_a,
         2: dict_b
     })
Beispiel #2
0
    def test_asdict_attr(self):
        class Simple(object):
            def __init__(self, test):
                self.test = test

            def __repr__(self):
                return "<Simple: {}>".format(self.test)

        simple_a = Simple(1)
        simple_b = Simple(2)

        self.assertEqual(asdict([simple_a, simple_b], attr='test'), {1: simple_a, 2: simple_b})
def test_asdict_attr():
    class Simple(object):
        def __init__(self, foo):
            self.foo = foo

        def __repr__(self):
            return "<Simple: {}>".format(self.foo)

    x = Simple(1)
    y = Simple(2)

    assert asdict([x, y], attr='foo') == {1: x, 2: y}
Beispiel #4
0
def test_asdict_attr():
    class Simple(object):
        def __init__(self, foo):
            self.foo = foo

        def __repr__(self):
            return "<Simple: {}>".format(self.foo)

    x = Simple(1)
    y = Simple(2)

    assert asdict([x, y], attr="foo") == {1: x, 2: y}
def test_asdict_key():
    x = {'foo': 1}
    y = {'foo': 2}
    assert asdict([x, y], key='foo') == {1: x, 2: y}
Beispiel #6
0
def test_asdict_key():
    x = {"foo": 1}
    y = {"foo": 2}
    assert asdict([x, y], key="foo") == {1: x, 2: y}