def test_plot_invalid_kind(self): with pytest.raises(ValueError, match=r"invalid_kind"): plot([str(DUMMY_BENCHMARK_PATH), '-k', 'invalid_kind'], 'benchopt', standalone_mode=False)
def test_plot_html_ignore_kind(self): with pytest.warns(UserWarning, match=r"Cannot specify '--kind'"): plot([ str(DUMMY_BENCHMARK_PATH), '-k', 'invalid_kind', '--html', '--no-display' ], 'benchopt', standalone_mode=False)
def test_plot_invalid_file(self): with pytest.raises(FileNotFoundError, match=r"invalid_file"): plot([ str(DUMMY_BENCHMARK_PATH), '-f', 'invalid_file', '--no-html', '--no-display' ], 'benchopt', standalone_mode=False)
def test_valid_call(self, kind): with SuppressStd() as out: plot([str(DUMMY_BENCHMARK_PATH), '-f', self.result_file, '-k', kind, '--no-display', '--no-html'], 'benchopt', standalone_mode=False) saved_files = re.findall(r'Save .* as: (.*\.pdf)', out.output) assert len(saved_files) == 1 saved_file = saved_files[0] assert kind in saved_file Path(saved_file).unlink()
def test_valid_call_html(self): with SuppressStd() as out: plot([ str(DUMMY_BENCHMARK_PATH), '-f', self.result_file, '--no-display', '--html' ], 'benchopt', standalone_mode=False) saved_files = re.findall(r'Writing.* results to (.*\.html)', out.output) try: assert len(saved_files) == 2 finally: # Make sure to clean up all files even when the test fails for f in saved_files: Path(f).unlink()
def test_valid_call(self, kind): with SuppressStd() as out: plot([ str(DUMMY_BENCHMARK_PATH), '-f', self.result_file, '-k', kind, '--no-display', '--no-html' ], 'benchopt', standalone_mode=False) saved_files = re.findall(r'Save .* as: (.*\.pdf)', out.output) try: assert len(saved_files) == 1 assert kind in saved_files[0] finally: # Make sure to clean up all files even when the test fails for f in saved_files: Path(f).unlink()