code: def test_mro_conflicts(self):
      @singledispatch
      def g(obj):
          return "base"
  
      class O(c.Sized):
          def __len__(self):
              return 0
  
      o = O()
      self.assertEqual(g(o), "base")
      g.register(c.Iterable)(lambda arg: "iterable")
      g.register(c.Container)(lambda arg: "container")
      g.register(c.Sized)(lambda arg: "sized")
      g.register(c.Set)(lambda arg: "set")
      self.assertEqual(g(o), "sized")
      c.Iterable.register(O)
      self.assertEqual(g(o), "sized")
      c.Container.register(O)
      with assertRaises(RuntimeError):  # was "sized" because in mro
          self.assertEqual(g(o), "sized")
      c.Set.register(O)
      self.assertEqual(g(o), "set")
  
      class P(object):
          pass
  
      p = P()
      self.assertEqual(g(p), "base")
      c.Iterable.register(P)
      self.assertEqual(g(p), "iterable")
      c.Container.register(P)
  
      with assertRaises(RuntimeError):
          self.assertEqual(g(p), "iterable")
  
      class Q(c.Sized):
          def __len__(self):
              return 0
  
      q = Q()
      self.assertEqual(g(q), "sized")
      c.Iterable.register(Q)
      self.assertEqual(g(q), "sized")
      c.Set.register(Q)
      self.assertEqual(g(q), "set")
      # because c.Set is a subclass of c.Sized and c.Iterable
  
      @singledispatch
      def h(obj):
          return "base"
  
      @h.register(c.Sized)
      def h_sized(arg):
          return "sized"
  
      @h.register(c.Container)
      def h_container(arg):
          return "container"
  
      # Even though Sized and Container are explicit bases of MutableMapping,
      # this ABC is implicitly registered on defaultdict which makes all of
      # MutableMapping's bases implicit as well from defaultdict's
      # perspective.
      with assertRaises(RuntimeError):
          self.assertEqual(h(defaultdict(lambda: 0)), "sized")
  
      class R(defaultdict):
          pass
  
      c.MutableSequence.register(R)
  
      @singledispatch
      def i(obj):
          return "base"
  
      @i.register(c.MutableMapping)
      def i_mapping(arg):
          return "mapping"
  
      @i.register(c.MutableSequence)
      def i_sequence(arg):
          return "sequence"
  
      r = R()
      with assertRaises(RuntimeError):  # was no error
          self.assertEqual(i(r), "sequence")
  
      class S(object):
          pass
  
      class T(S, c.Sized):
          def __len__(self):
              return 0
  
      t = T()
      self.assertEqual(h(t), "sized")
      c.Container.register(T)
      self.assertEqual(
          h(t), "sized"
      )  # because it's explicitly in the MRO
  
      class U(object):
          def __len__(self):
              return 0
  
      u = U()
      self.assertEqual(h(u), "sized")
      # implicit Sized subclass inferred
      # from the existence of __len__()
  
      c.Container.register(U)
      # There is no preference for registered versus inferred ABCs.
      with assertRaises(RuntimeError):
          h(u)
  
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 8 for calling the TestSingleDispatch obj's underlying member method code with example usage: obj.test_mro_conflicts() and returns: str, str, str, str, str, str, str, int, int, int, int