4
from twisted.trial import unittest
5
from twisted.python import log
6
from twisted.python.reflect import namedAny
7
from epsilon.setuphelper import _regeneratePluginCache
9
class TestCacheRegeneration(unittest.TestCase):
12
self.removedModules = []
13
for modname in self.removeModules:
15
module = namedAny(modname)
16
self.removedModules.append(module)
18
print 'COULD NOT LOAD', modname
19
self.sysmodules = sys.modules.copy()
20
self.syspath = sys.path[:]
22
for module in self.removedModules:
23
for ent in self.syspath:
24
if module.__file__.startswith(ent):
25
while ent in sys.path:
28
for modname in self.sysmodules:
29
if modname.startswith(module.__name__):
31
sys.modules.pop(modname)
32
assert rem, 'NO HITS: %r:%r' % (module,module.__name__)
34
def testRegeneratingIt(self):
35
for mod in self.removedModules:
36
self.failIf(mod.__name__ in sys.modules, 'Started with %r loaded: %r' % (mod.__name__, sys.path))
37
_regeneratePluginCache(['axiom', 'xmantissa'])
38
log.flushErrors(ImportError) # This is necessary since there are Axiom
39
# plugins that depend on Mantissa, so when
40
# Axiom is installed, Mantissa-dependent
41
# powerups are, but Mantissa isn't some
42
# harmless tracebacks are printed.
43
for mod in self.removedModules:
44
self.failIf(mod.__name__ in sys.modules, 'Loaded %r: %r' % (mod.__name__, sys.path))
46
testRegeneratingIt.skip = """
47
This test really ought to be the dependency-direction test from old
48
Quotient. As it currently stands it's just broken.
52
sys.path[:] = self.syspath
54
sys.modules.update(self.sysmodules)
56
class WithoutAxiom(TestCacheRegeneration):
57
removeModules = ['axiom']
59
class WithoutMantissa(TestCacheRegeneration):
60
removeModules = ['xmantissa']
62
class WithoutEither(TestCacheRegeneration):
63
removeModules = ['xmantissa', 'axiom']