def _testDetectNewFiles(self):
writeFileName = sibpath(plugins.__file__, 'pluginextra.py')
try:
wf = file(writeFileName, 'w')
except IOError, ioe:
if ioe.errno == errno.EACCES:
raise unittest.SkipTest(
"No permission to add things to twisted.plugins")
else:
raise
else:
try:
wf.write(begintest)
wf.flush()
self.failIfIn('twisted.plugins.pluginextra', sys.modules)
self.failIf(hasattr(sys.modules['twisted.plugins'], 'pluginextra'),
"plugins package still has pluginextra module")
plgs = list(plugin.getPlugins(plugin.ITestPlugin))
self.assertEquals(
len(plgs), 2,
"Unexpected plugins found: %r" % (
[p.__name__ for p in plgs]))
names = ['TestPlugin', 'FourthTestPlugin']
for p in plgs:
names.remove(p.__name__)
p.test1()
finally:
wf.close()
self._unimportPythonModule(
sys.modules['twisted.plugins.pluginextra'],
True)
评论列表
文章目录