def setUp(self):
        """
        Configure L{twisted.python.components.registerAdapter} to mutate an
        alternate registry to improve test isolation.
        """
        # Create a brand new, empty registry and put it onto the components
        # module where registerAdapter will use it.  Also ensure that it goes
        # away at the end of the test.
        scratchRegistry = AdapterRegistry()
        self.patch(components, 'globalRegistry', scratchRegistry)
        # Hook the new registry up to the adapter lookup system and ensure that
        # association is also discarded after the test.
        hook = _addHook(scratchRegistry)
        self.addCleanup(_removeHook, hook)

        Configure L{twisted.python.components.registerAdapter} to mutate an
        alternate registry to improve test isolation.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/test/test_components.py