mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-17 18:21:55 +02:00
[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
This commit is contained in:
parent
0c5e76997a
commit
98fbfae013
1 changed files with 14 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue