Skip to content
Snippets Groups Projects
Commit 9771fb86 authored by John Chilton's avatar John Chilton
Browse files

More PEP8-y test helper names.

parent c06a559d
No related branches found
No related tags found
No related merge requests found
import threading import threading
from .test_utils import skipUnlessModule from .test_utils import skip_unless_module
from pulsar.client import amqp_exchange from pulsar.client import amqp_exchange
TEST_CONNECTION = "memory://test_amqp" TEST_CONNECTION = "memory://test_amqp"
@skipUnlessModule("kombu") @skip_unless_module("kombu")
def test_amqp(): def test_amqp():
manager1_exchange = amqp_exchange.PulsarExchange(TEST_CONNECTION, "manager_test") manager1_exchange = amqp_exchange.PulsarExchange(TEST_CONNECTION, "manager_test")
manager3_exchange = amqp_exchange.PulsarExchange(TEST_CONNECTION, "manager3_test") manager3_exchange = amqp_exchange.PulsarExchange(TEST_CONNECTION, "manager3_test")
......
...@@ -4,9 +4,9 @@ from six import next, itervalues ...@@ -4,9 +4,9 @@ from six import next, itervalues
from six.moves import configparser from six.moves import configparser
from .test_utils import ( from .test_utils import (
TempDirectoryTestCase, TempDirectoryTestCase,
skipUnlessExecutable, skip_unless_executable,
skipUnlessModule, skip_unless_module,
skipUnlessAnyModule skip_unless_any_module
) )
from .test_utils import test_pulsar_app from .test_utils import test_pulsar_app
...@@ -96,7 +96,7 @@ class IntegrationTests(BaseIntegrationTest): ...@@ -96,7 +96,7 @@ class IntegrationTests(BaseIntegrationTest):
def test_integration_no_requirement(self): def test_integration_no_requirement(self):
self._run(private_token=None, **self.default_kwargs) self._run(private_token=None, **self.default_kwargs)
@skipUnlessModule("drmaa") @skip_unless_module("drmaa")
def test_integration_as_user(self): def test_integration_as_user(self):
job_props = {'type': 'queued_external_drmaa', "production": "false"} job_props = {'type': 'queued_external_drmaa', "production": "false"}
self._run(job_conf_props=job_props, private_token=None, default_file_action="copy", user='u1', **self.default_kwargs) self._run(job_conf_props=job_props, private_token=None, default_file_action="copy", user='u1', **self.default_kwargs)
...@@ -104,8 +104,8 @@ class IntegrationTests(BaseIntegrationTest): ...@@ -104,8 +104,8 @@ class IntegrationTests(BaseIntegrationTest):
def test_integration_local_setup(self): def test_integration_local_setup(self):
self._run(private_token=None, default_file_action="remote_copy", local_setup=True, **self.default_kwargs) self._run(private_token=None, default_file_action="remote_copy", local_setup=True, **self.default_kwargs)
@skipUnlessModule("pycurl") @skip_unless_module("pycurl")
@skipUnlessModule("kombu") @skip_unless_module("kombu")
def test_message_queue(self): def test_message_queue(self):
self._run( self._run(
app_conf=dict(message_queue_url="memory://test1"), app_conf=dict(message_queue_url="memory://test1"),
...@@ -128,7 +128,7 @@ class IntegrationTests(BaseIntegrationTest): ...@@ -128,7 +128,7 @@ class IntegrationTests(BaseIntegrationTest):
def test_integration_default(self): def test_integration_default(self):
self._run(private_token=None, **self.default_kwargs) self._run(private_token=None, **self.default_kwargs)
@skipUnlessModule("pycurl") @skip_unless_module("pycurl")
def test_integration_curl(self): def test_integration_curl(self):
self._run(private_token=None, transport="curl", **self.default_kwargs) self._run(private_token=None, transport="curl", **self.default_kwargs)
...@@ -138,19 +138,19 @@ class IntegrationTests(BaseIntegrationTest): ...@@ -138,19 +138,19 @@ class IntegrationTests(BaseIntegrationTest):
def test_integration_errors(self): def test_integration_errors(self):
self._run(app_conf={"private_token": "testtoken"}, private_token="testtoken", test_errors=True, **self.default_kwargs) self._run(app_conf={"private_token": "testtoken"}, private_token="testtoken", test_errors=True, **self.default_kwargs)
@skipUnlessModule("drmaa") @skip_unless_module("drmaa")
def test_integration_drmaa(self): def test_integration_drmaa(self):
self._run(app_conf={}, job_conf_props={'type': 'queued_drmaa'}, private_token=None, **self.default_kwargs) self._run(app_conf={}, job_conf_props={'type': 'queued_drmaa'}, private_token=None, **self.default_kwargs)
@skipUnlessExecutable("condor_submit") @skip_unless_executable("condor_submit")
def test_integration_condor(self): def test_integration_condor(self):
self._run(app_conf={}, job_conf_props={'type': 'queued_condor'}, private_token=None, **self.default_kwargs) self._run(app_conf={}, job_conf_props={'type': 'queued_condor'}, private_token=None, **self.default_kwargs)
@skipUnlessExecutable("qsub") @skip_unless_executable("qsub")
def test_integration_cli_torque(self): def test_integration_cli_torque(self):
self._run(app_conf={}, job_conf_props={'type': 'queued_cli', 'job_plugin': 'Torque'}, private_token=None, **self.default_kwargs) self._run(app_conf={}, job_conf_props={'type': 'queued_cli', 'job_plugin': 'Torque'}, private_token=None, **self.default_kwargs)
@skipUnlessExecutable("sbatch") @skip_unless_executable("sbatch")
def test_integration_cli_slurm(self): def test_integration_cli_slurm(self):
self._run(app_conf={}, job_conf_props={'type': 'queued_cli', 'job_plugin': 'Slurm'}, private_token=None, **self.default_kwargs) self._run(app_conf={}, job_conf_props={'type': 'queued_cli', 'job_plugin': 'Slurm'}, private_token=None, **self.default_kwargs)
...@@ -158,7 +158,7 @@ class IntegrationTests(BaseIntegrationTest): ...@@ -158,7 +158,7 @@ class IntegrationTests(BaseIntegrationTest):
class DirectIntegrationTests(IntegrationTests): class DirectIntegrationTests(IntegrationTests):
default_kwargs = dict(direct_interface=True, test_requirement=False) default_kwargs = dict(direct_interface=True, test_requirement=False)
@skipUnlessAnyModule(["pycurl", "poster", "requests_toolbelt"]) @skip_unless_any_module(["pycurl", "poster", "requests_toolbelt"])
def test_integration_remote_transfer(self): def test_integration_remote_transfer(self):
self._run( self._run(
private_token=None, private_token=None,
......
from .test_utils import ( from .test_utils import (
BaseManagerTestCase, BaseManagerTestCase,
skipUnlessModule skip_unless_module
) )
from pulsar.managers.queued_drmaa import DrmaaQueueManager from pulsar.managers.queued_drmaa import DrmaaQueueManager
...@@ -19,10 +19,10 @@ class DrmaaManagerTest(BaseManagerTestCase): ...@@ -19,10 +19,10 @@ class DrmaaManagerTest(BaseManagerTestCase):
def _set_manager(self, **kwds): def _set_manager(self, **kwds):
self.manager = DrmaaQueueManager('_default_', self.app, **kwds) self.manager = DrmaaQueueManager('_default_', self.app, **kwds)
@skipUnlessModule("drmaa") @skip_unless_module("drmaa")
def test_simple_execution(self): def test_simple_execution(self):
self._test_simple_execution(self.manager) self._test_simple_execution(self.manager)
@skipUnlessModule("drmaa") @skip_unless_module("drmaa")
def test_cancel(self): def test_cancel(self):
self._test_cancelling(self.manager) self._test_cancelling(self.manager)
...@@ -250,13 +250,13 @@ def test_pulsar_app(global_conf={}, app_conf={}, test_conf={}): ...@@ -250,13 +250,13 @@ def test_pulsar_app(global_conf={}, app_conf={}, test_conf={}):
pass pass
def skipUnlessExecutable(executable): def skip_unless_executable(executable):
if __which(executable): if _which(executable):
return lambda func: func return lambda func: func
return skip("PATH doesn't contain executable %s" % executable) return skip("PATH doesn't contain executable %s" % executable)
def skipUnlessModule(module): def skip_unless_module(module):
available = True available = True
try: try:
__import__(module) __import__(module)
...@@ -267,7 +267,7 @@ def skipUnlessModule(module): ...@@ -267,7 +267,7 @@ def skipUnlessModule(module):
return skip("Module %s could not be loaded, dependent test skipped." % module) return skip("Module %s could not be loaded, dependent test skipped." % module)
def skipUnlessAnyModule(modules): def skip_unless_any_module(modules):
available = False available = False
for module in modules: for module in modules:
try: try:
...@@ -280,7 +280,7 @@ def skipUnlessAnyModule(modules): ...@@ -280,7 +280,7 @@ def skipUnlessAnyModule(modules):
return skip("None of the modules %s could be loaded, dependent test skipped." % modules) return skip("None of the modules %s could be loaded, dependent test skipped." % modules)
def __which(program): def _which(program):
def is_exe(fpath): def is_exe(fpath):
return isfile(fpath) and access(fpath, X_OK) return isfile(fpath) and access(fpath, X_OK)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment