From 98fbfae0133d4f0bb7ffeaf1ba9af3f20ca9db68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Thu, 5 Jun 2025 16:54:03 +0200 Subject: [PATCH] [tests] Plugins: Add a `sleep` between file rewrites On some systems such as GitHub's Windows CI, the `write` operation is too fast and does not cause a change in the timestamp of the file we're reloading, hence causing the test to fail for external reasons. Adding a sleep does not change anything to the test functionally, but on the contrary ensures that we are actually testing the feature. https://stackoverflow.com/questions/19059877/python-os-path-getmtime-time-not-changing --- tests/test_plugins.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 40d13d69..4ee2e0a4 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -4,6 +4,7 @@ from meshroom.core import desc, pluginManager, loadClassesNodes from meshroom.core.plugins import NodePluginStatus, Plugin import os +import time class TestPluginWithValidNodesOnly: plugin = None @@ -185,10 +186,23 @@ class TestPluginWithInvalidNodes: # Attempt to register node plugin pluginManager.registerNode(node) assert pluginManager.isRegistered(nodeName) + + # Reload the node again without any change + node.reload() + assert pluginManager.isRegistered(nodeName) + # Hack to ensure that the timestamp of the file will be different after being rewritten + # Without it, on some systems, the operation is too fast and the timestamp does not change, + # cause the test to fail + time.sleep(0.1) + # Restore the node file to its original state (with a description error) with open(node.path, "w") as f: f.write(originalFileContent) + + timestampOr2 = os.path.getmtime(node.path) + print(f"New timestamp: {timestampOr2}") + print(os.stat(node.path)) # Reload the node and assert it is invalid while still registered node.reload()