@@ -69,43 +69,51 @@ def test_generate_config():
6969
7070def 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
96104def 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
111119def test_runtime_dir_changed ():
0 commit comments