Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-06-06 16:05:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-06-06 16:05:46 +0300
commit7ef2b760dc233d61a2350e20d4e65cb76dbb9311 (patch)
tree476fe9cce0128c03c1a57980762a358420949075 /tests
parentc27b7df563a68f38676decb5ab6f68b3e4ff85f0 (diff)
Event Simulate: and a --keep-open command line argument
It can be useful to investigate the state of the file after event simulation runs.
Diffstat (limited to 'tests')
-rw-r--r--tests/python/bl_run_operators_event_simulate.py28
1 files changed, 24 insertions, 4 deletions
diff --git a/tests/python/bl_run_operators_event_simulate.py b/tests/python/bl_run_operators_event_simulate.py
index 251d27fce90..92315d3e853 100644
--- a/tests/python/bl_run_operators_event_simulate.py
+++ b/tests/python/bl_run_operators_event_simulate.py
@@ -175,7 +175,7 @@ def mouse_location_get():
)
-def run_event_simulate(*, event_iter):
+def run_event_simulate(*, event_iter, exit_fn):
"""
Pass events from event_iter into Blender.
"""
@@ -188,8 +188,7 @@ def run_event_simulate(*, event_iter):
if val is Ellipsis:
bpy.app.use_event_simulate = False
print("Finished simulation")
-
- sys.exit(0)
+ exit_fn()
return None
# Run event simulation.
@@ -494,6 +493,18 @@ def argparse_create():
formatter_class=argparse.RawTextHelpFormatter,
)
+ parser.add_argument(
+ "--keep-open",
+ dest="keep_open",
+ default=False,
+ action="store_true",
+ help=(
+ "Keep the window open instead of exiting once event simulation is complete.\n"
+ "This can be useful to inspect the state of the file once the simulation is complete."
+ ),
+ required=False,
+ )
+
# Collect doc-strings from static methods in `actions`.
actions_docstring = []
for action_key in ACTION_DIR:
@@ -570,7 +581,16 @@ def main():
setup_default_preferences(bpy.context.preferences)
- run_event_simulate(event_iter=main_event_iter(action_list=args.actions))
+ def exit_fn():
+ if not args.keep_open:
+ sys.exit(0)
+ else:
+ bpy.app.use_event_simulate = False
+
+ run_event_simulate(
+ event_iter=main_event_iter(action_list=args.actions),
+ exit_fn=exit_fn,
+ )
if __name__ == "__main__":