Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jwong-nd committed Nov 9, 2024
1 parent 364508d commit 8b76a56
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/test_transform_videos.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Tests transform_videos module."""

import logging
import tempfile
from contextlib import contextmanager

import shlex
import subprocess
import tempfile
import unittest
from contextlib import contextmanager
from os import symlink, unlink
from pathlib import Path
from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -225,10 +223,12 @@ def capture_logs(self):
Context manager that creates a temporary log file
and configures logging to use it.
"""
with tempfile.NamedTemporaryFile(mode='w+', delete=False) as temp_log:
with tempfile.NamedTemporaryFile(mode="w+", delete=False) as temp_log:
# Configure logging to write to our temporary file
file_handler = logging.FileHandler(temp_log.name)
file_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s'))
file_handler.setFormatter(
logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
)
logging.getLogger().addHandler(file_handler)
logging.getLogger().setLevel(logging.DEBUG)

Expand All @@ -251,8 +251,8 @@ def test_serial_log(self, mock_time: MagicMock):

faulty_req = CompressionRequest(
compression_enum=CompressionEnum.USER_DEFINED,
user_ffmpeg_input_options = "invalid input args",
user_ffmpeg_output_options = "invalid output args",
user_ffmpeg_input_options="invalid input args",
user_ffmpeg_output_options="invalid output args",
)

if not self.test_vid_path.is_file():
Expand All @@ -279,17 +279,18 @@ def test_serial_log(self, mock_time: MagicMock):
RuntimeError,
helper_run_compression_job,
job_settings,
mock_time
mock_time,
)
error_blocks = []
with open(log_file, 'r') as f:
with open(log_file, "r") as f:
for line_num, line in enumerate(f, 1):
if 'ERROR' in line:
if "ERROR" in line:
error_blocks.append(line_num)

for i in range(len(error_blocks) - 1):
error_diff = error_blocks[i + 1] - error_blocks[i]
self.assertTrue(error_diff >= 9)


if __name__ == "__main__":
unittest.main()

0 comments on commit 8b76a56

Please sign in to comment.