summaryrefslogtreecommitdiffstats
path: root/deluge/tests/test_metafile.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 15:05:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-19 15:05:49 +0000
commitd395bd510fa4f4376dc5237ab2f8d190a920d35d (patch)
tree3e3b16b44064938be801aede14381562bae14f6a /deluge/tests/test_metafile.py
parentAdding upstream version 2.0.3. (diff)
downloaddeluge-a442edfa553d906131bfbb00a015adb3f52719d7.tar.xz
deluge-a442edfa553d906131bfbb00a015adb3f52719d7.zip
Adding upstream version 2.1.1.upstream/2.1.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/tests/test_metafile.py')
-rw-r--r--deluge/tests/test_metafile.py27
1 files changed, 8 insertions, 19 deletions
diff --git a/deluge/tests/test_metafile.py b/deluge/tests/test_metafile.py
index fc6507c..fda1cb7 100644
--- a/deluge/tests/test_metafile.py
+++ b/deluge/tests/test_metafile.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 metafile
-from deluge.common import windows_check
def check_torrent(filename):
@@ -28,7 +22,7 @@ def check_torrent(filename):
TorrentInfo(filename)
-class MetafileTestCase(unittest.TestCase):
+class TestMetafile:
def test_save_multifile(self):
# Create a temporary folder for torrent creation
tmp_path = tempfile.mkdtemp()
@@ -52,17 +46,12 @@ class MetafileTestCase(unittest.TestCase):
os.remove(tmp_file)
def test_save_singlefile(self):
- if windows_check():
- raise unittest.SkipTest('on windows \\ != / for path names')
- tmp_path = tempfile.mkstemp('testdata')[1]
- with open(tmp_path, 'wb') as tmp_file:
- tmp_file.write(b'a' * (2314 * 1024))
-
- tmp_fd, tmp_file = tempfile.mkstemp('.torrent')
- metafile.make_meta_file(tmp_path, '', 32768, target=tmp_file)
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ tmp_data = tmp_dir + '/testdata'
+ with open(tmp_data, 'wb') as tmp_file:
+ tmp_file.write(b'a' * (2314 * 1024))
- check_torrent(tmp_file)
+ tmp_torrent = tmp_dir + '/.torrent'
+ metafile.make_meta_file(tmp_data, '', 32768, target=tmp_torrent)
- os.remove(tmp_path)
- os.close(tmp_fd)
- os.remove(tmp_file)
+ check_torrent(tmp_torrent)