mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 03:24:54 +00:00
Fix importing libtorrent
This commit is contained in:
parent
b0714f625f
commit
16b832f7ab
1 changed files with 12 additions and 12 deletions
|
@ -9,13 +9,13 @@ from deluge import maketorrent
|
|||
|
||||
def check_torrent(filename):
|
||||
# Test loading with libtorrent to make sure it's valid
|
||||
import libtorrent as lt
|
||||
from deluge._libtorrent import lt
|
||||
lt.torrent_info(filename)
|
||||
|
||||
|
||||
# Test loading with our internal TorrentInfo class
|
||||
from deluge.ui.common import TorrentInfo
|
||||
ti = TorrentInfo(filename)
|
||||
|
||||
ti = TorrentInfo(filename)
|
||||
|
||||
class MakeTorrentTestCase(unittest.TestCase):
|
||||
def test_save_multifile(self):
|
||||
# Create a temporary folder for torrent creation
|
||||
|
@ -23,14 +23,14 @@ class MakeTorrentTestCase(unittest.TestCase):
|
|||
open(os.path.join(tmp_path, "file_A"), "wb").write("a" * (312 * 1024))
|
||||
open(os.path.join(tmp_path, "file_B"), "wb").write("b" * (2354 * 1024))
|
||||
open(os.path.join(tmp_path, "file_C"), "wb").write("c" * (11 * 1024))
|
||||
|
||||
|
||||
t = maketorrent.TorrentMetadata()
|
||||
t.data_path = tmp_path
|
||||
tmp_file = tempfile.mkstemp(".torrent")[1]
|
||||
t.save(tmp_file)
|
||||
|
||||
|
||||
check_torrent(tmp_file)
|
||||
|
||||
|
||||
os.remove(os.path.join(tmp_path, "file_A"))
|
||||
os.remove(os.path.join(tmp_path, "file_B"))
|
||||
os.remove(os.path.join(tmp_path, "file_C"))
|
||||
|
@ -44,7 +44,7 @@ class MakeTorrentTestCase(unittest.TestCase):
|
|||
t.data_path = tmp_data
|
||||
tmp_file = tempfile.mkstemp(".torrent")[1]
|
||||
t.save(tmp_file)
|
||||
|
||||
|
||||
check_torrent(tmp_file)
|
||||
|
||||
os.remove(tmp_data)
|
||||
|
@ -56,17 +56,17 @@ class MakeTorrentTestCase(unittest.TestCase):
|
|||
open(os.path.join(tmp_path, "file_A"), "wb").write("a" * (312 * 1024))
|
||||
open(os.path.join(tmp_path, "file_B"), "wb").write("b" * (2354 * 1024))
|
||||
open(os.path.join(tmp_path, "file_C"), "wb").write("c" * (11 * 1024))
|
||||
|
||||
|
||||
t = maketorrent.TorrentMetadata()
|
||||
t.data_path = tmp_path
|
||||
t.pad_files = True
|
||||
tmp_file = tempfile.mkstemp(".torrent")[1]
|
||||
t.save(tmp_file)
|
||||
|
||||
|
||||
check_torrent(tmp_file)
|
||||
|
||||
|
||||
os.remove(os.path.join(tmp_path, "file_A"))
|
||||
os.remove(os.path.join(tmp_path, "file_B"))
|
||||
os.remove(os.path.join(tmp_path, "file_C"))
|
||||
os.rmdir(tmp_path)
|
||||
os.remove(tmp_file)
|
||||
os.remove(tmp_file)
|
||||
|
|
Loading…
Add table
Reference in a new issue