'Verify that when C{components.ALLOW_DUPLICATES} is set to C{True}, new
adapter registrations for a particular from-type/interface and
to-interface pair replace older registrations.'

def _duplicateAdapterForClassOrInterfaceAllowed(self, original):

    firstAdapter = (lambda o: False)
    secondAdapter = (lambda o: True)
    class TheInterface(Interface, ):
        pass
    components.registerAdapter(firstAdapter, original, TheInterface)
    components.ALLOW_DUPLICATES = True
    try:
        components.registerAdapter(secondAdapter, original, TheInterface)
        self.assertIs(components.getAdapterFactory(original, TheInterface, None), secondAdapter)
    finally:
        components.ALLOW_DUPLICATES = False
    self.assertRaises(ValueError, components.registerAdapter, firstAdapter, original, TheInterface)
    self.assertIs(components.getAdapterFactory(original, TheInterface, None), secondAdapter)
