code: def test_register_abc(self):
      d = {"a": "b"}
      l = [1, 2, 3]
      s = set([object(), None])
      f = frozenset(s)
      t = (1, 2, 3)
  
      @singledispatch
      def g(obj):
          return "base"
  
      self.assertEqual(g(d), "base")
      self.assertEqual(g(l), "base")
      self.assertEqual(g(s), "base")
      self.assertEqual(g(f), "base")
      self.assertEqual(g(t), "base")
  
      g.register(c.Sized)(lambda obj: "sized")
      self.assertEqual(g(d), "sized")
      self.assertEqual(g(l), "sized")
      self.assertEqual(g(s), "sized")
      self.assertEqual(g(f), "sized")
      self.assertEqual(g(t), "sized")
  
      g.register(c.MutableMapping)(lambda obj: "mutablemapping")
      self.assertEqual(g(d), "mutablemapping")
      self.assertEqual(g(l), "sized")
      self.assertEqual(g(s), "sized")
      self.assertEqual(g(f), "sized")
      self.assertEqual(g(t), "sized")
  
      if hasattr(c, "ChainMap"):
          g.register(c.ChainMap)(lambda obj: "chainmap")
          # irrelevant ABCs registered
          self.assertEqual(g(d), "mutablemapping")
          self.assertEqual(g(l), "sized")
          self.assertEqual(g(s), "sized")
          self.assertEqual(g(f), "sized")
          self.assertEqual(g(t), "sized")
  
      g.register(c.MutableSequence)(lambda obj: "mutablesequence")
      self.assertEqual(g(d), "mutablemapping")
      self.assertEqual(g(l), "mutablesequence")
      self.assertEqual(g(s), "sized")
      self.assertEqual(g(f), "sized")
      self.assertEqual(g(t), "sized")
  
      g.register(c.MutableSet)(lambda obj: "mutableset")
      self.assertEqual(g(d), "mutablemapping")
      self.assertEqual(g(l), "mutablesequence")
      self.assertEqual(g(s), "mutableset")
      self.assertEqual(g(f), "sized")
      self.assertEqual(g(t), "sized")
  
      g.register(c.Mapping)(lambda obj: "mapping")
      self.assertEqual(g(d), "mutablemapping")  # not specific enough
      self.assertEqual(g(l), "mutablesequence")
      self.assertEqual(g(s), "mutableset")
      self.assertEqual(g(f), "sized")
      self.assertEqual(g(t), "sized")
  
      g.register(c.Sequence)(lambda obj: "sequence")
      self.assertEqual(g(d), "mutablemapping")
      self.assertEqual(g(l), "mutablesequence")
      self.assertEqual(g(s), "mutableset")
      self.assertEqual(g(f), "sized")
      self.assertEqual(g(t), "sequence")
  
      g.register(c.Set)(lambda obj: "set")
      self.assertEqual(g(d), "mutablemapping")
      self.assertEqual(g(l), "mutablesequence")
      self.assertEqual(g(s), "mutableset")
      self.assertEqual(g(f), "set")
      self.assertEqual(g(t), "sequence")
  
      g.register(dict)(lambda obj: "dict")
      self.assertEqual(g(d), "dict")
      self.assertEqual(g(l), "mutablesequence")
      self.assertEqual(g(s), "mutableset")
      self.assertEqual(g(f), "set")
      self.assertEqual(g(t), "sequence")
  
      g.register(list)(lambda obj: "list")
      self.assertEqual(g(d), "dict")
      self.assertEqual(g(l), "list")
      self.assertEqual(g(s), "mutableset")
      self.assertEqual(g(f), "set")
      self.assertEqual(g(t), "sequence")
  
      g.register(set)(lambda obj: "concrete-set")
      self.assertEqual(g(d), "dict")
      self.assertEqual(g(l), "list")
      self.assertEqual(g(s), "concrete-set")
      self.assertEqual(g(f), "set")
      self.assertEqual(g(t), "sequence")
  
      g.register(frozenset)(lambda obj: "frozen-set")
      self.assertEqual(g(d), "dict")
      self.assertEqual(g(l), "list")
      self.assertEqual(g(s), "concrete-set")
      self.assertEqual(g(f), "frozen-set")
      self.assertEqual(g(t), "sequence")
  
      g.register(tuple)(lambda obj: "tuple")
      self.assertEqual(g(d), "dict")
      self.assertEqual(g(l), "list")
      self.assertEqual(g(s), "concrete-set")
      self.assertEqual(g(f), "frozen-set")
      self.assertEqual(g(t), "tuple")
  
imports: from __future__ import absolute_import
  import sys
  import doctest
  import unittest
  import decimal
  import inspect
  import functools
  import collections
  from collections import defaultdict
  from decorator import dispatch_on, contextmanager, decorator
label_desc: Use image node_id 7 for calling the TestSingleDispatch obj's underlying member method code with example usage: obj.test_register_abc() and returns: str