fix return-value/deprecated API bugs, accumulation lock leaks, code cleanup
Build Debian Packages / build (bookworm, debian12) (push) Successful in 8m56s
Build Debian Packages / build (trixie, debian13) (push) Successful in 9m3s

- raise instead of silent None for unsupported operands and empty negation
- validate before acquiring lock in Accumulation operators (no RLock leak)
- Accumulation._copy_provenance helper, ADC_Result._copy_metadata for all result paths
- shared _sandbox_stdout_redirect contextmanager for sandboxed scripts
- TemperatureMonitor dead code removal (gtk helper, traceback, unused properties)
- new unit tests incl. lock-freedom regression test
- gitignore sphinx generated doc/_autosummary/ and doc/damaris/
This commit is contained in:
markusro committed 2026-10-17 19:17:43 +02:00
1 parent 91ade4376c
commit f9d8de7697
26 files changed
+590 -236

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
import sys
import threading
import unittest
from damaris.gui.ExperimentHandling import ExperimentHandling
from damaris.gui.ResultHandling import ResultHandling
class _FakeWriter:
def __init__(self):
self.sent = []
def send_next(self, job, quit=False):
self.sent.append(job)
class _FakeResultIterator:
def __init__(self):
self.quit_flag = threading.Event()
def __iter__(self):
return iter([])
class TestSandboxStdoutRestore(unittest.TestCase):
"""
sys.stdout/sys.stderr are process-global: the sandbox redirect in
run() must be undone even when the script raises or returns early.
"""
def test_experiment_stdout_restored_after_script_exception(self):
orig_stdout = sys.stdout
orig_stderr = sys.stderr
handled = ExperimentHandling("raise ValueError('boom')", None, None,
log_callback=lambda line: None)
handled.run()
self.assertIs(sys.stdout, orig_stdout)
self.assertIs(sys.stderr, orig_stderr)
self.assertIsNotNone(handled.raised_exception)
def test_experiment_stdout_restored_on_success(self):
orig_stdout = sys.stdout
writer = _FakeWriter()
handled = ExperimentHandling("print('hello')\nexperiment = lambda: iter([])",
writer, None, log_callback=lambda line: None)
handled.run()
self.assertIs(sys.stdout, orig_stdout)
self.assertIsNone(handled.raised_exception)
def test_result_stdout_restored_after_script_exception(self):
orig_stdout = sys.stdout
orig_stderr = sys.stderr
handling = ResultHandling("raise ValueError('boom')", _FakeResultIterator(),
None, log_callback=lambda line: None)
handling.run()
self.assertIs(sys.stdout, orig_stdout)
self.assertIs(sys.stderr, orig_stderr)
self.assertIsNotNone(handling.raised_exception)
def test_result_stdout_restored_without_result_function(self):
orig_stdout = sys.stdout
handling = ResultHandling("x = 1", _FakeResultIterator(), None,
log_callback=lambda line: None)
handling.run()
self.assertIs(sys.stdout, orig_stdout)
self.assertIsNone(handling.raised_exception)
if __name__ == "__main__":
unittest.main()