def test_lookup(): f = PlainTextFormatter() f.for_type(C, foo_printer) nt.assert_is(f.lookup(C()), foo_printer) with nt.assert_raises(KeyError): f.lookup(A())
def test_lookup(): f = PlainTextFormatter() f.for_type(C, foo_printer) assert f.lookup(C()) is foo_printer with pytest.raises(KeyError): f.lookup(A())
def test_lookup_string(): f = PlainTextFormatter() type_str = '%s.%s' % (C.__module__, 'C') f.for_type(type_str, foo_printer) nt.assert_is(f.lookup(C()), foo_printer) # should move from deferred to imported dict nt.assert_not_in(_mod_name_key(C), f.deferred_printers) nt.assert_in(C, f.type_printers)
def test_lookup_string(): f = PlainTextFormatter() type_str = '%s.%s' % (C.__module__, 'C') f.for_type(type_str, foo_printer) assert f.lookup(C()) is foo_printer # should move from deferred to imported dict assert _mod_name_key(C) not in f.deferred_printers assert C in f.type_printers