From 17db9bafc233c44038003ba9aeb76a93bf8010c6 Mon Sep 17 00:00:00 2001 From: akutuva21 Date: Mon, 20 Jul 2026 13:32:21 -0400 Subject: [PATCH 1/3] fix: remove stale conf reference in bngfile.py and update csimulator test mocks - bngfile.py: replaced conf.get('stdout') with self.suppress (conf was removed in the upstream deferred-app-setup refactor) - test_csimulator.py: patch get_conf() instead of the removed module-level conf attribute, matching the upstream csimulator architecture --- bionetgen/modelapi/bngfile.py | 4 +--- tests/test_csimulator.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bionetgen/modelapi/bngfile.py b/bionetgen/modelapi/bngfile.py index 0d640052..15320c16 100644 --- a/bionetgen/modelapi/bngfile.py +++ b/bionetgen/modelapi/bngfile.py @@ -84,11 +84,9 @@ def generate_xml(self, xml_file, model_file=None) -> bool: xml_file, stripped_bngl ) # no need to chdir here, handled by finally block - app_stdout = conf.get("stdout") - app_suppress = False if app_stdout == "STDOUT" else self.suppress rc, _ = run_command( ["perl", self.bngexec, "--xml", stripped_bngl], - suppress=app_suppress, + suppress=self.suppress, cwd=temp_folder, ) if rc != 0: diff --git a/tests/test_csimulator.py b/tests/test_csimulator.py index 58e9ff7b..18fa63d6 100644 --- a/tests/test_csimulator.py +++ b/tests/test_csimulator.py @@ -189,8 +189,10 @@ def test_csimulator_init_str(): with unittest.mock.patch( "bionetgen.simulator.csimulator._new_ccompiler" ) as mock_new_comp: - with unittest.mock.patch("bionetgen.simulator.csimulator.conf") as mock_conf: - mock_conf.get.return_value = "dummy" + with unittest.mock.patch( + "bionetgen.simulator.csimulator.get_conf" + ) as mock_conf: + mock_conf.return_value = {"cvode_include": "dummy", "cvode_lib": "dummy"} with unittest.mock.patch( "bionetgen.simulator.csimulator.bionetgen.run" @@ -222,8 +224,10 @@ def test_csimulator_init_bngmodel(): with unittest.mock.patch( "bionetgen.simulator.csimulator._new_ccompiler" ) as mock_new_comp: - with unittest.mock.patch("bionetgen.simulator.csimulator.conf") as mock_conf: - mock_conf.get.return_value = "dummy" + with unittest.mock.patch( + "bionetgen.simulator.csimulator.get_conf" + ) as mock_conf: + mock_conf.return_value = {"cvode_include": "dummy", "cvode_lib": "dummy"} with unittest.mock.patch( "bionetgen.simulator.csimulator.bionetgen.run" From 697d9fdf2f5ef7e144eb0e619493ec83ed3a5be0 Mon Sep 17 00:00:00 2001 From: akutuva21 Date: Mon, 20 Jul 2026 13:41:33 -0400 Subject: [PATCH 2/3] fix: mock parse_model side effect in test_bngmodel_passes_path_options_to_bngparser add_empty_block creates empty block attributes but does not populate active_blocks (only the real parser does that via add_block with an argument). The test needs active_blocks populated so bngmodel.__init__ does not raise BNGModelError before reaching the assertion. --- tests/test_modelapi_export_errors.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_modelapi_export_errors.py b/tests/test_modelapi_export_errors.py index 8c9a08d8..7e0ad324 100644 --- a/tests/test_modelapi_export_errors.py +++ b/tests/test_modelapi_export_errors.py @@ -226,6 +226,13 @@ def test_bngmodel_passes_path_options_to_bngparser(mock_parser_cls): from bionetgen.modelapi.model import bngmodel parser = MagicMock() + + def _fake_parse_model(model): + for b in model._block_order: + if b not in model.active_blocks: + model.active_blocks.append(b) + + parser.parse_model.side_effect = _fake_parse_model mock_parser_cls.return_value = parser bngmodel( From fdee16cb1a5ac155d012c1eadbc55885e9f8260a Mon Sep 17 00:00:00 2001 From: akutuva21 Date: Mon, 20 Jul 2026 13:51:53 -0400 Subject: [PATCH 3/3] fix: add verbose=False to BNGParser call assertion in test_bngmodel_passes_path_options_to_bngparser The merged code now passes verbose=self.verbose to BNGParser, so the expected call must include verbose=False for the default case. --- tests/test_modelapi_export_errors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_modelapi_export_errors.py b/tests/test_modelapi_export_errors.py index 7e0ad324..a9f6142d 100644 --- a/tests/test_modelapi_export_errors.py +++ b/tests/test_modelapi_export_errors.py @@ -247,6 +247,7 @@ def _fake_parse_model(model): BNGPATH="/custom/bng", generate_network=True, suppress=False, + verbose=False, ) parser.parse_model.assert_called_once()