diff --git a/appveyor.yml b/appveyor.yml index 55d93358e..2b34ec64d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,12 +5,12 @@ environment: matrix: # See: http://www.appveyor.com/docs/installed-software#python - - TOXENV: pydef - TOXENV: flake8 - - TOXENV: docs - TOXENV: trial + - TOXENV: pydef - TOXENV: pygtkui - TOXENV: plugins + - TOXENV: docs - PYTHON_VERSION: "2.7.x" pull_requests: diff --git a/deluge/tests/common.py b/deluge/tests/common.py index b7b38f680..79d4052f6 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -238,7 +238,12 @@ def start_core( import sys import deluge.core.daemon_entry -sys.argv.extend(['-d', '-c', '%s', '-L', 'info', '-p', '%d']) +from deluge.common import windows_check + + if windows_check(): + sys.argv.extend(['-c', '%s', '-L', 'info', '-p', '%d']) + else + sys.argv.extend(['-d', '-c', '%s', '-L', 'info', '-p', '%d']) try: daemon = deluge.core.daemon_entry.start_daemon(skip_start=True) diff --git a/deluge/tests/daemon_base.py b/deluge/tests/daemon_base.py index ed7deea0e..24af09848 100644 --- a/deluge/tests/daemon_base.py +++ b/deluge/tests/daemon_base.py @@ -14,12 +14,16 @@ from twisted.internet import defer from twisted.internet.error import CannotListenError import deluge.component as component +from deluge.common import windows_check from . import common class DaemonBase(object): + if windows_check: + skip = 'windows cant start_core not enough arguments for format string' + def common_set_up(self): common.set_tmp_config_dir() self.listen_port = 58900 diff --git a/deluge/tests/test_client.py b/deluge/tests/test_client.py index 9f622ec92..7a8a35bc9 100644 --- a/deluge/tests/test_client.py +++ b/deluge/tests/test_client.py @@ -11,7 +11,7 @@ from twisted.internet import defer import deluge.component as component from deluge import error -from deluge.common import AUTH_LEVEL_NORMAL, get_localhost_auth +from deluge.common import AUTH_LEVEL_NORMAL, get_localhost_auth, windows_check from deluge.core.authmanager import AUTH_LEVEL_ADMIN from deluge.ui.client import Client, DaemonSSLProxy, client @@ -77,6 +77,9 @@ class NoVersionSendingClient(Client): class ClientTestCase(BaseTestCase, DaemonBase): + if windows_check: + skip = 'windows cant start_core not enough arguments for format string' + def set_up(self): d = self.common_set_up() d.addCallback(self.start_core) diff --git a/deluge/tests/test_common.py b/deluge/tests/test_common.py index 9a537df79..00933a5c1 100644 --- a/deluge/tests/test_common.py +++ b/deluge/tests/test_common.py @@ -13,7 +13,7 @@ import tarfile from twisted.trial import unittest from deluge.common import (VersionSplit, archive_files, fdate, fpcnt, fpeer, fsize, fspeed, ftime, get_path_size, - is_infohash, is_ip, is_ipv4, is_ipv6, is_magnet, is_url) + is_infohash, is_ip, is_ipv4, is_ipv6, is_magnet, is_url, windows_check) from deluge.ui.translations_util import setup_translations from .common import get_test_data_file, set_tmp_config_dir @@ -77,6 +77,8 @@ class CommonTestCase(unittest.TestCase): self.assertTrue(is_infohash('2dc5d0e71a66fe69649a640d39cb00a259704973')) def test_get_path_size(self): + if windows_check(): + raise unittest.SkipTest('os devnull is different on windows') self.assertTrue(get_path_size(os.devnull) == 0) self.assertTrue(get_path_size('non-existant.file') == -1) diff --git a/deluge/tests/test_files_tab.py b/deluge/tests/test_files_tab.py index 1942171cd..4d7cb2a3c 100644 --- a/deluge/tests/test_files_tab.py +++ b/deluge/tests/test_files_tab.py @@ -11,6 +11,7 @@ import pytest from twisted.trial import unittest import deluge.component as component +from deluge.common import windows_check from deluge.configmanager import ConfigManager from deluge.ui.translations_util import setup_translations @@ -98,6 +99,8 @@ class FilesTabTestCase(BaseTestCase): self.assertTrue(ret) def test_files_tab2(self): + if windows_check(): + raise unittest.SkipTest('on windows \ != / for path names') self.filestab.files_list[self.t_id] = ( {'index': 0, 'path': '1/1/test_10.txt', 'offset': 0, 'size': 13}, {'index': 1, 'path': 'test_100.txt', 'offset': 13, 'size': 14}, @@ -111,6 +114,8 @@ class FilesTabTestCase(BaseTestCase): self.assertTrue(ret) def test_files_tab3(self): + if windows_check(): + raise unittest.SkipTest('on windows \ != / for path names') self.filestab.files_list[self.t_id] = ( {'index': 0, 'path': '1/test_10.txt', 'offset': 0, 'size': 13}, {'index': 1, 'path': 'test_100.txt', 'offset': 13, 'size': 14}, @@ -144,6 +149,8 @@ class FilesTabTestCase(BaseTestCase): self.assertTrue(ret) def test_files_tab5(self): + if windows_check(): + raise unittest.SkipTest('on windows \ != / for path names') self.filestab.files_list[self.t_id] = ( {'index': 0, 'path': '1/test_10.txt', 'offset': 0, 'size': 13}, {'index': 1, 'path': '2/test_100.txt', 'offset': 13, 'size': 14}, diff --git a/deluge/tests/test_httpdownloader.py b/deluge/tests/test_httpdownloader.py index f06ea5716..68fd69b7e 100644 --- a/deluge/tests/test_httpdownloader.py +++ b/deluge/tests/test_httpdownloader.py @@ -20,6 +20,7 @@ from twisted.web.resource import Resource from twisted.web.server import Site from twisted.web.util import redirectTo +from deluge.common import windows_check from deluge.httpdownloader import download_file from deluge.log import setup_logger from deluge.ui.web.common import compress @@ -185,6 +186,10 @@ class DownloadFileTestCase(unittest.TestCase): return d def test_download_with_rename(self): + + if windows_check(): + raise unittest.SkipTest('on windows \ != / for path names') + url = self.get_url('rename?filename=renamed') d = download_file(url, fname('original')) d.addCallback(self.assertEqual, fname('renamed')) @@ -192,6 +197,10 @@ class DownloadFileTestCase(unittest.TestCase): return d def test_download_with_rename_exists(self): + + if windows_check(): + raise unittest.SkipTest('on windows \ != / for path names') + open(fname('renamed'), 'w').close() url = self.get_url('rename?filename=renamed') d = download_file(url, fname('original')) @@ -200,6 +209,10 @@ class DownloadFileTestCase(unittest.TestCase): return d def test_download_with_rename_sanitised(self): + + if windows_check(): + raise unittest.SkipTest('on windows \ != / for path names') + url = self.get_url('rename?filename=/etc/passwd') d = download_file(url, fname('original')) d.addCallback(self.assertEqual, fname('passwd')) diff --git a/deluge/tests/test_maketorrent.py b/deluge/tests/test_maketorrent.py index 0e223896f..9f5e8379f 100644 --- a/deluge/tests/test_maketorrent.py +++ b/deluge/tests/test_maketorrent.py @@ -13,6 +13,7 @@ import tempfile from twisted.trial import unittest from deluge import maketorrent +from deluge.common import windows_check def check_torrent(filename): @@ -51,6 +52,8 @@ 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('a' * (2314 * 1024)) diff --git a/deluge/tests/test_metafile.py b/deluge/tests/test_metafile.py index 0558a097a..d61d61015 100644 --- a/deluge/tests/test_metafile.py +++ b/deluge/tests/test_metafile.py @@ -13,6 +13,7 @@ import tempfile from twisted.trial import unittest from deluge import metafile +from deluge.common import windows_check def check_torrent(filename): @@ -49,6 +50,8 @@ 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('a' * (2314 * 1024)) diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py index a4148d3d5..d74b82fe6 100644 --- a/deluge/tests/test_torrent.py +++ b/deluge/tests/test_torrent.py @@ -13,12 +13,13 @@ import time from twisted.internet import reactor from twisted.internet.task import deferLater +from twisted.trial import unittest import deluge.component as component import deluge.core.torrent import deluge.tests.common as common from deluge._libtorrent import lt -from deluge.common import utf8_encode_structure +from deluge.common import utf8_encode_structure, windows_check from deluge.core.core import Core from deluge.core.rpcserver import RPCServer from deluge.core.torrent import Torrent @@ -123,6 +124,8 @@ class TorrentTestCase(BaseTestCase): # self.print_priority_list(priorities) def test_torrent_error_data_missing(self): + if windows_check(): + raise unittest.SkipTest('unexpected end of file in bencoded string') options = {'seed_mode': True} filename = common.get_test_data_file('test_torrent.file.torrent') with open(filename) as _file: @@ -139,6 +142,8 @@ class TorrentTestCase(BaseTestCase): self.assert_state(torrent, 'Error') def test_torrent_error_resume_original_state(self): + if windows_check(): + raise unittest.SkipTest('unexpected end of file in bencoded string') options = {'seed_mode': True, 'add_paused': True} filename = common.get_test_data_file('test_torrent.file.torrent') with open(filename) as _file: @@ -158,6 +163,8 @@ class TorrentTestCase(BaseTestCase): torrent.force_recheck() def test_torrent_error_resume_data_unaltered(self): + if windows_check(): + raise unittest.SkipTest('unexpected end of file in bencoded string') resume_data = { 'active_time': 13399, 'num_incomplete': 16777215, 'announce_to_lsd': 1, 'seed_mode': 0, 'pieces': '\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01', 'paused': 0, diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py index 407d7eefc..5f094a93b 100644 --- a/deluge/tests/test_tracker_icons.py +++ b/deluge/tests/test_tracker_icons.py @@ -11,6 +11,7 @@ import pytest import deluge.component as component import deluge.ui.tracker_icons +from deluge.common import windows_check from deluge.ui.tracker_icons import TrackerIcon, TrackerIcons from . import common @@ -24,6 +25,9 @@ common.disable_new_release_check() @pytest.mark.internet class TrackerIconsTestCase(BaseTestCase): + if windows_check(): + skip = 'cannot use os.path.samefile to compair on windows(unix only)' + def set_up(self): self.icons = TrackerIcons() diff --git a/deluge/tests/test_ui_common.py b/deluge/tests/test_ui_common.py index 32ad3037f..20e0818c3 100644 --- a/deluge/tests/test_ui_common.py +++ b/deluge/tests/test_ui_common.py @@ -10,6 +10,7 @@ from __future__ import unicode_literals from twisted.trial import unittest +from deluge.common import windows_check from deluge.ui.common import TorrentInfo from . import common @@ -29,6 +30,8 @@ class UICommonTestCase(unittest.TestCase): self.assertTrue('azcvsupdater_2.6.2.jar' in ti.files_tree) def test_utf8_encoded_paths2(self): + if windows_check(): + raise unittest.SkipTest('on windows KeyError: unicode_filenames') filename = common.get_test_data_file('unicode_filenames.torrent') ti = TorrentInfo(filename) diff --git a/deluge/tests/test_ui_entry.py b/deluge/tests/test_ui_entry.py index 130dbe192..cabdabb09 100644 --- a/deluge/tests/test_ui_entry.py +++ b/deluge/tests/test_ui_entry.py @@ -19,11 +19,8 @@ from twisted.internet import defer import deluge import deluge.component as component -import deluge.ui.console -import deluge.ui.console.cmdline.commands.quit -import deluge.ui.console.main import deluge.ui.web.server -from deluge.common import get_localhost_auth, utf8_encode_structure +from deluge.common import get_localhost_auth, utf8_encode_structure, windows_check from deluge.ui import ui_entry from deluge.ui.web.server import DelugeWeb @@ -31,6 +28,11 @@ from . import common from .basetest import BaseTestCase from .daemon_base import DaemonBase +if not windows_check(): + import deluge.ui.console + import deluge.ui.console.cmdline.commands.quit + import deluge.ui.console.main + DEBUG_COMMAND = False sys_stdout = sys.stdout @@ -96,6 +98,9 @@ class UIWithDaemonBaseTestCase(UIBaseTestCase, DaemonBase): class DelugeEntryTestCase(BaseTestCase): + if windows_check(): + skip = 'cannot test console ui on windows' + def set_up(self): common.set_tmp_config_dir() return component.start() @@ -229,6 +234,9 @@ class WebUIBaseTestCase(UIBaseTestCase): class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase): + if windows_check(): + skip = 'cannot test console ui on windows' + def __init__(self, testname): super(WebUIScriptEntryTestCase, self).__init__(testname) WebUIBaseTestCase.__init__(self) @@ -245,6 +253,9 @@ class WebUIScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase): class WebUIDelugeScriptEntryTestCase(BaseTestCase, WebUIBaseTestCase): + if windows_check(): + skip = 'cannot test console ui on windows' + def __init__(self, testname): super(WebUIDelugeScriptEntryTestCase, self).__init__(testname) WebUIBaseTestCase.__init__(self) @@ -354,6 +365,9 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase): class ConsoleScriptEntryWithDaemonTestCase(BaseTestCase, ConsoleUIWithDaemonBaseTestCase): + if windows_check(): + skip = 'cannot test console ui on windows' + def __init__(self, testname): super(ConsoleScriptEntryWithDaemonTestCase, self).__init__(testname) ConsoleUIWithDaemonBaseTestCase.__init__(self) @@ -377,6 +391,9 @@ class ConsoleScriptEntryWithDaemonTestCase(BaseTestCase, ConsoleUIWithDaemonBase class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase): + if windows_check(): + skip = 'cannot test console ui on windows' + def __init__(self, testname): super(ConsoleScriptEntryTestCase, self).__init__(testname) ConsoleUIBaseTestCase.__init__(self) @@ -393,6 +410,9 @@ class ConsoleScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase): class ConsoleDelugeScriptEntryTestCase(BaseTestCase, ConsoleUIBaseTestCase): + if windows_check(): + skip = 'cannot test console ui on windows' + def __init__(self, testname): super(ConsoleDelugeScriptEntryTestCase, self).__init__(testname) ConsoleUIBaseTestCase.__init__(self) diff --git a/docs/source/conf.py b/docs/source/conf.py index 4b6300fa0..2326f5adc 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -57,9 +57,13 @@ class Mock(object): return Mock() -MOCK_MODULES = ['deluge.ui.gtkui.gtkui', 'deluge._libtorrent', - 'libtorrent', 'psyco', - 'pygtk', 'gtk', 'gobject', 'gtk.gdk', 'pango', 'cairo', 'pangocairo'] +MOCK_MODULES = [ + 'deluge.ui.gtkui.gtkui', 'deluge._libtorrent', + 'libtorrent', 'psyco', + 'pygtk', 'gtk', 'gobject', 'gtk.gdk', 'pango', 'cairo', 'pangocairo', + 'curses', 'win32api', 'win32file', 'win32process', 'win32pipe', + 'pywintypes', 'win32con', 'win32event', +] for mod_name in MOCK_MODULES: sys.modules[mod_name] = Mock()