From e3fbe5958562d2b0168221f955ff731583cda2c5 Mon Sep 17 00:00:00 2001 From: Dylan Jeannin Date: Thu, 23 Jul 2026 10:12:01 +0200 Subject: [PATCH] SQLite debug: files with space in name can now be open --- src/View/MainWindow.py | 6 +----- src/View/test_MainWindow.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/View/test_MainWindow.py diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 38ca8770..dd3e9dee 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -2306,11 +2306,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): logger.debug("No study open for sql debuging...") return - # todo : gérer le cas où le dossier a un espace dans le nom - # (ne veut pas ouvrir sqlitebrowser) - file = self._study.filename _ = subprocess.Popen( - f"sqlitebrowser {file}", - shell=True + ["sqlitebrowser", file] ) diff --git a/src/View/test_MainWindow.py b/src/View/test_MainWindow.py new file mode 100644 index 00000000..338a6734 --- /dev/null +++ b/src/View/test_MainWindow.py @@ -0,0 +1,29 @@ +# test_MainWindow.py -- Pamhyr +# Copyright (C) 2026 INRAE +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# -*- coding: utf-8 -*- + +import unittest + +from types import SimpleNamespace +from unittest.mock import patch + +from View.MainWindow import ApplicationWindow + + +class MainWindowTestCase(unittest.TestCase): + @patch("View.MainWindow.subprocess.Popen") + def test_open_sqlite_with_spaces_in_study_path(self, popen): + path = "/tmp/a study with spaces/example study.pamhyr" + window = SimpleNamespace( + _study=SimpleNamespace(filename=path) + ) + + ApplicationWindow.open_sqlite(window) + + popen.assert_called_once_with(["sqlitebrowser", path])