From: Oleg Broytman Date: Wed, 29 Jan 2025 00:31:52 +0000 (+0300) Subject: Tests(test_list_torrents): Handle torrent that lacks `creation_date` X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=5a3c051d6158531433dfb1a7fc1cfb08ba1aaf14;p=mc%2Fmc-torrent-vfs-tests.git Tests(test_list_torrents): Handle torrent that lacks `creation_date` Set fixed timestamp for 'leaves-metadata.torrent' file. --- diff --git a/tests/test_list_torrents.py b/tests/test_list_torrents.py index 38d9ca8..b01f382 100755 --- a/tests/test_list_torrents.py +++ b/tests/test_list_torrents.py @@ -1,5 +1,7 @@ #! /usr/bin/env python3 +from datetime import datetime +from time import mktime import os import os.path import subprocess @@ -19,6 +21,13 @@ def _get_filename(line): def _test1(basename): torrent_file = os.path.join(test_torrents_dir, basename + '.torrent') + + if basename == 'leaves-metadata': + # The torrent lacks creation_date field, set fixd timestamp + leaves_metadata_dt = datetime(2016, 3, 16, 19, 33) + timestamp = mktime(leaves_metadata_dt.timetuple()) + os.utime(torrent_file, (timestamp, timestamp)) + command = os.path.join(extfs_dir, 'torrent') pipe = subprocess.Popen([sys.executable, command, 'list', torrent_file], stdout=subprocess.PIPE)