Skip to content

Commit

Permalink
Fix importing libtorrent
Browse files Browse the repository at this point in the history
  • Loading branch information
aresch committed Mar 21, 2010
1 parent b0714f6 commit 16b832f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions tests/test_maketorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@

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
tmp_path = tempfile.mkdtemp()
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"))
Expand All @@ -44,7 +44,7 @@ def test_save_singlefile(self):
t.data_path = tmp_data
tmp_file = tempfile.mkstemp(".torrent")[1]
t.save(tmp_file)

check_torrent(tmp_file)

os.remove(tmp_data)
Expand All @@ -56,17 +56,17 @@ def test_save_multifile_padded(self):
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)

0 comments on commit 16b832f

Please sign in to comment.