From da367d913674d97007e79edc51b82c1ff664d683 Mon Sep 17 00:00:00 2001 From: Ryan Walter Murray Date: Mon, 26 Jan 2026 14:04:37 +0100 Subject: [PATCH 1/4] Fix test suite on Windows to avoid exceeding file handle limit --- tests/conftest.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..cc2633c48 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,21 @@ +import gc +import sys +import pytest + + +@pytest.fixture(autouse=True) +def gc_after_module(): + """Run Python's garabage collection after each test on Windows. + + The test suite currently opens many file handles that are not closed until garabage collection + runs. This results in flaky test failures on Windows which has a limit of 512 open file handles + per process. It could be possible to remove this in the future if the problem is solved upstream + (most likely in MIKE IO). See issue below for details: + + https://github.com/DHI/mikecore-python/issues/41 + """ + if sys.platform.startswith("win"): + yield + gc.collect() + else: + yield From 14cb5bc531828e797859fde9c411384a50dcaf42 Mon Sep 17 00:00:00 2001 From: Ryan Murray <74630349+ryan-kipawa@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:26:04 +0100 Subject: [PATCH 2/4] Update conftest.py Co-authored-by: Henrik Andersson --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index cc2633c48..df8208abb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ @pytest.fixture(autouse=True) -def gc_after_module(): +def gc_after_test(): """Run Python's garabage collection after each test on Windows. The test suite currently opens many file handles that are not closed until garabage collection From 5fc962f2bd5e793789fa8e6d5861def8152f2d78 Mon Sep 17 00:00:00 2001 From: Ryan Murray <74630349+ryan-kipawa@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:26:15 +0100 Subject: [PATCH 3/4] Update conftest.py Co-authored-by: Henrik Andersson --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index df8208abb..22ac26dcd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,7 +5,7 @@ @pytest.fixture(autouse=True) def gc_after_test(): - """Run Python's garabage collection after each test on Windows. + """Run Python's garbage collection after each test on Windows. The test suite currently opens many file handles that are not closed until garabage collection runs. This results in flaky test failures on Windows which has a limit of 512 open file handles From 4f69d39d0ac7593dac15ba02cde2fbba6868bd6a Mon Sep 17 00:00:00 2001 From: Ryan Murray <74630349+ryan-kipawa@users.noreply.github.com> Date: Mon, 26 Jan 2026 17:26:23 +0100 Subject: [PATCH 4/4] Update conftest.py Co-authored-by: Henrik Andersson --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 22ac26dcd..e1f75e284 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,7 @@ def gc_after_test(): """Run Python's garbage collection after each test on Windows. - The test suite currently opens many file handles that are not closed until garabage collection + The test suite currently opens many file handles that are not closed until garbage collection runs. This results in flaky test failures on Windows which has a limit of 512 open file handles per process. It could be possible to remove this in the future if the problem is solved upstream (most likely in MIKE IO). See issue below for details: