From d87a86dbdc76fa8112eb1b64c02ea7ee838da19a Mon Sep 17 00:00:00 2001 From: Mikael Koli Date: Tue, 27 Sep 2022 00:14:38 +0300 Subject: [PATCH 1/4] test: fix warnings --- rocketry/test/task/code/test_construct.py | 6 +++--- rocketry/test/task/func/test_run.py | 3 ++- rocketry/test/task/misc/test_restart.py | 2 +- rocketry/test/task/misc/test_shutdown.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/rocketry/test/task/code/test_construct.py b/rocketry/test/task/code/test_construct.py index b7e1a7b2..4125371f 100644 --- a/rocketry/test/task/code/test_construct.py +++ b/rocketry/test/task/code/test_construct.py @@ -35,7 +35,7 @@ def main(): return_value = main() """), execution=execution, name="mytask", session=session) - task.force_run = True + task.run() session.config.shut_cond = TaskStarted(task='mytask') >= 1 session.start() @@ -51,7 +51,7 @@ def main(param): return_value = main(myparam) """), name="mytask", execution=execution, parameters={'myparam': ' + myparam'}, session=session) - task.force_run = True + task.run() session.config.shut_cond = TaskStarted(task='mytask') >= 1 session.start() @@ -73,7 +73,7 @@ def main(): return_value = main() """), execution=execution, name="mytask", session=session) - task.force_run = True + task.run() session.config.shut_cond = TaskStarted(task='mytask') >= 1 session.start() diff --git a/rocketry/test/task/func/test_run.py b/rocketry/test/task/func/test_run.py index d2a57069..8c76beb8 100644 --- a/rocketry/test/task/func/test_run.py +++ b/rocketry/test/task/func/test_run.py @@ -209,7 +209,8 @@ def test_force_run(session): execution="main", session=session ) - task.force_run = True + with pytest.deprecated_call(): + task.force_run = True assert bool(task) assert bool(task) diff --git a/rocketry/test/task/misc/test_restart.py b/rocketry/test/task/misc/test_restart.py index 61c73629..ffd6926e 100644 --- a/rocketry/test/task/misc/test_restart.py +++ b/rocketry/test/task/misc/test_restart.py @@ -25,7 +25,7 @@ def test_scheduler_restart(tmpdir, session): task = Restart(session=session) - task.force_run = True + task.run() session.config.shut_cond = TaskStarted(task=task) == 1 session.config.restarting = "recall" diff --git a/rocketry/test/task/misc/test_shutdown.py b/rocketry/test/task/misc/test_shutdown.py index 7157014c..2c8fca74 100644 --- a/rocketry/test/task/misc/test_shutdown.py +++ b/rocketry/test/task/misc/test_shutdown.py @@ -23,7 +23,7 @@ def test_scheduler_shutdown(tmpdir, session): task = ShutDown(session=session) - task.force_run = True + task.run() session.config.shut_cond = AlwaysFalse() From 736d5603d714a79e2fbca4d81d661497d07addf4 Mon Sep 17 00:00:00 2001 From: Mikael Koli Date: Tue, 27 Sep 2022 00:16:40 +0300 Subject: [PATCH 2/4] CI: raise for deprecation warning --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a143aa6e..3b58b84a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,7 +43,7 @@ jobs: - name: Run test suite run: | - python -m pytest --pyargs rocketry -W error::UserWarning -W error::FutureWarning + python -m pytest --pyargs rocketry -W error::UserWarning -W error::FutureWarning -W error::DeprecationWarning # Seems there is a possible problem with pytest-cov parallelization #- name: Run test suite From 491863f56ac1637f9c4b3b623448c72167ad34e2 Mon Sep 17 00:00:00 2001 From: Mikael Koli Date: Tue, 27 Sep 2022 00:27:43 +0300 Subject: [PATCH 3/4] test: fix warnings --- rocketry/test/session/params/test_return.py | 4 ++-- rocketry/test/session/test_logs.py | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/rocketry/test/session/params/test_return.py b/rocketry/test/session/params/test_return.py index 2f25fb79..0a80abd2 100644 --- a/rocketry/test/session/params/test_return.py +++ b/rocketry/test/session/params/test_return.py @@ -25,9 +25,9 @@ def test_normal(session, execution): name="return task", start_cond="~has started", execution=execution, - force_run=True, session=session ) + task_return.run() task = FuncTask( func_x_with_arg, name="a task", @@ -54,9 +54,9 @@ def test_normal_pass_task(session, execution): name="return task", start_cond="~has started", execution=execution, - force_run=True, session=session ) + task_return.run() task = FuncTask( func_x_with_arg, name="a task", diff --git a/rocketry/test/session/test_logs.py b/rocketry/test/session/test_logs.py index 92cbeffb..a44a1614 100644 --- a/rocketry/test/session/test_logs.py +++ b/rocketry/test/session/test_logs.py @@ -53,7 +53,8 @@ def emit(self, record): raise RuntimeError("Oops") logger = logging.getLogger("rocketry.task") logger.handlers.insert(0, MyHandler()) - task = FuncTask({"success": do_success, "fail": do_fail}[status], name="a task", execution=execution, force_run=True, session=session) + task = FuncTask({"success": do_success, "fail": do_fail}[status], name="a task", execution=execution, session=session) + task.run() if on == "startup": task.on_startup = True @@ -85,7 +86,8 @@ def emit(self, record): logger = logging.getLogger("rocketry.task") logger.handlers.insert(0, MyHandler()) - task = FuncTask({"success": do_success, "fail": do_fail}[status], name="a task", execution=execution, force_run=True, session=session) + task = FuncTask({"success": do_success, "fail": do_fail}[status], name="a task", execution=execution, session=session) + task.run() if on == "startup": task.on_startup = True elif on == "shutdown": @@ -167,10 +169,15 @@ def test_get_logs_params(tmpdir, mock_pydatetime, mock_time, query, expected, se RepoHandler(repo=MemoryRepo(model=CustomRecord)) ] - task1 = FuncTask(lambda: None, name="task1", execution="main", force_run=True, session=session) - task2 = FuncTask(lambda: None, name="task2", execution="main", force_run=True, session=session) - task3 = FuncTask(lambda: None, name="task3", execution="main", force_run=True, session=session) - task4 = FuncTask(lambda: None, name="task4", execution="main", force_run=True, session=session) + task1 = FuncTask(lambda: None, name="task1", execution="main", session=session) + task2 = FuncTask(lambda: None, name="task2", execution="main", session=session) + task3 = FuncTask(lambda: None, name="task3", execution="main", session=session) + task4 = FuncTask(lambda: None, name="task4", execution="main", session=session) + + task1.run() + task2.run() + task3.run() + task4.run() # Start mock_pydatetime("2021-01-01 00:00:00") From 876135903584dacbfae4c1e27c49b49e778a5e84 Mon Sep 17 00:00:00 2001 From: Mikael Koli Date: Tue, 27 Sep 2022 00:27:53 +0300 Subject: [PATCH 4/4] fix: deprecation warning --- rocketry/session.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketry/session.py b/rocketry/session.py index c3b22b85..62743bc1 100644 --- a/rocketry/session.py +++ b/rocketry/session.py @@ -275,7 +275,7 @@ def run(self, *task_names:Tuple[str], execution=None, obey_cond=False): } if name in task_names: if not obey_cond: - task.force_run = True + task.run() if execution is not None: task.execution = execution else: