コード例 #1
0
 def test_load_extension(self):
     sys.modules['ipython_environment'] = MockIpythonEnvironment
     load_ipython_extension(None)
     self.assertEqual(MockIpythonEnvironment.environment,
                      Environment.current_env())
     unload_ipython_extension(None)
     with self.assertRaises(NoEnvironment):
         Environment.current_env()
     sys.modules['ipython_environment'] = None
コード例 #2
0
 def test_context_manager(self):
     e = Environment()
     with e:
         self.assertIs(Environment.current_env(), e)
     with self.assertRaises(NoEnvironment):
         Environment.current_env()