'Warnings emitted by a function the source code of which is not
available can still be flushed.'

def test_missingSource(self):

    package = FilePath(self.mktemp().encode('utf-8')).child('twisted_private_helper')
    package.makedirs()
    package.child('__init__.py').setContent('')
    package.child('missingsourcefile.py').setContent('\nimport    warnings\ndef    foo():\n                warnings.warn("oh    no")\n')
    pathEntry = package.parent().path.decode('utf-8')
    sys.path.insert(0, pathEntry)
    self.addCleanup(sys.path.remove, pathEntry)
    from twisted_private_helper import missingsourcefile
    self.addCleanup(sys.modules.pop, 'twisted_private_helper')
    self.addCleanup(sys.modules.pop, missingsourcefile.__name__)
    package.child('missingsourcefile.py').remove()
    missingsourcefile.foo()
    self.assertEqual(len(self.flushWarnings([missingsourcefile.foo])), 1)
