示例#1
0
def test_fields_str_ignore_none():
    Foo = namedtuple('Foo', 'bar')
    to_str = common.fields_str('Foo', ('bar', ), False)

    assert to_str(Foo(42)) == ('Foo({%r: 42})' % 'bar')
    assert to_str(Foo(None)) == 'Foo({})'
示例#2
0
def test_fields_str_ignore_none():
    Foo = namedtuple('Foo', 'bar')
    to_str = common.fields_str('Foo', ('bar',), False)

    assert to_str(Foo(42)) == ('Foo({%r: 42})' % 'bar')
    assert to_str(Foo(None)) == 'Foo({})'
示例#3
0
def test_fields_str():
    Foo = namedtuple('Foo', 'bar')
    to_str = common.fields_str('Foo', ('bar', ))

    assert to_str(Foo(42)) == ('Foo({%r: 42})' % 'bar')
    assert to_str(Foo(None)) == ('Foo({%r: None})' % 'bar')
示例#4
0
def test_fields_str():
    Foo = namedtuple('Foo', 'bar')
    to_str = common.fields_str('Foo', ('bar',))

    assert to_str(Foo(42)) == ('Foo({%r: 42})' % 'bar')
    assert to_str(Foo(None)) == ('Foo({%r: None})' % 'bar')