Show More
@@ -88,3 +88,47 def test_bad_precision(): | |||||
88 | nt.assert_raises(ValueError, set_fp, -1) |
|
88 | nt.assert_raises(ValueError, set_fp, -1) | |
89 |
|
89 | |||
90 |
|
90 | |||
|
91 | def test_for_type(): | |||
|
92 | f = PlainTextFormatter() | |||
|
93 | class C(): | |||
|
94 | pass | |||
|
95 | ||||
|
96 | def foo(c, p, cycle): | |||
|
97 | p.text('C') | |||
|
98 | ||||
|
99 | # initial return is None | |||
|
100 | assert f.for_type(C, foo) is None | |||
|
101 | # no func queries | |||
|
102 | assert f.for_type(C) is foo | |||
|
103 | # shouldn't change anything | |||
|
104 | assert f.for_type(C) is foo | |||
|
105 | # None should clear and return foo | |||
|
106 | assert f.for_type(C, None) is foo | |||
|
107 | # verify clear | |||
|
108 | assert C not in f.type_printers | |||
|
109 | assert f.for_type(C) is None | |||
|
110 | ||||
|
111 | ||||
|
112 | def test_for_type_by_name(): | |||
|
113 | f = PlainTextFormatter() | |||
|
114 | class C(): | |||
|
115 | pass | |||
|
116 | ||||
|
117 | mod = C.__module__ | |||
|
118 | ||||
|
119 | def foo(c, p, cycle): | |||
|
120 | p.text('C') | |||
|
121 | ||||
|
122 | # initial return is None | |||
|
123 | assert f.for_type_by_name(mod, 'C', foo) is None | |||
|
124 | # no func queries | |||
|
125 | assert f.for_type_by_name(mod, 'C') is foo | |||
|
126 | # shouldn't change anything | |||
|
127 | assert f.for_type_by_name(mod, 'C') is foo | |||
|
128 | # None should clear and return foo | |||
|
129 | assert f.for_type_by_name(mod, 'C', None) is foo | |||
|
130 | # verify clear | |||
|
131 | assert (mod, 'C') not in f.deferred_printers | |||
|
132 | assert f.for_type_by_name(mod, 'C') is None | |||
|
133 | ||||
|
134 |
General Comments 0
You need to be logged in to leave comments.
Login now