Skip to content

Commit 973f5b0

Browse files
committed
TST: Fix tests that use chdir
1 parent 0453e35 commit 973f5b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sambo/_test.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ def test_make_doc_plots(self):
379379
plot_convergence: dict(yscale='log', true_minimum=0),
380380
plot_objective: dict(resolution=12)
381381
}
382-
with chdir(Path(__file__).parent.parent / 'www'):
382+
www_dir = Path(__file__).parent.parent / 'www'
383+
www_dir.mkdir(exist_ok=True)
384+
with chdir(www_dir):
383385
for plot_func in PLOT_FUNCS:
384386
name = plot_func.__name__.removeprefix("plot_")
385387
with self.subTest(plot=name):
@@ -419,7 +421,9 @@ def evaluate(x):
419421
results.append(result)
420422
named_results = [(f'estimator={e!r}', r) for e, r in zip(BUILTIN_ESTIMATORS, results)]
421423
fig = plot_convergence(*named_results, true_minimum=0)
422-
with chdir(Path(__file__).parent.parent / 'www'):
424+
www_dir = Path(__file__).parent.parent / 'www'
425+
www_dir.mkdir(exist_ok=True)
426+
with chdir(www_dir):
423427
fig.savefig('convergence2.svg')
424428
plt.show()
425429

0 commit comments

Comments
 (0)