(self)
| 2305 | self.assertEqual(g(D()), "B") |
| 2306 | |
| 2307 | def test_register_decorator(self): |
| 2308 | @functools.singledispatch |
| 2309 | def g(obj): |
| 2310 | return "base" |
| 2311 | @g.register(int) |
| 2312 | def g_int(i): |
| 2313 | return "int %s" % (i,) |
| 2314 | self.assertEqual(g(""), "base") |
| 2315 | self.assertEqual(g(12), "int 12") |
| 2316 | self.assertIs(g.dispatch(int), g_int) |
| 2317 | self.assertIs(g.dispatch(object), g.dispatch(str)) |
| 2318 | # Note: in the assert above this is not g. |
| 2319 | # @singledispatch returns the wrapper. |
| 2320 | |
| 2321 | def test_wrapping_attributes(self): |
| 2322 | @functools.singledispatch |
nothing calls this directly
no test coverage detected