Skip to content

Commit

Permalink
fix: force sftp cleanup when done with instance
Browse files Browse the repository at this point in the history
Force inline sftp closure rather than on garbage collection.
Without this, pytest causes tracebacks because it cleans up the logger
before the final sftp connection is closed, which causes tracebacks
after tests pass.
  • Loading branch information
holmanb committed Sep 12, 2024
1 parent b88f910 commit 0d63ce7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ def _client(
yield instance
test_failed = request.session.testsfailed - previous_failures > 0
_collect_artifacts(instance, request.node.nodeid, test_failed)
# conflicting requirements:
# - pytest thinks that it can cleanup loggers after tests run
# - pycloudlib thinks that at garbage collection is a good place to tear
# down sftp connections
# After the final test runs, pytest might clean up loggers which will cause
# paramiko to barf when it logs that the connection is being closed.
#
# Manually run __del__() to prevent this teardown mess.
instance.instance.__del__()


@pytest.fixture
Expand Down

0 comments on commit 0d63ce7

Please sign in to comment.