def setUp(self):
        self.tempdirs = []
        self._mock_extensions = []

        self.test_dir = self.tempdir()
        self.data_dir = os.path.join(self.test_dir, 'data')
        self.config_dir = os.path.join(self.test_dir, 'config')
        self.system_data_dir = os.path.join(self.test_dir, 'system_data')
        self.system_config_dir = os.path.join(self.test_dir, 'system_config')
        self.system_path = [self.system_data_dir]
        self.system_config_path = [self.system_config_dir]

        self.patches = []
        p = patch.dict(
            'os.environ', {
                'JUPYTER_CONFIG_DIR': self.config_dir,
                'JUPYTER_DATA_DIR': self.data_dir,
            })
        self.patches.append(p)
        for mod in (paths, nbextensions):
            p = patch.object(mod, 'SYSTEM_JUPYTER_PATH', self.system_path)
            self.patches.append(p)
            p = patch.object(mod, 'ENV_JUPYTER_PATH', [])
            self.patches.append(p)
        for mod in (paths, extensions):
            p = patch.object(mod, 'SYSTEM_CONFIG_PATH',
                             self.system_config_path)
            self.patches.append(p)
            p = patch.object(mod, 'ENV_CONFIG_PATH', [])
            self.patches.append(p)
        # avoid adding the user site to the config paths with jupyter-core >= 4.9
        # https://github.com/jupyter/jupyter_core/pull/242
        p = patch.object(site, 'ENABLE_USER_SITE', False)
        self.patches.append(p)
        for p in self.patches:
            p.start()
            self.addCleanup(p.stop)
        # verify our patches
        self.assertEqual(paths.jupyter_config_path(),
                         [self.config_dir] + self.system_config_path)
        self.assertEqual(extensions._get_config_dir(user=False),
                         self.system_config_dir)
        self.assertEqual(paths.jupyter_path(),
                         [self.data_dir] + self.system_path)
Exemplo n.º 2
0
    def setUp(self):
        self.tempdirs = []
        self._mock_extensions = []

        self.test_dir = self.tempdir()
        self.data_dir = os.path.join(self.test_dir, 'data')
        self.config_dir = os.path.join(self.test_dir, 'config')
        self.system_data_dir = os.path.join(self.test_dir, 'system_data')
        self.system_config_dir = os.path.join(self.test_dir, 'system_config')
        self.system_path = [self.system_data_dir]
        self.system_config_path = [self.system_config_dir]

        self.patches = []
        p = patch.dict(
            'os.environ', {
                'JUPYTER_CONFIG_DIR': self.config_dir,
                'JUPYTER_DATA_DIR': self.data_dir,
            })
        self.patches.append(p)
        for mod in (paths, nbextensions):
            p = patch.object(mod, 'SYSTEM_JUPYTER_PATH', self.system_path)
            self.patches.append(p)
            p = patch.object(mod, 'ENV_JUPYTER_PATH', [])
            self.patches.append(p)
        for mod in (paths, extensions):
            p = patch.object(mod, 'SYSTEM_CONFIG_PATH',
                             self.system_config_path)
            self.patches.append(p)
            p = patch.object(mod, 'ENV_CONFIG_PATH', [])
            self.patches.append(p)
        for p in self.patches:
            p.start()
            self.addCleanup(p.stop)
        # verify our patches
        self.assertEqual(paths.jupyter_config_path(),
                         [self.config_dir] + self.system_config_path)
        self.assertEqual(extensions._get_config_dir(user=False),
                         self.system_config_dir)
        self.assertEqual(paths.jupyter_path(),
                         [self.data_dir] + self.system_path)
    def setUp(self):
        self.tempdirs = []
        self._mock_extensions = []

        self.test_dir = self.tempdir()
        self.data_dir = os.path.join(self.test_dir, 'data')
        self.config_dir = os.path.join(self.test_dir, 'config')
        self.system_data_dir = os.path.join(self.test_dir, 'system_data')
        self.system_config_dir = os.path.join(self.test_dir, 'system_config')
        self.system_path = [self.system_data_dir]
        self.system_config_path = [self.system_config_dir]
        
        self.patches = []
        p = patch.dict('os.environ', {
            'JUPYTER_CONFIG_DIR': self.config_dir,
            'JUPYTER_DATA_DIR': self.data_dir,
        })
        self.patches.append(p)
        for mod in (paths, nbextensions):
            p = patch.object(mod,
                'SYSTEM_JUPYTER_PATH', self.system_path)
            self.patches.append(p)
            p = patch.object(mod,
                'ENV_JUPYTER_PATH', [])
            self.patches.append(p)
        for mod in (paths, extensions):
            p = patch.object(mod,
                'SYSTEM_CONFIG_PATH', self.system_config_path)
            self.patches.append(p)
            p = patch.object(mod,
                'ENV_CONFIG_PATH', [])
            self.patches.append(p)
        for p in self.patches:
            p.start()
            self.addCleanup(p.stop)
        # verify our patches
        self.assertEqual(paths.jupyter_config_path(), [self.config_dir] + self.system_config_path)
        self.assertEqual(extensions._get_config_dir(user=False), self.system_config_dir)
        self.assertEqual(paths.jupyter_path(), [self.data_dir] + self.system_path)