summaryrefslogtreecommitdiffstats
path: root/deluge/tests/test_maketorrent.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 15:05:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 16:15:47 +0000
commitb686174b07bd56af4e5ffaa23c24f27f417fc305 (patch)
tree1ce335620d99341d94e88c159c0b9b0f6f0de5a0 /deluge/tests/test_maketorrent.py
parentAdding debian version 2.0.3-4. (diff)
downloaddeluge-b686174b07bd56af4e5ffaa23c24f27f417fc305.tar.xz
deluge-b686174b07bd56af4e5ffaa23c24f27f417fc305.zip
Merging upstream version 2.1.1 (Closes: #1026291).
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/tests/test_maketorrent.py')
-rw-r--r--deluge/tests/test_maketorrent.py33
1 files changed, 11 insertions, 22 deletions
diff --git a/deluge/tests/test_maketorrent.py b/deluge/tests/test_maketorrent.py
index 4e00996..a2e473f 100644
--- a/deluge/tests/test_maketorrent.py
+++ b/deluge/tests/test_maketorrent.py
@@ -1,19 +1,13 @@
-# -*- coding: utf-8 -*-
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#
-from __future__ import unicode_literals
-
import os
import tempfile
-from twisted.trial import unittest
-
from deluge import maketorrent
-from deluge.common import windows_check
def check_torrent(filename):
@@ -28,7 +22,7 @@ def check_torrent(filename):
TorrentInfo(filename)
-class MakeTorrentTestCase(unittest.TestCase):
+class TestMakeTorrent:
def test_save_multifile(self):
# Create a temporary folder for torrent creation
tmp_path = tempfile.mkdtemp()
@@ -54,21 +48,16 @@ class MakeTorrentTestCase(unittest.TestCase):
os.remove(tmp_file)
def test_save_singlefile(self):
- if windows_check():
- raise unittest.SkipTest('on windows file not released')
- tmp_data = tempfile.mkstemp('testdata')[1]
- with open(tmp_data, 'wb') as _file:
- _file.write(b'a' * (2314 * 1024))
- t = maketorrent.TorrentMetadata()
- t.data_path = tmp_data
- tmp_fd, tmp_file = tempfile.mkstemp('.torrent')
- t.save(tmp_file)
-
- check_torrent(tmp_file)
-
- os.remove(tmp_data)
- os.close(tmp_fd)
- os.remove(tmp_file)
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ tmp_data = tmp_dir + '/data'
+ with open(tmp_data, 'wb') as _file:
+ _file.write(b'a' * (2314 * 1024))
+ t = maketorrent.TorrentMetadata()
+ t.data_path = tmp_data
+ tmp_file = tmp_dir + '/.torrent'
+ t.save(tmp_file)
+
+ check_torrent(tmp_file)
def test_save_multifile_padded(self):
# Create a temporary folder for torrent creation