Skip to content

Commit

Permalink
Split Generators tests from Sequence tests (keras-team#11901)
Browse files Browse the repository at this point in the history
* Split Sequence test from generator tests

* use_spawn check for windows

* Do not copy use_spawn

* Remove unused param
  • Loading branch information
Frédéric Branchaud-Charron authored and gabrieldemarmiesse committed Dec 20, 2018
1 parent f199d00 commit 8f41e41
Show file tree
Hide file tree
Showing 2 changed files with 328 additions and 124 deletions.
16 changes: 9 additions & 7 deletions tests/keras/utils/data_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import six
from six.moves.urllib.parse import urljoin
from six.moves.urllib.request import pathname2url
import warnings

from flaky import flaky

Expand All @@ -33,17 +32,15 @@
'TRAVIS_PYTHON_VERSION' in os.environ,
reason='Generators do not work with `spawn`.')

if sys.version_info < (3,):
def next(x):
return x.next()


def use_spawn(func):
"""Decorator to test both Unix (fork) and Windows (spawn)"""
"""Decorator which uses `spawn` when possible.
This is useful on Travis to avoid memory issues.
"""

@six.wraps(func)
def wrapper(*args, **kwargs):
if sys.version_info > (3, 4):
if sys.version_info > (3, 4) and os.name != 'nt':
mp.set_start_method('spawn', force=True)
out = func(*args, **kwargs)
mp.set_start_method('fork', force=True)
Expand All @@ -54,6 +51,11 @@ def wrapper(*args, **kwargs):
return wrapper


if sys.version_info < (3,):
def next(x):
return x.next()


@pytest.fixture
def in_tmpdir(tmpdir):
"""Runs a function in a temporary directory.
Expand Down
Loading

0 comments on commit 8f41e41

Please sign in to comment.