diff --git a/.appveyor.yml b/.appveyor.yml index b11c90717..1d0362b82 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,8 +28,9 @@ test_script: - pylint lbrynet # disable tests for now so that appveyor can build the app - set PYTHONPATH=. -- trial tests/unit -#- python -m twisted.trial tests # avoids having to set PYTHONPATH=. (see https://twistedmatrix.com/trac/ticket/9035) +- trial tests +# TODO: integration tests do not work +#- python -m unittest discover tests/integration #- rvm use 2.3.1 && gem install danger --version '~> 4.0' && danger diff --git a/tests/functional/test_misc.py b/tests/functional/test_misc.py index 77d912442..148c2feb0 100644 --- a/tests/functional/test_misc.py +++ b/tests/functional/test_misc.py @@ -65,6 +65,19 @@ def use_epoll_on_linux(): sys.modules['twisted.internet.reactor'] = twisted.internet.reactor +def init_conf_windows(settings={}): + """ + There is no fork on windows, so imports + are freshly initialized in new processes. + So conf needs to be intialized for new processes + """ + if os.name == 'nt': + original_settings = conf.settings + conf.settings = conf.Config(conf.FIXED_SETTINGS, conf.ADJUSTABLE_SETTINGS) + conf.settings.installation_id = conf.settings.get_installation_id() + conf.settings.update(settings) + + class LbryUploader(object): def __init__(self, sd_hash_queue, kill_event, dead_event, file_size, ul_rate_limit=None, is_generous=False): @@ -84,6 +97,8 @@ class LbryUploader(object): def start(self): use_epoll_on_linux() + init_conf_windows() + from twisted.internet import reactor self.reactor = reactor logging.debug("Starting the uploader") @@ -98,6 +113,7 @@ class LbryUploader(object): self.sd_identifier = StreamDescriptorIdentifier() db_dir = "server" os.mkdir(db_dir) + self.session = Session( conf.ADJUSTABLE_SETTINGS['data_rate'][1], db_dir=db_dir, lbryid="abcd", peer_finder=peer_finder, hash_announcer=hash_announcer, peer_port=5553, @@ -182,6 +198,7 @@ class LbryUploader(object): def start_lbry_reuploader(sd_hash, kill_event, dead_event, ready_event, n, ul_rate_limit=None, is_generous=False): use_epoll_on_linux() + init_conf_windows() from twisted.internet import reactor logging.debug("Starting the uploader") @@ -295,6 +312,7 @@ def start_lbry_reuploader(sd_hash, kill_event, dead_event, def start_blob_uploader(blob_hash_queue, kill_event, dead_event, slow, is_generous=False): use_epoll_on_linux() + init_conf_windows() from twisted.internet import reactor logging.debug("Starting the uploader")