Skip to content

Commit

Permalink
test logging better
Browse files Browse the repository at this point in the history
  • Loading branch information
rwb27 committed Apr 23, 2020
1 parent 4369ceb commit 24df9b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
9 changes: 8 additions & 1 deletion tests/test_core_tasks_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import gevent
from gevent.thread import get_ident
import time


def test_task_with_args():
Expand Down Expand Up @@ -89,16 +90,22 @@ def test_task_log_list():

def task_func():
logging.warning("Task warning")
for i in range(10):
time.sleep(0.001)
logging.info(f"Counted to {i}")

task_obj = thread.TaskThread(target=task_func)
task_obj.start()
task_obj.started_event.wait()

assert len(task_obj.log) == 1
assert len(task_obj.log) >= 1
assert task_obj.log[0]["message"] == "Task warning"
assert task_obj.log[0]["levelname"] == "WARNING"
assert task_obj.log[0]["filename"] == os.path.basename(__file__)

task_obj.join()
assert len(task_obj.log) == 11, "Didn't get the right number of log entries - are INFO entries being logged?"


def test_task_log_without_thread():

Expand Down
16 changes: 0 additions & 16 deletions tests/test_tasks.py

This file was deleted.

0 comments on commit 24df9b5

Please sign in to comment.