Skip to content

Commit

Permalink
conftest.py: check that IO loop resrouces are closed
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jun 23, 2024
1 parent 3aa6dc8 commit 89d2436
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pyftpdlib/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import psutil
import pytest

from pyftpdlib.ioloop import IOLoop


# set it to True to raise an exception instead of warning
FAIL = False
Expand Down Expand Up @@ -64,6 +66,17 @@ def assert_closed_resources(setup_ctx, request):
warn(msg)


def assert_closed_ioloop():
inst = IOLoop.instance()
if inst.socket_map:
warn(f"unclosed ioloop socket map {inst.socket_map}")
if inst.sched._tasks:
warn(f"unclosed ioloop tasks {inst.sched._tasks}")


# ---


def setup_method(origin):
ctx = collect_resources()
ctx["_origin"] = origin
Expand All @@ -72,6 +85,7 @@ def setup_method(origin):

def teardown_method(setup_ctx, request):
assert_closed_resources(setup_ctx, request)
assert_closed_ioloop()


@pytest.fixture(autouse=True, scope="function")
Expand Down

0 comments on commit 89d2436

Please sign in to comment.