Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions distarray/globalapi/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@
import distarray.globalapi.functions as functions
from distarray.globalapi import Context, ContextCreationError

SKIP = True
try:
glb_ctx = Context()
except ContextCreationError:
raise unittest.SkipTest()
SKIP = False
except EnvironmentError:
pass

def setUpModule():
global glb_ctx
if not glb_ctx:
if not SKIP and not glb_ctx:
glb_ctx = Context()

def tearDownModule():
if glb_ctx:
if not SKIP and glb_ctx:
glb_ctx.close()

def add_checkers(cls, ops_and_data, checker_name):
Expand All @@ -48,10 +50,14 @@ def add_checkers(cls, ops_and_data, checker_name):

ops, data = ops_and_data

dist_data = tuple(glb_ctx.fromndarray(d) for d in data)
if not SKIP:
dist_data = tuple(glb_ctx.fromndarray(d) for d in data)

def check(op_name):
return lambda self: op_checker(self, op_name, data, dist_data)
if SKIP:
return lambda self: None
else:
return lambda self: op_checker(self, op_name, data, dist_data)

for op_name in ops:
op_test_name = 'test_' + op_name
Expand Down
22 changes: 12 additions & 10 deletions distarray/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,25 +214,27 @@ class IPythonContextTestCase(BaseContextTestCase):

@classmethod
def make_context(cls, targets=None):
return Context(kind='IPython', targets=targets)

@classmethod
def setUpClass(cls):
try:
super(IPythonContextTestCase, cls).setUpClass()
# except EnvironmentError:
except IOError:
return Context(kind='IPython', targets=targets)
except EnvironmentError:
msg = "You must have an ipcluster running to run this test case."
raise unittest.SkipTest(msg)
else:
cls.client = cls.context.client

@classmethod
def setUpClass(cls):
super(IPythonContextTestCase, cls).setUpClass()
cls.client = cls.context.client


class DefaultContextTestCase(BaseContextTestCase):

@classmethod
def make_context(cls, targets=None):
return Context(targets=targets)
try:
return Context(targets=targets)
except EnvironmentError:
msg = "You must have an ipcluster running to run this test case."
raise unittest.SkipTest(msg)


def check_targets(required, available):
Expand Down