def test_renamedSource(self):
        package = FilePath(self.mktemp()).child('twisted_private_helper')
        package.makedirs()
        package.child('__init__.py').setContent('')
        package.child('module.py').setContent('''
import warnings
def foo():
    warnings.warn("oh no")
''')
        sys.path.insert(0, package.parent().path)
        self.addCleanup(sys.path.remove, package.parent().path)

        # Import it to cause pycs to be generated
        from twisted_private_helper import module

        # Clean up the state resulting from that import; we're not going to use
        # this module, so it should go away.
        del sys.modules['twisted_private_helper']
        del sys.modules[module.__name__]

        # Rename the source directory
        package.moveTo(package.sibling('twisted_renamed_helper'))

        # Import the newly renamed version
        from twisted_renamed_helper import module
        self.addCleanup(sys.modules.pop, 'twisted_renamed_helper')
        self.addCleanup(sys.modules.pop, module.__name__)

        # Generate the warning
        module.foo()

        # Flush it
        self.assertEqual(len(self.flushWarnings([module.foo])), 1)
Warnings emitted by a function defined in a file which has been renamed
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/trial/test/test_warning.py/FlushWarningsTests.test_renamedSource