Skip to content

Commit

Permalink
Merge pull request #119 from Miksus/test/deprecation_warnings
Browse files Browse the repository at this point in the history
TEST: fix warnings in tests
  • Loading branch information
Miksus authored Sep 26, 2022
2 parents 1204c1a + 8761359 commit 18e6132
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rocketry/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions rocketry/test/session/params/test_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
19 changes: 13 additions & 6 deletions rocketry/test/session/test_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions rocketry/test/task/code/test_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion rocketry/test/task/func/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion rocketry/test/task/misc/test_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion rocketry/test/task/misc/test_shutdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 18e6132

Please sign in to comment.