From 81606b798874d31ba193c5c5c810597f5c64af72 Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Sun, 29 Mar 2026 19:51:16 +0200 Subject: [PATCH] Prevent "I/O operation on closed file" errors in Click tests --- properdocs/tests/cli_tests.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/properdocs/tests/cli_tests.py b/properdocs/tests/cli_tests.py index cf7ea444..d6345d11 100644 --- a/properdocs/tests/cli_tests.py +++ b/properdocs/tests/cli_tests.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import gc import io import logging import unittest @@ -14,6 +15,12 @@ class CLITests(unittest.TestCase): def setUp(self): self.runner = CliRunner() + def tearDown(self): + super().tearDown() + # Cleanup of CliRunner, if done non-deterministically, can mess up tests that follow after. + del self.runner + gc.collect() + @mock.patch('properdocs.commands.serve.serve', autospec=True) def test_serve_default(self, mock_serve): result = self.runner.invoke(cli.cli, ["serve"], catch_exceptions=False)