-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Milestone
Description
Hi,
I am a maintainer of subliminal that uses click for its CLI. Some tests for the CLI are failing since the upgrade to click 8.3.0.
I tracked the failures to a regression in click 8.3.0 due to #2991. Reverting this commit makes my tests pass with click 8.3.0.
The failing pytest tests are of the following form:
def test_cli_download(tmp_path: os.PathLike[str]) -> None:
runner = CliRunner()
result = runner.invoke(subliminal_cli, ['download', '-l', 'en', '-p', 'podnapisi', 'video.mkv'])
# Curiously this test is not failing, subtitle is even downloaded
assert result.exit_code == 0
# The following two asserts are failing because `result.output` show a long error message.
assert result.output.startswith('Collecting videos')
assert result.output.endswith('Downloaded 1 subtitle\n')
When I only run this test function with pytest, all the assertions pass, but when I run the whole file that has plenty of test functions with the same structure, all the functions fail at the result.output assert (although not consistently...)
The error message in result.output is like this:
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.13/logging/__init__.py", line 1154, in emit
stream.write(msg + self.terminator)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
ValueError: I/O operation on closed file.
[...]
File "src/subliminal/score.py", line 157, in compute_score
logger.debug('Found matches %r', matches)
Message: 'Found matches %r'
Arguments: ({'country', 'episode', 'season', 'series', 'year'},)
It seems the logging files are closed after one CliRunner.invoke call and its giving rise to failures in the other tests.
edgarrmondragon and bchopson
Metadata
Metadata
Assignees
Labels
No labels