5 from nose.suite import ContextSuiteFactory
7 support = os.path.abspath(os.path.join(os.path.dirname(__file__), 'support'))
9 class TestContextSuiteFactory(unittest.TestCase):
12 self._mods = sys.modules.copy()
13 self._path = sys.path[:]
14 sys.path.insert(0, os.path.join(support, 'package2'))
17 to_del = [ m for m in sys.modules.keys() if
22 sys.modules.update(self._mods)
25 def test_find_context(self):
26 from test_pak import test_mod
28 factory = ContextSuiteFactory()
29 tests = [case.FunctionTestCase(test_mod.test_add),
30 case.FunctionTestCase(test_mod.test_minus)]
31 suite = factory(tests)
32 self.assertEqual(suite.context, test_mod)
34 def test_ancestry(self):
35 from test_pak.test_sub.test_mod import TestMaths
36 from test_pak.test_sub import test_mod
37 from test_pak import test_sub
40 factory = ContextSuiteFactory()
41 ancestry = [l for l in factory.ancestry(TestMaths)]
42 self.assertEqual(ancestry,
43 [test_mod, test_sub, test_pak])
46 if __name__ == '__main__':