Skip to content

Commit 1118c8c

Browse files
committed
Merge pull request from GHSA-m678-f26j-3hrp
1 parent d3f61f3 commit 1118c8c

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

jupyter_core/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def _config_dir_default(self):
8888
def config_file_paths(self):
8989
path = jupyter_config_path()
9090
if self.config_dir not in path:
91+
# Insert config dir as first item.
9192
path.insert(0, self.config_dir)
92-
path.insert(0, os.getcwd())
9393
return path
9494

9595
data_dir = Unicode()

jupyter_core/tests/test_application.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,43 +69,51 @@ def test_generate_config():
6969

7070
def test_load_config():
7171
config_dir = mkdtemp()
72-
wd = mkdtemp()
72+
os.environ["JUPYTER_CONFIG_PATH"] = str(config_dir)
7373
with open(pjoin(config_dir, "dummy_app_config.py"), "w", encoding="utf-8") as f:
7474
f.write("c.DummyApp.m = 1\n")
7575
f.write("c.DummyApp.n = 1")
76-
with patch.object(os, "getcwd", lambda: wd):
77-
app = DummyApp(config_dir=config_dir)
78-
app.initialize([])
76+
77+
app = DummyApp(config_dir=config_dir)
78+
app.initialize([])
7979

8080
assert app.n == 1, "Loaded config from config dir"
81+
assert app.m == 1, "Loaded config from config dir"
82+
83+
shutil.rmtree(config_dir)
84+
del os.environ["JUPYTER_CONFIG_PATH"]
8185

82-
with open(pjoin(wd, "dummy_app_config.py"), "w", encoding="utf-8") as f:
83-
f.write("c.DummyApp.n = 2")
8486

87+
def test_load_config_no_cwd():
88+
config_dir = mkdtemp()
89+
wd = mkdtemp()
90+
with open(pjoin(wd, "dummy_app_config.py"), "w", encoding="utf-8") as f:
91+
f.write("c.DummyApp.m = 1\n")
92+
f.write("c.DummyApp.n = 1")
8593
with patch.object(os, "getcwd", lambda: wd):
8694
app = DummyApp(config_dir=config_dir)
8795
app.initialize([])
8896

89-
assert app.m == 1, "Loaded config from config dir"
90-
assert app.n == 2, "Loaded config from CWD"
97+
assert app.n == 0
98+
assert app.m == 0
9199

92100
shutil.rmtree(config_dir)
93101
shutil.rmtree(wd)
94102

95103

96104
def test_load_bad_config():
97105
config_dir = mkdtemp()
98-
wd = mkdtemp()
106+
os.environ["JUPYTER_CONFIG_PATH"] = str(config_dir)
99107
with open(pjoin(config_dir, "dummy_app_config.py"), "w", encoding="utf-8") as f:
100108
f.write('c.DummyApp.m = "a\n') # Syntax error
101-
with patch.object(os, "getcwd", lambda: wd):
102-
with pytest.raises(SyntaxError):
103-
app = DummyApp(config_dir=config_dir)
104-
app.raise_config_file_errors = True
105-
app.initialize([])
109+
110+
with pytest.raises(SyntaxError):
111+
app = DummyApp(config_dir=config_dir)
112+
app.raise_config_file_errors = True
113+
app.initialize([])
106114

107115
shutil.rmtree(config_dir)
108-
shutil.rmtree(wd)
116+
del os.environ["JUPYTER_CONFIG_PATH"]
109117

110118

111119
def test_runtime_dir_changed():

0 commit comments

Comments
 (0)