コード例 #1
0
ファイル: test_utils.py プロジェクト: Hoops/sqlalchemy
    def test_multi_kw(self):
        class Foo(object):
            def __init__(self, a, b, c=3, d=4):
                self.a = a
                self.b = b
                self.c = c
                self.d = d
        class Bar(Foo):
            def __init__(self, e, f, g=5, **kw):
                self.e = e
                self.f = f
                self.g = g
                super(Bar, self).__init__(**kw)

        eq_(
            util.generic_repr(
                Bar('e', 'f', g=7, a=6, b=5, d=9),
                to_inspect=[Bar, Foo]
            ),
            "Bar('e', 'f', g=7, a=6, b=5, d=9)"
        )

        eq_(
            util.generic_repr(
                Bar('e', 'f', a=6, b=5),
                to_inspect=[Bar, Foo]
            ),
            "Bar('e', 'f', a=6, b=5)"
        )
コード例 #2
0
 def test_no_init(self):
     class Foo(object):
         pass
     eq_(
         util.generic_repr(Foo()),
         "Foo()"
     )
コード例 #3
0
ファイル: test_utils.py プロジェクト: ContextLogic/sqlalchemy
 def test_no_init(self):
     class Foo(object):
         pass
     eq_(
         util.generic_repr(Foo()),
         "Foo()"
     )
コード例 #4
0
    def test_significant_vargs(self):
        class Foo(object):
            def __init__(self, a, b, *args):
                self.a = a
                self.b = b
                self.args = args

        eq_(util.generic_repr(Foo(1, 2, 3, 4)), "Foo(1, 2, 3, 4)")
コード例 #5
0
 def test_no_args(self):
     class Foo(object):
         def __init__(self):
             pass
     eq_(
         util.generic_repr(Foo()),
         "Foo()"
     )
コード例 #6
0
    def test_all_positional(self):
        class Foo(object):
            def __init__(self, a, b, c):
                self.a = a
                self.b = b
                self.c = c

        eq_(util.generic_repr(Foo(1, 2, 3)), "Foo(1, 2, 3)")
コード例 #7
0
    def test_discard_vargs_kwargs(self):
        class Foo(object):
            def __init__(self, a, b, *args, **kw):
                self.a = a
                self.b = b
                self.c, self.d = args[0:2]

        eq_(util.generic_repr(Foo(1, 2, 3, 4, x=7, y=4)), "Foo(1, 2)")
コード例 #8
0
ファイル: test_utils.py プロジェクト: ContextLogic/sqlalchemy
 def test_no_args(self):
     class Foo(object):
         def __init__(self):
             pass
     eq_(
         util.generic_repr(Foo()),
         "Foo()"
     )
コード例 #9
0
    def test_kw_defaults(self):
        class Foo(object):
            def __init__(self, a=1, b=2, c=3, d=4):
                self.a = a
                self.b = b
                self.c = c
                self.d = d

        eq_(util.generic_repr(Foo(1, 5, 3, 7)), "Foo(b=5, d=7)")
コード例 #10
0
    def test_positional_plus_kw(self):
        class Foo(object):
            def __init__(self, a, b, c=5, d=4):
                self.a = a
                self.b = b
                self.c = c
                self.d = d

        eq_(util.generic_repr(Foo(1, 2, 3, 6)), "Foo(1, 2, c=3, d=6)")
コード例 #11
0
ファイル: test_utils.py プロジェクト: ContextLogic/sqlalchemy
 def test_discard_vargs(self):
     class Foo(object):
         def __init__(self, a, b, *args):
             self.a = a
             self.b = b
             self.c, self.d = args[0:2]
     eq_(
         util.generic_repr(Foo(1, 2, 3, 4)),
         "Foo(1, 2)"
     )
コード例 #12
0
ファイル: test_utils.py プロジェクト: ContextLogic/sqlalchemy
 def test_all_positional(self):
     class Foo(object):
         def __init__(self, a, b, c):
             self.a = a
             self.b = b
             self.c = c
     eq_(
         util.generic_repr(Foo(1, 2, 3)),
         "Foo(1, 2, 3)"
     )
コード例 #13
0
ファイル: test_utils.py プロジェクト: ContextLogic/sqlalchemy
 def test_significant_vargs(self):
     class Foo(object):
         def __init__(self, a, b, *args):
             self.a = a
             self.b = b
             self.args = args
     eq_(
         util.generic_repr(Foo(1, 2, 3, 4)),
         "Foo(1, 2, 3, 4)"
     )
コード例 #14
0
ファイル: test_utils.py プロジェクト: ContextLogic/sqlalchemy
 def test_kw_defaults(self):
     class Foo(object):
         def __init__(self, a=1, b=2, c=3, d=4):
             self.a = a
             self.b = b
             self.c = c
             self.d = d
     eq_(
         util.generic_repr(Foo(1, 5, 3, 7)),
         "Foo(b=5, d=7)"
     )
コード例 #15
0
ファイル: test_utils.py プロジェクト: ContextLogic/sqlalchemy
 def test_positional_plus_kw(self):
     class Foo(object):
         def __init__(self, a, b, c=5, d=4):
             self.a = a
             self.b = b
             self.c = c
             self.d = d
     eq_(
         util.generic_repr(Foo(1, 2, 3, 6)),
         "Foo(1, 2, c=3, d=6)"
     )
コード例 #16
0
ファイル: test_utils.py プロジェクト: xixibu/sqlalchemy
    def test_multi_kw_repeated(self):
        class Foo(object):
            def __init__(self, a=1, b=2):
                self.a = a
                self.b = b

        class Bar(Foo):
            def __init__(self, b=3, c=4, **kw):
                self.c = c
                super(Bar, self).__init__(b=b, **kw)

        eq_(util.generic_repr(Bar(a='a', b='b', c='c'), to_inspect=[Bar, Foo]),
            "Bar(b='b', c='c', a='a')")
コード例 #17
0
ファイル: test_utils.py プロジェクト: xixibu/sqlalchemy
    def test_multi_kw(self):
        class Foo(object):
            def __init__(self, a, b, c=3, d=4):
                self.a = a
                self.b = b
                self.c = c
                self.d = d

        class Bar(Foo):
            def __init__(self, e, f, g=5, **kw):
                self.e = e
                self.f = f
                self.g = g
                super(Bar, self).__init__(**kw)

        eq_(
            util.generic_repr(Bar('e', 'f', g=7, a=6, b=5, d=9),
                              to_inspect=[Bar, Foo]),
            "Bar('e', 'f', g=7, a=6, b=5, d=9)")

        eq_(util.generic_repr(Bar('e', 'f', a=6, b=5), to_inspect=[Bar, Foo]),
            "Bar('e', 'f', a=6, b=5)")
コード例 #18
0
ファイル: test_utils.py プロジェクト: Hoops/sqlalchemy
    def test_multi_kw_repeated(self):
        class Foo(object):
            def __init__(self, a=1, b=2):
                self.a = a
                self.b = b
        class Bar(Foo):
            def __init__(self, b=3, c=4, **kw):
                self.c = c
                super(Bar, self).__init__(b=b, **kw)

        eq_(
            util.generic_repr(
                Bar(a='a', b='b', c='c'),
                to_inspect=[Bar, Foo]
            ),
            "Bar(b='b', c='c', a='a')"
        )
コード例 #19
0
 def __repr__(self):
     return util.generic_repr(self)
コード例 #20
0
 def __repr__(self):
     return util.generic_repr(self)