summaryrefslogtreecommitdiff
path: root/src/sardana
diff options
context:
space:
mode:
authorcpascual <cpascual@cells.es>2014-03-31 17:09:51 +0200
committercpascual <cpascual@cells.es>2014-03-31 17:09:51 +0200
commit9092650f8f6c3579aefe95173205b6af5c481fb3 (patch)
treee0f13271b9802bf414a141b258782d24ca702786 /src/sardana
parentac1e1bfa755002c0ca8e9c19261f09fd99b77c4a (diff)
Apply autopep8 to sep5 files
This commit is the result of applying the following command to the sardana root dir: find ./ -name test -type d -exec autopep8 -ir --ignore E269 {} \;
Diffstat (limited to 'src/sardana')
-rw-r--r--src/sardana/macroserver/macros/test/__init__.py8
-rwxr-xr-xsrc/sardana/macroserver/macros/test/base.py269
-rw-r--r--src/sardana/macroserver/macros/test/macroexecutor.py133
-rwxr-xr-xsrc/sardana/macroserver/macros/test/sardemoenv.py89
-rw-r--r--src/sardana/macroserver/macros/test/test_ct.py16
-rwxr-xr-xsrc/sardana/macroserver/macros/test/test_list.py53
-rwxr-xr-xsrc/sardana/macroserver/macros/test/test_scan.py79
-rw-r--r--src/sardana/macroserver/macros/test/test_wm.py23
-rwxr-xr-xsrc/sardana/spock/test/__init__.py10
-rw-r--r--src/sardana/spock/test/test_parameter.py57
-rw-r--r--src/sardana/tango/macroserver/test/__init__.py6
-rwxr-xr-xsrc/sardana/tango/macroserver/test/macroexecutor.py74
-rw-r--r--src/sardana/test/__init__.py46
-rw-r--r--src/sardana/test/test_sardanavalue.py73
-rw-r--r--src/sardana/test/testsuite.py13
15 files changed, 484 insertions, 465 deletions
diff --git a/src/sardana/macroserver/macros/test/__init__.py b/src/sardana/macroserver/macros/test/__init__.py
index 692f24fe..41018731 100644
--- a/src/sardana/macroserver/macros/test/__init__.py
+++ b/src/sardana/macroserver/macros/test/__init__.py
@@ -7,23 +7,23 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
##############################################################################
from macroexecutor import BaseMacroExecutor, MacroExecutorFactory
-from base import (macroTest, BaseMacroTestCase, RunMacroTestCase,
+from base import (macroTest, BaseMacroTestCase, RunMacroTestCase,
RunStopMacroTestCase, testRun, testFail, testStop)
from sardemoenv import SarDemoEnv
diff --git a/src/sardana/macroserver/macros/test/base.py b/src/sardana/macroserver/macros/test/base.py
index c5968979..7c2c0f51 100755
--- a/src/sardana/macroserver/macros/test/base.py
+++ b/src/sardana/macroserver/macros/test/base.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -25,8 +25,8 @@
"""System tests for Macros"""
-__all__ = ['macroTest', 'BaseMacroTestCase', 'RunMacroTestCase',
- 'RunStopMacroTestCase', 'testRun', 'testFail' 'testStop']
+__all__ = ['macroTest', 'BaseMacroTestCase', 'RunMacroTestCase',
+ 'RunStopMacroTestCase', 'testRun', 'testFail' 'testStop']
import time
import functools
from sardana import sardanacustomsettings
@@ -39,88 +39,89 @@ class __NotPassedType(int):
pass
_NOT_PASSED = __NotPassedType()
-def macroTest(klass=None, helper_name=None, test_method_name=None,
- test_method_doc = None, **helper_kwargs):
+
+def macroTest(klass=None, helper_name=None, test_method_name=None,
+ test_method_doc=None, **helper_kwargs):
"""Decorator to insert test methods from a helper method that accepts
arguments.
-
- macroTest provides a very economic API for creating new tests for a given
+
+ macroTest provides a very economic API for creating new tests for a given
class based on a helper method.
-
+
macroTest accepts the following arguments:
-
+
- helper_name (str): the name of the helper method. macroTest will
- insert a test method which calls the helper with
+ insert a test method which calls the helper with
any the helper_kwargs (see below).
- test_method_name (str): Optional. Name of the test method to be used.
- If None given, one will be generated from the
+ If None given, one will be generated from the
macro and helper names.
- - test_method_doc (str): The docstring for the inserted test method
- (this shows in the unit test output). If None
- given, a default one is generated which
- includes the input parameters and the helper
+ - test_method_doc (str): The docstring for the inserted test method
+ (this shows in the unit test output). If None
+ given, a default one is generated which
+ includes the input parameters and the helper
name.
- - \*\*helper_kwargs: Any remaining keyword arguments are passed to the
- helper.
-
- macroTest assumes that the decorated class inherits from unittest.TestCase
+ - \*\*helper_kwargs: Any remaining keyword arguments are passed to the
+ helper.
+
+ macroTest assumes that the decorated class inherits from unittest.TestCase
and that it has a macro_name class member.
-
- This decorator can be considered a "base" decorator. It is often used to
- create other decorators in which the helper method is pre-set. Some
+
+ This decorator can be considered a "base" decorator. It is often used to
+ create other decorators in which the helper method is pre-set. Some
of them are already provided in this module:
-
+
- :meth:`testRun` is equivalent to macroTest with helper_name='macro_runs'
- :meth:`testStop` is equivalent to macroTest with helper_name='macro_stops'
- :meth:`testFail` is equivalent to macroTest with helper_name='macro_fails'
-
- The advantage of using the decorators compared to writing the test methods
- directly is that the helper method can get keyword arguments and therefore
- avoid duplication of code for very similar tests (think, e.g. on writing
+
+ The advantage of using the decorators compared to writing the test methods
+ directly is that the helper method can get keyword arguments and therefore
+ avoid duplication of code for very similar tests (think, e.g. on writing
similar tests for various sets of macro input parameters):
-
- Consider the following code written using the
+
+ Consider the following code written using the
:meth:`RunMacroTestCase.macro_runs` helper::
-
+
class FooTest(RunMacroTestCase, unittest.TestCase)
macro_name = twice
-
+
def test_foo_runs_with_input_2(self):
'''test that twice(2) runs'''
self.macro_runs(macro_params=['2'])
-
+
def test_foo_runs_with_input_minus_1(self):
'''test that twice(2) runs'''
self.macro_runs(macro_params=['-1'])
-
+
The equivalent code could be written as::
-
+
@macroTest(helper_name='macro_runs', macro_params=['2'])
@macroTest(helper_name='macro_runs', macro_params=['-1'])
class FooTest(RunMacroTestCase, unittest.TestCase):
macro_name = 'twice'
-
+
Or, even better, using the specialized testRun decorator::
-
+
@testRun(macro_params=['2'])
@testRun(macro_params=['-1'])
class FooTest(RunMacroTestCase, unittest.TestCase):
- macro_name = 'twice'
+ macro_name = 'twice'
"""
- #TODO: Note: this could be generalized to general tests.
- # In fact the only "macro-specific" thing here is the assumption
+ #TODO: Note: this could be generalized to general tests.
+ # In fact the only "macro-specific" thing here is the assumption
# that klass.macro_name exists
- if klass is None: #recipe to use
- return functools.partial(macroTest, helper_name=helper_name,
+ if klass is None: # recipe to use
+ return functools.partial(macroTest, helper_name=helper_name,
test_method_name=test_method_name,
- test_method_doc = test_method_doc,
+ test_method_doc=test_method_doc,
**helper_kwargs)
-
+
if helper_name is None:
raise ValueError('helper_name argument is not optional')
-
+
if test_method_name is None:
test_method_name = 'test_%s_%s' % (klass.macro_name, helper_name)
#Append an index if necessary to avoid overwriting the test method
@@ -129,76 +130,79 @@ def macroTest(klass=None, helper_name=None, test_method_name=None,
i += 1
name = "%s_%i" % (test_method_name, i)
test_method_name = name
-
+
if test_method_doc is None:
- argsrep = ', '.join(['%s=%s'%(k,v) for k,v in helper_kwargs.items()])
- test_method_doc = 'Testing %s with %s(%s)'%(klass.macro_name,
- helper_name, argsrep)
-
+ argsrep = ', '.join(['%s=%s' % (k, v)
+ for k, v in helper_kwargs.items()])
+ test_method_doc = 'Testing %s with %s(%s)' % (klass.macro_name,
+ helper_name, argsrep)
+
# New test implementation
# Sets the passed parameters and adds super and self implementation
def newTest(obj):
helper = getattr(obj, helper_name)
return helper(**helper_kwargs)
-
+
#setup a custom docstring
newTest.__doc__ = test_method_doc
-
+
# Add the new test method with the new implementation
setattr(klass, test_method_name, newTest)
-
+
return klass
-
-#Definition of specializations of the macroTest decorator:
+
+#Definition of specializations of the macroTest decorator:
testRun = functools.partial(macroTest, helper_name='macro_runs')
testStop = functools.partial(macroTest, helper_name='macro_stops')
testFail = functools.partial(macroTest, helper_name='macro_fails')
class BaseMacroTestCase(object):
+
"""An abstract class for macro testing.
- BaseMacroTestCase will provide a `macro_executor` member which is an
+ BaseMacroTestCase will provide a `macro_executor` member which is an
instance of BaseMacroExecutor and which can be used to run a macro.
-
+
To use it, simply inherit from BaseMacroTestCase *and* unittest.TestCase
and provide the following class members:
-
+
- macro_name (string) name of the macro to be tested (mandatory)
- door_name (string) name of the door where the macro will be executed.
- This is optional. If not set,
+ This is optional. If not set,
`sardanacustomsettings.UNITTEST_DOOR_NAME` is used
-
+
Then you may define test methods.
"""
macro_name = None
- door_name = getattr(sardanacustomsettings,'UNITTEST_DOOR_NAME')
-
+ door_name = getattr(sardanacustomsettings, 'UNITTEST_DOOR_NAME')
+
def setUp(self):
- """ A macro_executor instance must be created
+ """ A macro_executor instance must be created
"""
if self.macro_name is None:
- msg = '%s does not define macro_name' % self.__class__.__name__
- raise NotImplementedError(msg)
+ msg = '%s does not define macro_name' % self.__class__.__name__
+ raise NotImplementedError(msg)
mefact = MacroExecutorFactory()
self.macro_executor = mefact.getMacroExecutor(self.door_name)
-
+
def tearDown(self):
- """The macro_executor instance must be removed
+ """The macro_executor instance must be removed
"""
self.macro_executor.unregisterAll()
self.macro_executor = None
class RunMacroTestCase(BaseMacroTestCase):
+
"""A base class for testing execution of arbitrary Sardana macros.
See :class:`BaseMacroTestCase` for requirements.
-
+
It provides the following helper methods:
- - :meth:`macro_runs`
- - :meth:`macro_fails`
+ - :meth:`macro_runs`
+ - :meth:`macro_fails`
"""
-
+
def assertFinished(self, msg):
"""Asserts that macro has finished.
"""
@@ -210,75 +214,77 @@ class RunMacroTestCase(BaseMacroTestCase):
self.assertIn(state, finishStates, msg)
def setUp(self):
- """Preconditions:
+ """Preconditions:
- Those from :class:`BaseMacroTestCase`
- the macro executor registers to all the log levels
"""
BaseMacroTestCase.setUp(self)
self.macro_executor.registerAll()
-
+
def macro_runs(self, macro_params=None, wait_timeout=float("inf"),
data=_NOT_PASSED):
- """A helper method to create tests that check if the macro can be
- successfully executed for the given input parameters. It may also
+ """A helper method to create tests that check if the macro can be
+ successfully executed for the given input parameters. It may also
optionally perform checks on the outputs from the execution.
-
- :param macro_params: (seq<str>): parameters for running the macro.
- If passed, they must be given as a sequence of
+
+ :param macro_params: (seq<str>): parameters for running the macro.
+ If passed, they must be given as a sequence of
their string representations.
:param wait_timeout: (float) maximum allowed time (in s) for the macro
to finish. By default infinite timeout is used.
- :param data: (obj) Optional. If passed, the macro data after the
+ :param data: (obj) Optional. If passed, the macro data after the
execution is tested to be equal to this.
"""
- self.macro_executor.run(macro_name = self.macro_name,
- macro_params = macro_params,
- sync = True, timeout = wait_timeout)
+ self.macro_executor.run(macro_name=self.macro_name,
+ macro_params=macro_params,
+ sync=True, timeout=wait_timeout)
self.assertFinished('Macro %s did not finish' % self.macro_name)
-
- #check if the data of the macro is the expected one
+
+ #check if the data of the macro is the expected one
if data is not _NOT_PASSED:
actual_data = self.macro_executor.getData()
msg = 'Macro data does not match expected data:\n' + \
- 'obtained=%s\nexpected=%s'%(actual_data, data)
+ 'obtained=%s\nexpected=%s' % (actual_data, data)
self.assertEqual(actual_data, data, msg)
-
+
#TODO: implement generic asserts for macro result and macro output, etc
# in a similar way to what is done for macro data
-
+
def macro_fails(self, macro_params=None, wait_timeout=float("inf"),
- exception=None):
+ exception=None):
"""Check that the macro fails to run for the given input parameters
-
- :param macro_params: (seq<str>) input parameters for the macro
- :param wait_timeout: maximum allowed time for the macro to fail. By
+
+ :param macro_params: (seq<str>) input parameters for the macro
+ :param wait_timeout: maximum allowed time for the macro to fail. By
default infinite timeout is used.
- :param exception: (str or Exception) if given, an additional check of
- the type of the exception is done.
- (IMPORTANT: this is just a comparison of str
+ :param exception: (str or Exception) if given, an additional check of
+ the type of the exception is done.
+ (IMPORTANT: this is just a comparison of str
representations of exception objects)
"""
- self.macro_executor.run(macro_name = self.macro_name,
- macro_params = macro_params,
- sync = True, timeout = wait_timeout)
+ self.macro_executor.run(macro_name=self.macro_name,
+ macro_params=macro_params,
+ sync=True, timeout=wait_timeout)
state = self.macro_executor.getState()
actual_exc_str = self.macro_executor.getExceptionStr()
- msg = 'Post-execution state should be "exception" (got "%s")'%state
- self.assertEqual(state, 'exception', msg)
-
+ msg = 'Post-execution state should be "exception" (got "%s")' % state
+ self.assertEqual(state, 'exception', msg)
+
if exception is not None:
msg = 'Raised exception does not match expected exception:\n' + \
- 'raised=%s\nexpected=%s'%(actual_exc_str, exception)
- self.assertEqual(actual_exc_str, str(exception), msg)
-
-
+ 'raised=%s\nexpected=%s' % (actual_exc_str, exception)
+ self.assertEqual(actual_exc_str, str(exception), msg)
+
+
class RunStopMacroTestCase(RunMacroTestCase):
- """This is an extension of :class:`RunMacroTestCase` to include helpers for
- testing the abort process of a macro. Useful for Runnable and Stopable
+
+ """This is an extension of :class:`RunMacroTestCase` to include helpers for
+ testing the abort process of a macro. Useful for Runnable and Stopable
macros.
- It provides the :meth:`macro_stops` helper
+ It provides the :meth:`macro_stops` helper
"""
+
def assertStopped(self, msg):
"""Asserts that macro was stopped
"""
@@ -287,56 +293,55 @@ class RunStopMacroTestCase(RunMacroTestCase):
#TODO buffer is just for debugging, attach only the last state
state_buffer = self.macro_executor.getStateBuffer()
msg = msg + '; State buffer was %s' % state_buffer
- self.assertIn(state, stoppedStates, msg)
-
- def macro_stops(self, macro_params=None, stop_delay=0.1,
+ self.assertIn(state, stoppedStates, msg)
+
+ def macro_stops(self, macro_params=None, stop_delay=0.1,
wait_timeout=float("inf")):
- """A helper method to create tests that check if the macro can be
+ """A helper method to create tests that check if the macro can be
successfully stoped (a.k.a. aborted) after it has been launched.
-
- :param macro_params: (seq<str>): parameters for running the macro.
- If passed, they must be given as a sequence of
+
+ :param macro_params: (seq<str>): parameters for running the macro.
+ If passed, they must be given as a sequence of
their string representations.
- :param stop_delay: (float) Time (in s) to wait between launching the
- macro and sending the stop command. default=0.1
+ :param stop_delay: (float) Time (in s) to wait between launching the
+ macro and sending the stop command. default=0.1
:param wait_timeout: (float) maximum allowed time (in s) for the macro
to finish. By default infinite timeout is used.
"""
- self.macro_executor.run(macro_name = self.macro_name,
- macro_params = macro_params,
- sync = False)
+ self.macro_executor.run(macro_name=self.macro_name,
+ macro_params=macro_params,
+ sync=False)
if stop_delay is not None:
time.sleep(stop_delay)
self.macro_executor.stop()
- self.macro_executor.wait(timeout = wait_timeout)
+ self.macro_executor.wait(timeout=wait_timeout)
self.assertStopped('Macro %s did not stop' % self.macro_name)
-
+
if __name__ == '__main__':
import unittest
from sardana.macroserver.macros.test import SarDemoEnv
-
+
_m1 = SarDemoEnv().getMotors()[0]
-
-
+
#@testRun(macro_params=[_m1, '0', '100', '4', '.1'])
@testRun(macro_params=[_m1, '1', '0', '2', '.1'])
@testRun(macro_params=[_m1, '0', '1', '4', '.1'])
class dummyAscanTest(RunStopMacroTestCase, unittest.TestCase):
macro_name = 'ascan'
-
-
- @testRun(macro_params=['1'], data={'in':1,'out':2})
+
+ @testRun(macro_params=['1'], data={'in': 1, 'out': 2})
@testRun(macro_params=['5'])
@testRun
class dummyTwiceTest(RunStopMacroTestCase, unittest.TestCase):
macro_name = 'twice'
-
+
@testFail
@testFail(exception=Exception)
class dummyRaiseException(RunStopMacroTestCase, unittest.TestCase):
macro_name = 'raise_exception'
-
- suite = unittest.defaultTestLoader.loadTestsFromTestCase(dummyRaiseException)
- unittest.TextTestRunner(descriptions=True, verbosity=2).run(suite)
+
+ suite = unittest.defaultTestLoader.loadTestsFromTestCase(
+ dummyRaiseException)
+ unittest.TextTestRunner(descriptions=True, verbosity=2).run(suite)
diff --git a/src/sardana/macroserver/macros/test/macroexecutor.py b/src/sardana/macroserver/macros/test/macroexecutor.py
index e4fbcdc9..b255b879 100644
--- a/src/sardana/macroserver/macros/test/macroexecutor.py
+++ b/src/sardana/macroserver/macros/test/macroexecutor.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -27,11 +27,12 @@ from taurus.core.util.singleton import Singleton
class BaseMacroExecutor(object):
- """Abstract MacroExecutor class. Inherit from it if you want to create your
+
+ """Abstract MacroExecutor class. Inherit from it if you want to create your
own macro executor.
"""
- log_levels = ['debug', 'output', 'info', 'warning', 'critical', 'error']
+ log_levels = ['debug', 'output', 'info', 'warning', 'critical', 'error']
def __init__(self):
# macro result
@@ -47,33 +48,33 @@ class BaseMacroExecutor(object):
self._common = None
def _clean(self):
- """In case of reuse of the macro executor object this method executes
- the necessary cleanups. Extend if you need to clean your particular
- setups.
+ """In case of reuse of the macro executor object this method executes
+ the necessary cleanups. Extend if you need to clean your particular
+ setups.
"""
for level in self.log_levels:
log_buffer = getattr(self, '_%s' % level)
if not log_buffer is None:
log_buffer.__init__()
-
+
if self._common:
self._common.__init__()
- def run(self, macro_name, macro_params=None, sync=True,
+ def run(self, macro_name, macro_params=None, sync=True,
timeout=float("inf")):
"""Execute macro.
-
+
:param macro_name: (string) name of macro to be executed
- :param macro_params: (list<string>) macro parameters
+ :param macro_params: (list<string>) macro parameters
(default is macro_params=None for macros without
parameters or with the default values)
:param sync: (bool) whether synchronous or asynchronous call
(default is sync=True)
- :param timeout: (float) timeout (in s) that will be passed to the wait
+ :param timeout: (float) timeout (in s) that will be passed to the wait
method, in case of synchronous execution
- In asyncrhonous execution method :meth:`~wait` has to be explicitly
- called.
+ In asyncrhonous execution method :meth:`~wait` has to be explicitly
+ called.
"""
if macro_params == None:
macro_params = []
@@ -87,9 +88,9 @@ class BaseMacroExecutor(object):
def _run(self, macro_name, macro_params):
"""Method responsible for triggering the macro execution. Must be
implemented in your macro executor.
-
+
:param macro_name: (string) name of macro to be executed
- :param macro_params: (list<string>) macro parameters
+ :param macro_params: (list<string>) macro parameters
(default is macro_params=None for macros without
parameters or with the default values)
"""
@@ -99,18 +100,18 @@ class BaseMacroExecutor(object):
def wait(self, timeout=float("inf")):
"""
Wait until macro is done. Use it in asynchronous executions.
-
+
:param timeout: (float) waiting timeout (in s)
"""
if timeout <= 0:
- timeout = float("inf")
+ timeout = float("inf")
self._wait(timeout)
-
+
def _wait(self, timeout):
"""Method responsible for waiting until macro is done. Must be
implemented in your macro executor.
-
+
:param timeout: (float) waiting timeout (in s)
"""
raise NotImplementedError('Method _wait not implemented in class %s' %
@@ -119,7 +120,7 @@ class BaseMacroExecutor(object):
def stop(self, started_event_timeout=3.0):
"""Stop macro execution. Execute macro in synchronous way before using
this method.
-
+
:param started_event_timeout: (float) waiting timeout for started event
"""
self._stop(started_event_timeout)
@@ -128,7 +129,7 @@ class BaseMacroExecutor(object):
"""
Method responsible for stopping the macro execution. Must be
implemented in your macro executor.
-
+
:param started_event_timeout: (float) waiting timeout for started event
"""
raise NotImplementedError('Method _stop not implemented in class %s' %
@@ -136,44 +137,44 @@ class BaseMacroExecutor(object):
def registerLog(self, log_level):
"""Start registering log messages.
-
+
:param log_level: (str) string indicating the log level
"""
log_buffer_name = '_%s' % log_level
setattr(self, log_buffer_name, [])
self._registerLog(log_level)
-
+
def _registerLog(self, log_level):
"""
Method responsible for starting log registration. Must be
implemented in your macro executor.
-
+
:param log_level: (str) string indicating the log level
"""
raise NotImplementedError('Method _registerLog not implemented in '
'class %s' % self.__class__.__name__)
-
+
def unregisterLog(self, log_level):
"""Stop registering log messages.
-
+
:param log_level: (str) string indicating the log level
"""
self._unregisterLog(log_level)
-
+
def _unregisterLog(self, log_level):
"""Method responsible for stopping log registration. Must be
implemented in your macro executor.
-
+
:param log_level: (str) string indicating the log level
"""
raise NotImplementedError('Method _unregisterLog not implemented in '
'class %s' % self.__class__.__name__)
-
+
def getLog(self, log_level):
"""Get log messages.
-
+
:param log_level: (str) string indicating the log level
-
+
:return: (seq<str>) list of strings with log messages
"""
log_buffer_name = '_%s' % log_level
@@ -194,12 +195,12 @@ class BaseMacroExecutor(object):
for log_level in self.log_levels:
self.unregisterLog(log_level)
self.unregisterResult()
-
+
def registerResult(self):
"""Register for macro result
"""
self._registerResult()
-
+
def _registerResult(self):
"""Method responsible for registering for macro result. Must be
implemented in your macro executor.
@@ -211,7 +212,7 @@ class BaseMacroExecutor(object):
"""Unregister macro result.
"""
self._unregisterResult()
-
+
def _unregisterResult(self):
"""Method responsible for unregistering for macro result. Must be
implemented in your macro executor.
@@ -221,94 +222,94 @@ class BaseMacroExecutor(object):
def getResult(self):
"""Get macro result.
-
+
:return: (seq<str>) list of strings with Result messages
"""
return self._result
-
+
def createCommonBuffer(self):
"""Create a common buffer, where all the registered logs will be stored.
"""
self._common = []
-
+
def getCommonBuffer(self):
"""Get common buffer.
- Method getCommonBuffer can only be used if at least one buffer exists.
-
+ Method getCommonBuffer can only be used if at least one buffer exists.
+
:return: (seq<str>) list of strings with messages from all log levels
-
- .. seealso:: :meth:`~createCommonBuffer`
+
+ .. seealso:: :meth:`~createCommonBuffer`
"""
return self._common
def getState(self):
"""Get macro execution state.
-
+
:return: (str)
"""
state = None
if len(self._state_buffer) > 0:
state = self._state_buffer[-1]
return state
-
+
def getStateBuffer(self):
"""Get buffer (history) of macro execution states.
-
+
:return: (seq<str>)
"""
return self._state_buffer
-
+
def getExceptionStr(self):
- """Get macro exception type representation (None if the macro state
+ """Get macro exception type representation (None if the macro state
is not exception).
-
+
:return: (str)
"""
return self._exception
-
+
class MacroExecutorFactory(Singleton):
+
"""A scheme-agnostic factory for MacroExecutor instances
-
+
Example::
-
+
f = MacroExecutorFactory()
f.getMacroExecutor('tango://my/door/name') #returns a TangoMacroExecutor
-
+
Note: For the moment, only TangoMacroExecutor is supported
"""
-
+
def getMacroExecutor(self, door_name=None):
"""
- Returns a macro executor instance (a subclass of
+ Returns a macro executor instance (a subclass of
:class:`BaseMacroExecutor`) depending on the door being used.
- """
+ """
if door_name == None:
from sardana import sardanacustomsettings
- door_name = getattr(sardanacustomsettings,'UNITTEST_DOOR_NAME')
-
+ door_name = getattr(sardanacustomsettings, 'UNITTEST_DOOR_NAME')
+
#=======================================================================
# TODO: Once SEP3 is done, it will define a better way to get the scheme
# from a model name (including customized default schemes)
- # For the moment I implement it by calling an internal member of
+ # For the moment I implement it by calling an internal member of
# TaurusManager
from taurus.core import TaurusManager
scheme = TaurusManager()._get_scheme(door_name)
- #=======================================================================
+ #======================================================================
if scheme == 'tango':
return self._getTangoMacroExecutor(door_name)
else:
- raise ValueError('No MacroExecutor supported for scheme %s' % \
+ raise ValueError('No MacroExecutor supported for scheme %s' %
scheme)
-
+
def _getTangoMacroExecutor(self, door_name):
from sardana.tango.macroserver.test import TangoMacroExecutor
return TangoMacroExecutor(door_name=door_name)
-
-
+
+
if __name__ == '__main__':
from sardana import sardanacustomsettings
- door_name = getattr(sardanacustomsettings,'UNITTEST_DOOR_NAME')
+ door_name = getattr(sardanacustomsettings, 'UNITTEST_DOOR_NAME')
print MacroExecutorFactory().getMacroExecutor(door_name)
-
diff --git a/src/sardana/macroserver/macros/test/sardemoenv.py b/src/sardana/macroserver/macros/test/sardemoenv.py
index 408e71ae..de2cd23b 100755
--- a/src/sardana/macroserver/macros/test/sardemoenv.py
+++ b/src/sardana/macroserver/macros/test/sardemoenv.py
@@ -3,46 +3,49 @@
#############################################################################
##
## This file is part of Sardana, a Tango User Interface Library
-##
+##
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
#############################################################################
-from taurus import Device
+from taurus import Device
from sardana.taurus.core.tango.sardana import registerExtensions
from taurus.core.util.singleton import Singleton
from sardana import sardanacustomsettings
+
class SarDemoEnv(Singleton):
+
"""Class to get _SAR_DEMO environment variable with cross checking with
- the MacroServer (given by :attr:`UNITTEST_DOOR_NAME`)
+ the MacroServer (given by :attr:`UNITTEST_DOOR_NAME`)
"""
+
def __init__(self, door_name=None):
if door_name is None:
- door_name = getattr(sardanacustomsettings,'UNITTEST_DOOR_NAME')
+ door_name = getattr(sardanacustomsettings, 'UNITTEST_DOOR_NAME')
registerExtensions()
try:
self.door = Device(door_name)
self.ms = self.door.macro_server
except ValueError:
- raise ValueError('The door %s does not exist' %(door_name))
+ raise ValueError('The door %s does not exist' % (door_name))
- self.controllers = None
+ self.controllers = None
self.cts = None
self.motors = None
self.pseudos = None
@@ -52,17 +55,17 @@ class SarDemoEnv(Singleton):
try:
self.env = self.ms.getEnvironment()['_SAR_DEMO']['elements'] + \
- list(self.ms.getEnvironment()['_SAR_DEMO']['controllers'])
+ list(self.ms.getEnvironment()['_SAR_DEMO']['controllers'])
except KeyError:
err = 'sar_demo has not been executed (or door %s not ready)' % \
door_name
- raise RuntimeError(err)
+ raise RuntimeError(err)
def getElements(self, elem_type='all'):
- """Return the name of sardemo element(s) of given elem type
-
+ """Return the name of sardemo element(s) of given elem type
+
:param elem_type: (str) type of elemnts to return (all by default)
-
+
:return: (list<str>)
"""
if elem_type.lower() == 'all':
@@ -70,86 +73,86 @@ class SarDemoEnv(Singleton):
if elem_type.lower() == 'moveable':
return self.getElements('motor') + self.getElements('pseudomotor')
ms_elems = self.ms.getElementNamesOfType(elem_type)
- elems = [e for e in ms_elems if e is not None and e in self.env ]
+ elems = [e for e in ms_elems if e is not None and e in self.env]
return elems
def getMoveables(self):
- """Return the name of moveable(s) defined by SarDemo
-
+ """Return the name of moveable(s) defined by SarDemo
+
:return: (list<str>)
"""
return self.getMotors() + self.getPseudoMotors()
-
+
def getControllers(self):
- """Return the name of controllers(s) defined by SarDemo
-
+ """Return the name of controllers(s) defined by SarDemo
+
:return: (list<str>)
"""
if not self.controllers:
- self.controllers = self.getElements('controller')
+ self.controllers = self.getElements('controller')
return self.controllers
-
+
def getCTs(self):
- """Return the name of counter timer exp channel(s) defined by SarDemo
-
+ """Return the name of counter timer exp channel(s) defined by SarDemo
+
:return: (list<str>)
"""
if not self.cts:
- self.cts = self.getElements('ctexpchannel')
+ self.cts = self.getElements('ctexpchannel')
return self.cts
def getMotors(self):
- """Return the name of motor(s) defined by SarDemo
-
+ """Return the name of motor(s) defined by SarDemo
+
:return: (list<str>)
"""
if not self.motors:
- self.motors = self.getElements('motor')
+ self.motors = self.getElements('motor')
return self.motors
def getPseudoMotors(self):
- """Return the name of pseudomotor(s) defined by SarDemo
-
+ """Return the name of pseudomotor(s) defined by SarDemo
+
:return: (list<str>)
"""
if not self.pseudos:
- self.pseudos = self.getElements('pseudomotor')
+ self.pseudos = self.getElements('pseudomotor')
return self.pseudos
def getZerods(self):
- """Return the name of zerod exp channel(s) defined by SarDemo
-
+ """Return the name of zerod exp channel(s) defined by SarDemo
+
:return: (list<str>)
"""
if not self.zerods:
- self.zerods = self.getElements('zerodexpchannel')
+ self.zerods = self.getElements('zerodexpchannel')
return self.zerods
def getOneds(self):
- """Return the name of one exp channel(s) defined by SarDemo
-
+ """Return the name of one exp channel(s) defined by SarDemo
+
:return: (list<str>)
"""
if not self.oneds:
- self.oneds = self.getElements('onedexpchannel')
+ self.oneds = self.getElements('onedexpchannel')
return self.oneds
def getTwods(self):
- """Return the name of two exp channel(s) defined by SarDemo
-
+ """Return the name of two exp channel(s) defined by SarDemo
+
:return: (list<str>)
"""
if not self.twods:
- self.twods = self.getElements('twodexpchannel')
+ self.twods = self.getElements('twodexpchannel')
return self.twods
-
+
def changeDoor(self, door_name):
- """Change the door name and reset all lists
+ """Change the door name and reset all lists
"""
self.__init__(door_name)
-if __name__ == '__main__':
+if __name__ == '__main__':
s = SarDemoEnv()
print s.env
print s.getControllers()
diff --git a/src/sardana/macroserver/macros/test/test_ct.py b/src/sardana/macroserver/macros/test/test_ct.py
index 8a6379f6..094e5f07 100644
--- a/src/sardana/macroserver/macros/test/test_ct.py
+++ b/src/sardana/macroserver/macros/test/test_ct.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -35,14 +35,12 @@ from sardana.macroserver.macros.test import testStop
@testRun(macro_params=['.3'], wait_timeout=.5)
@testStop(macro_params=['1'], stop_delay=.1, wait_timeout=2)
class CtRunStopTest(RunStopMacroTestCase, unittest.TestCase):
+
"""Test of ct macro. It verifies that macro ct can be executed.
It inherits from RunStopMacroTestCase and from unittest.TestCase.
- It tests two executions of the ct macro with two different input
+ It tests two executions of the ct macro with two different input
parameters.
- Then it does another execution and it tests if the execution can be
- aborted.
+ Then it does another execution and it tests if the execution can be
+ aborted.
"""
macro_name = "ct"
-
-
-
diff --git a/src/sardana/macroserver/macros/test/test_list.py b/src/sardana/macroserver/macros/test/test_list.py
index d9c4d74c..509b55b1 100755
--- a/src/sardana/macroserver/macros/test/test_list.py
+++ b/src/sardana/macroserver/macros/test/test_list.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -32,17 +32,18 @@ from sardana.macroserver.macros.test import (RunMacroTestCase, testRun,
class LsTest(RunMacroTestCase):
+
"""Base class for testing macros used to list elements.
- See :class:`.RunMacroTestCase` for requirements.
- LsTest use the lists of elem_type generated by :class:`.SarDemoEnv` as
+ See :class:`.RunMacroTestCase` for requirements.
+ LsTest use the lists of elem_type generated by :class:`.SarDemoEnv` as
reference for compare with the output of the tested ls macro.
LsTest provide the class member:
- - elem_type (str): Type of the element to validate (mandatory).
- Must be a valid type for :class:`.SarDemoEnv` class.
+ - elem_type (str): Type of the element to validate (mandatory).
+ Must be a valid type for :class:`.SarDemoEnv` class.
It provides the helper method:
- - :meth:`check_elements`
+ - :meth:`check_elements`
"""
elem_type = None
@@ -58,9 +59,9 @@ class LsTest(RunMacroTestCase):
def macro_runs(self, **kwargs):
""" Reimplementation of macro_runs method for ls macros.
- It verifies that elements (elem_type) gotten by parsing the
- macro executor log output are in the correspondent
- list (elem_type) of SardanaEnv.
+ It verifies that elements (elem_type) gotten by parsing the
+ macro executor log output are in the correspondent
+ list (elem_type) of SardanaEnv.
"""
RunMacroTestCase.macro_runs(self, **kwargs)
self.log_output = self.macro_executor.getLog("output")
@@ -70,8 +71,8 @@ class LsTest(RunMacroTestCase):
if (self.elem_type is not None):
list_sardemo = SarDemoEnv().getElements(self.elem_type)
else:
- raise Exception("element_type cannot be None")
-
+ raise Exception("element_type cannot be None")
+
#parsing log output to get all elements
header_rows = 2
names_column_index = 0
@@ -82,14 +83,15 @@ class LsTest(RunMacroTestCase):
if len(macro_output) >= len(list_sardemo):
self.check_elements(list_sardemo, macro_output)
else:
- self.check_elements(macro_output, list_sardemo)
+ self.check_elements(macro_output, list_sardemo)
@testRun(macro_params=['l.*'])
@testRun
class LsmTest(LsTest, unittest.TestCase):
+
"""Class used for testing the 'lsm' macro.
- It verifies that all motors created by sar_demo are listed after
+ It verifies that all motors created by sar_demo are listed after
execution of the macro 'lsm'.
"""
macro_name = "lsm"
@@ -98,8 +100,9 @@ class LsmTest(LsTest, unittest.TestCase):
@testRun
class LspmTest(LsTest, unittest.TestCase):
+
"""Class used for testing the 'lspm' macro.
- It verifies that all pseudomotors created by sar_demo are listed after
+ It verifies that all pseudomotors created by sar_demo are listed after
execution of the macro 'lspm'.
"""
macro_name = "lspm"
@@ -108,8 +111,9 @@ class LspmTest(LsTest, unittest.TestCase):
@testRun
class LsctrlTest(LsTest, unittest.TestCase):
+
"""Class used for testing the 'lsctrl' macro.
- It verifies that all controllers created by sar_demo are listed after
+ It verifies that all controllers created by sar_demo are listed after
execution of the macro 'lsctrl'.
"""
macro_name = "lsctrl"
@@ -118,8 +122,9 @@ class LsctrlTest(LsTest, unittest.TestCase):
@testRun
class LsctTest(LsTest, unittest.TestCase):
+
"""Class used for testing the 'lsct' macro.
- It verifies that all ct created by sar_demo are listed after
+ It verifies that all ct created by sar_demo are listed after
execution of the macro 'lsct'.
"""
macro_name = "lsct"
@@ -128,8 +133,9 @@ class LsctTest(LsTest, unittest.TestCase):
@testRun
class Ls0dTest(LsTest, unittest.TestCase):
+
"""Class used for testing the 'ls0d' macro.
- It verifies that all 0d created by sar_demo are listed after
+ It verifies that all 0d created by sar_demo are listed after
execution of the macro 'ls0d'.
"""
macro_name = "ls0d"
@@ -138,8 +144,9 @@ class Ls0dTest(LsTest, unittest.TestCase):
@testRun
class Ls1dTest(LsTest, unittest.TestCase):
+
"""Class used for testing the 'ls1d' macro.
- It verifies that all 1d created by sar_demo are listed after
+ It verifies that all 1d created by sar_demo are listed after
execution of the macro 'ls1d'.
"""
macro_name = "ls1d"
@@ -148,12 +155,10 @@ class Ls1dTest(LsTest, unittest.TestCase):
@testRun
class Ls2dTest(LsTest, unittest.TestCase):
+
"""Class used for testing the 'ls2d' macro.
- It verifies that all 2d created by sar_demo are listed after
+ It verifies that all 2d created by sar_demo are listed after
execution of the macro 'ls2d'.
"""
macro_name = "ls2d"
elem_type = "twodexpchannel"
-
-
-
diff --git a/src/sardana/macroserver/macros/test/test_scan.py b/src/sardana/macroserver/macros/test/test_scan.py
index c42ba282..c230df69 100755
--- a/src/sardana/macroserver/macros/test/test_scan.py
+++ b/src/sardana/macroserver/macros/test/test_scan.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -26,21 +26,22 @@
"""Tests for scan macros"""
import unittest
-from sardana.macroserver.macros.test import (RunStopMacroTestCase,
+from sardana.macroserver.macros.test import (RunStopMacroTestCase,
testRun, testStop, SarDemoEnv)
#get handy motor names from sardemo
-try:
+try:
_MOTORS = SarDemoEnv().getMotors()
- _m1,_m2 = _MOTORS[:2]
+ _m1, _m2 = _MOTORS[:2]
except RuntimeError:
import taurus
from sardana import sardanacustomsettings
- door_name = getattr(sardanacustomsettings,'UNITTEST_DOOR_NAME')
- taurus.warning("The door %s is not running ." % (door_name) +\
+ door_name = getattr(sardanacustomsettings, 'UNITTEST_DOOR_NAME')
+ taurus.warning("The door %s is not running ." % (door_name) +
"Ignore this message if you are building the documentation")
_m1 = _m2 = 'motor_not_defined'
+
def parsing_log_output(log_output):
"""A helper method to parse log output of an executed scan macro.
:params log_output: (seq<str>) Result of macro_executor.getLog('output')
@@ -53,16 +54,17 @@ def parsing_log_output(log_output):
data = []
for line, in log_output[first_data_line:]:
# Get a list of elements without white spaces between them
- l = line.split()
+ l = line.split()
# Cast all elements of the scan line (l) to float
l = [float(scan_elem) for scan_elem in l]
# Cast index of scan to int (the first element of the list)
- l[scan_index]= int(l[scan_index])
+ l[scan_index] = int(l[scan_index])
data.append(l)
- return data
+ return data
class ANscanTest(RunStopMacroTestCase):
+
"""Not yet implemented. Once implemented it will test anscan.
See :class:`.RunStopMacroTestCase` for requirements.
"""
@@ -70,6 +72,7 @@ class ANscanTest(RunStopMacroTestCase):
class DNscanTest(ANscanTest):
+
"""Not yet implemented. Once implemented it will test the macro dnscanc.
See :class:`ANscanTest` for requirements.
"""
@@ -77,6 +80,7 @@ class DNscanTest(ANscanTest):
class DNscancTest(DNscanTest):
+
"""Not yet implemented. Once implemented it will test the macro dnscanc.
See :class:`DNscanTest` for requirements.
"""
@@ -86,25 +90,26 @@ class DNscancTest(DNscanTest):
@testRun(macro_params=[_m1, '0', '5', '4', '.1'], wait_timeout=float("inf"))
@testStop(macro_params=[_m1, '0', '5', '3', '.1'])
class AscanTest(ANscanTest, unittest.TestCase):
- """Test of ascan macro. See :class:`ANscanTest` for requirements.
- It verifies that macro ascan can be executed and stoped and tests
- the output of the ascan using data from log system and macro data.
+
+ """Test of ascan macro. See :class:`ANscanTest` for requirements.
+ It verifies that macro ascan can be executed and stoped and tests
+ the output of the ascan using data from log system and macro data.
"""
macro_name = 'ascan'
def macro_runs(self, macro_params=None, wait_timeout=float("inf")):
- """Reimplementation of macro_runs method for ascan macro.
- It verifies using double checking, with log output and data from
+ """Reimplementation of macro_runs method for ascan macro.
+ It verifies using double checking, with log output and data from
the macro:
- - The motor initial and final positions of the scan are the
- ones given as input.
+ - The motor initial and final positions of the scan are the
+ ones given as input.
- - Intervals in terms of motor position between one point and
+ - Intervals in terms of motor position between one point and
the next one are equidistant.
"""
#call the parent class implementation
- ANscanTest.macro_runs(self, macro_params=macro_params,
+ ANscanTest.macro_runs(self, macro_params=macro_params,
wait_timeout=wait_timeout)
mot_name = macro_params[0]
@@ -119,18 +124,18 @@ class AscanTest(ANscanTest, unittest.TestCase):
mot_final_pos = data[max(data.keys())].data[mot_name]
pre = mot_init_pos
- for step in range(1, max(data.keys())+1):
- self.assertAlmostEqual(abs(pre - data[step].data[mot_name]),
- interval, 7,
- "Step interval differs for more than expected (using getData)")
+ for step in range(1, max(data.keys()) + 1):
+ self.assertAlmostEqual(abs(pre - data[step].data[mot_name]),
+ interval, 7,
+ "Step interval differs for more than expected (using getData)")
pre = data[step].data[mot_name]
self.assertAlmostEqual(mot_init_pos, expected_init_pos, 7,
- "Initial possition differs from set value (using getData)")
+ "Initial possition differs from set value (using getData)")
self.assertAlmostEqual(mot_final_pos, expected_final_pos, 7,
- "Final possition differs from set value (using getData)")
+ "Final possition differs from set value (using getData)")
- # Test data from log_output (macro_executor.getLog('output'))
+ # Test data from log_output (macro_executor.getLog('output'))
log_output = self.macro_executor.getLog('output')
data = parsing_log_output(log_output)
init_pos = 0
@@ -138,20 +143,22 @@ class AscanTest(ANscanTest, unittest.TestCase):
value = 1
pre = data[init_pos]
for step in data[1:]:
- self.assertAlmostEqual(abs(pre[value] - step[value]),
- interval, 7,
- "Step interval differs for more than expected (using getData)")
+ self.assertAlmostEqual(abs(pre[value] - step[value]),
+ interval, 7,
+ "Step interval differs for more than expected (using getData)")
pre = step
self.assertAlmostEqual(data[init_pos][value], expected_init_pos, 7,
- "Initial possition differs from set value (using getLog)")
+ "Initial possition differs from set value (using getLog)")
self.assertAlmostEqual(data[last_pos][value], expected_final_pos, 7,
- "Final possition differs from set value (using getLog)")
+ "Final possition differs from set value (using getLog)")
+
@testRun(macro_params=[_m1, '-1', '1', '2', '.1'])
@testStop(macro_params=[_m1, '1', '-1', '3', '.1'])
class DscanTest(DNscanTest, unittest.TestCase):
- """Test of dscan macro. It verifies that macro dscan can be executed and
+
+ """Test of dscan macro. It verifies that macro dscan can be executed and
stoped. See :class:`DNscanTest` for requirements.
"""
macro_name = 'dscan'
@@ -161,10 +168,8 @@ class DscanTest(DNscanTest, unittest.TestCase):
@testRun(macro_params=[_m1, '-2', '2', '3', _m2, '-2', '-1', '2', '.1'])
@testStop(macro_params=[_m1, '-3', '0', '3', _m2, '-3', '0', '2', '.1'])
class MeshTest(RunStopMacroTestCase, unittest.TestCase):
- """Test of mesh macro. It verifies that macro mesh can be executed and
+
+ """Test of mesh macro. It verifies that macro mesh can be executed and
stoped. See :class:`.RunStopMacroTestCase` for requirements.
"""
macro_name = 'mesh'
-
-
-
diff --git a/src/sardana/macroserver/macros/test/test_wm.py b/src/sardana/macroserver/macros/test/test_wm.py
index 252a9ac1..ba09379d 100644
--- a/src/sardana/macroserver/macros/test/test_wm.py
+++ b/src/sardana/macroserver/macros/test/test_wm.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -29,21 +29,23 @@ import unittest
from sardana.macroserver.macros.test import (RunMacroTestCase, testRun,
SarDemoEnv)
-try:
+try:
_MOTORS = SarDemoEnv().getMotors()
- _m1,_m2 = _MOTORS[:2]
+ _m1, _m2 = _MOTORS[:2]
except RuntimeError:
import taurus
from sardana import sardanacustomsettings
- door_name = getattr(sardanacustomsettings,'UNITTEST_DOOR_NAME')
- taurus.warning("The door %s is not running ." % (door_name) +\
+ door_name = getattr(sardanacustomsettings, 'UNITTEST_DOOR_NAME')
+ taurus.warning("The door %s is not running ." % (door_name) +
"Ignore this message if you are building the documentation")
_m1 = _m2 = 'motor_not_defined'
+
class WBase(RunMacroTestCase):
+
"""Base class for testing macros used to read position.
"""
-
+
def macro_runs(self, **kw):
"""Testing the execution of the 'wm' macro and verify that the log
'output' exists.
@@ -54,11 +56,12 @@ class WBase(RunMacroTestCase):
self.assertTrue(len(self.logOutput) > 0, msg)
-@testRun(macro_params = [_m1], wait_timeout=5.0)
+@testRun(macro_params=[_m1], wait_timeout=5.0)
class WmTest(WBase, unittest.TestCase):
+
"""Test of wm macro. It verifies that the macro 'wm' can be executed.
It inherits from WmBase and from unittest.TestCase.
It tests the execution of the 'wm' macro and verifies that the log 'output'
- exists.
+ exists.
"""
macro_name = "wm"
diff --git a/src/sardana/spock/test/__init__.py b/src/sardana/spock/test/__init__.py
index 65e48edc..05c105ab 100755
--- a/src/sardana/spock/test/__init__.py
+++ b/src/sardana/spock/test/__init__.py
@@ -3,22 +3,22 @@
##############################################################################
##
## This file is part of Sardana
-##
+##
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
-##############################################################################
+##############################################################################
diff --git a/src/sardana/spock/test/test_parameter.py b/src/sardana/spock/test/test_parameter.py
index b3d4c0ef..2817f5d8 100644
--- a/src/sardana/spock/test/test_parameter.py
+++ b/src/sardana/spock/test/test_parameter.py
@@ -3,21 +3,21 @@
##############################################################################
##
## This file is part of Sardana
-##
+##
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -30,41 +30,40 @@ from sardana.spock import parameter
class ParamTestCase(unittest.TestCase):
+
"""
- Instantiate in different ways a Param object and verify that
+ Instantiate in different ways a Param object and verify that
they are correct instances from the class Param.
"""
def testInstanceCreation(self):
"""
- Instantiate in different ways a Param object.
+ Instantiate in different ways a Param object.
"""
spock_param = parameter.Param()
- self.assertIsInstance(spock_param, parameter.Param,
- 'Instantiation of an object Param without arguments ' +
- 'does not work \n')
+ self.assertIsInstance(spock_param, parameter.Param,
+ 'Instantiation of an object Param without arguments ' +
+ 'does not work \n')
spock_param = parameter.Param(name='sardanaName')
- self.assertIsInstance(spock_param, parameter.Param,
- 'Instantiation of an object Param with argument name ' +
- 'does not work')
-
- spock_param = parameter.Param(name='sardanaName',
- desc='description_is_present')
- self.assertIsInstance(spock_param, parameter.Param,
- 'Instantiation of an object Param with arguments name ' +
- 'and description does not work')
-
- spock_param = parameter.Param(name='sardanaName',
- desc='description_is_present', type_name='integer')
- self.assertIsInstance(spock_param, parameter.Param,
- 'Instantiation of an object Param with arguments name, ' +
- 'description and type_name does not work')
+ self.assertIsInstance(spock_param, parameter.Param,
+ 'Instantiation of an object Param with argument name ' +
+ 'does not work')
- spock_param = parameter.Param(name='sardanaName',
- desc='description_is_present', type_name='integer', defvalue=7)
- self.assertIsInstance(spock_param, parameter.Param,
- 'Instantiation of an object Param with arguments name, ' +
- 'description, type_name and defvalue does not work')
+ spock_param = parameter.Param(name='sardanaName',
+ desc='description_is_present')
+ self.assertIsInstance(spock_param, parameter.Param,
+ 'Instantiation of an object Param with arguments name ' +
+ 'and description does not work')
+ spock_param = parameter.Param(name='sardanaName',
+ desc='description_is_present', type_name='integer')
+ self.assertIsInstance(spock_param, parameter.Param,
+ 'Instantiation of an object Param with arguments name, ' +
+ 'description and type_name does not work')
+ spock_param = parameter.Param(name='sardanaName',
+ desc='description_is_present', type_name='integer', defvalue=7)
+ self.assertIsInstance(spock_param, parameter.Param,
+ 'Instantiation of an object Param with arguments name, ' +
+ 'description, type_name and defvalue does not work')
diff --git a/src/sardana/tango/macroserver/test/__init__.py b/src/sardana/tango/macroserver/test/__init__.py
index af5d4b16..427be599 100644
--- a/src/sardana/tango/macroserver/test/__init__.py
+++ b/src/sardana/tango/macroserver/test/__init__.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
diff --git a/src/sardana/tango/macroserver/test/macroexecutor.py b/src/sardana/tango/macroserver/test/macroexecutor.py
index 2999a60b..71fd2e3c 100755
--- a/src/sardana/tango/macroserver/test/macroexecutor.py
+++ b/src/sardana/tango/macroserver/test/macroexecutor.py
@@ -7,17 +7,17 @@
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -32,15 +32,17 @@ from sardana import sardanacustomsettings
class TangoAttrCb(object):
+
'''An abstract callback class for Tango events'''
-
+
def __init__(self, tango_macro_executor):
self._tango_macro_executor = tango_macro_executor
-
+
class TangoResultCb(TangoAttrCb):
+
'''Callback class for Tango events of the Result attribute'''
-
+
def push_event(self, *args, **kwargs):
'''callback method receiving the event'''
event_data = args[0]
@@ -52,7 +54,8 @@ class TangoResultCb(TangoAttrCb):
class TangoLogCb(TangoAttrCb):
- '''Callback class for Tango events of the log attributes
+
+ '''Callback class for Tango events of the log attributes
e.g. Output, Error, Critical
'''
@@ -66,7 +69,7 @@ class TangoLogCb(TangoAttrCb):
if event_data.attr_value:
log = event_data.attr_value.value
log_buffer_name = '_%s' % self._log_name
- log_buffer = getattr(self._tango_macro_executor, log_buffer_name)
+ log_buffer = getattr(self._tango_macro_executor, log_buffer_name)
log_buffer.append(log)
common_buffer = self._tango_macro_executor._common
if common_buffer != None:
@@ -74,8 +77,9 @@ class TangoLogCb(TangoAttrCb):
class TangoStatusCb(TangoAttrCb):
+
'''Callback class for Tango events of the MacroStatus attribute'''
-
+
START_STATES = ['start']
DONE_STATES = ['finish', 'stop', 'exception']
@@ -100,12 +104,14 @@ class TangoStatusCb(TangoAttrCb):
fmt, data = codec.decode(v)
for macro_status in data:
state = macro_status['state']
- self._tango_macro_executor._exception = macro_status.get('exc_type')
+ self._tango_macro_executor._exception = macro_status.get(
+ 'exc_type')
if state in self.START_STATES:
#print 'TangoStatusCb.push_event: setting _started_event'
self._tango_macro_executor._started_event.set()
elif state in self.DONE_STATES:
- #print 'TangoStatusCb.push_event: setting _done_event %s' %(state)
+ # print 'TangoStatusCb.push_event: setting _done_event %s'
+ # %(state)
self._tango_macro_executor._done_event.set()
#else:
# print 'State %s' %(state)
@@ -113,6 +119,7 @@ class TangoStatusCb(TangoAttrCb):
class TangoMacroExecutor(BaseMacroExecutor):
+
'''
Macro executor implemented using Tango communication with the Door device
'''
@@ -120,36 +127,36 @@ class TangoMacroExecutor(BaseMacroExecutor):
def __init__(self, door_name=None):
super(TangoMacroExecutor, self).__init__()
if door_name == None:
- door_name = getattr(sardanacustomsettings,'UNITTEST_DOOR_NAME')
+ door_name = getattr(sardanacustomsettings, 'UNITTEST_DOOR_NAME')
self._door = PyTango.DeviceProxy(door_name)
self._done_event = None
self._started_event = None
-
+
def _clean(self):
- '''Recreates threading Events in case the macro executor is reused.'''
+ '''Recreates threading Events in case the macro executor is reused.'''
super(TangoMacroExecutor, self)._clean()
- self._started_event = threading.Event()
+ self._started_event = threading.Event()
self._done_event = threading.Event()
-
+
def _run(self, macro_name, macro_params):
'''reimplemented from :class:`BaseMacroExecutor`'''
- # preaparing RunMacro command input arguments
+ # preaparing RunMacro command input arguments
argin = copy.copy(macro_params)
argin.insert(0, macro_name)
# registering for MacroStatus events
status_cb = TangoStatusCb(self)
self._status_id = self._door.subscribe_event('macrostatus',
- PyTango.EventType.CHANGE_EVENT,
- status_cb)
+ PyTango.EventType.CHANGE_EVENT,
+ status_cb)
# executing RunMacro command
self._door.RunMacro(argin)
def _wait(self, timeout):
'''reimplemented from :class:`BaseMacroExecutor`'''
- #TODO: In case of timeout = inf if the macro excecutor run a macro
+ #TODO: In case of timeout = inf if the macro excecutor run a macro
# with wrong parameters it'll never awake of the done_event wait
# Pending to remove this comment when Sardana resolves the bug.
- if self._done_event:
+ if self._done_event:
self._done_event.wait(timeout)
self._door.unsubscribe_event(self._status_id)
@@ -158,40 +165,39 @@ class TangoMacroExecutor(BaseMacroExecutor):
self._started_event.wait(started_event_timeout)
try:
self._door.StopMacro()
- except PyTango.DevFailed, e:
- raise Exception("Unable to Stop macro: %s"% e)
-
+ except PyTango.DevFailed as e:
+ raise Exception("Unable to Stop macro: %s" % e)
+
def _registerLog(self, log_level):
'''reimplemented from :class:`BaseMacroExecutor`'''
log_cb = TangoLogCb(self, log_level)
id_log_name = '_%s_id' % log_level
- id_log = self._door.subscribe_event(log_level,
- PyTango.EventType.CHANGE_EVENT,
- log_cb)
+ id_log = self._door.subscribe_event(log_level,
+ PyTango.EventType.CHANGE_EVENT,
+ log_cb)
setattr(self, id_log_name, id_log)
-
+
def _unregisterLog(self, log_level):
'''reimplemented from :class:`BaseMacroExecutor`'''
id_log_name = '_%s_id' % log_level
id_log = getattr(self, id_log_name)
self._door.unsubscribe_event(id_log)
-
+
def _registerResult(self):
'''reimplemented from :class:`BaseMacroExecutor`'''
result_cb = TangoResultCb(self)
self._result_id = self._door.subscribe_event('result',
- PyTango.EventType.CHANGE_EVENT,
- result_cb)
-
+ PyTango.EventType.CHANGE_EVENT,
+ result_cb)
+
def _unregisterResult(self):
'''reimplemented from :class:`BaseMacroExecutor`'''
self._door.unsubscribe_event(self._result_id)
def getData(self):
'''Returns the data object for the last executed macro
-
+
:return: (obj)
'''
data = self._door.RecordData
return CodecFactory().decode(data)
-
diff --git a/src/sardana/test/__init__.py b/src/sardana/test/__init__.py
index 13032ff8..f7a54e8e 100644
--- a/src/sardana/test/__init__.py
+++ b/src/sardana/test/__init__.py
@@ -3,51 +3,51 @@
##############################################################################
##
## This file is part of Sardana
-##
+##
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
-##############################################################################
+##############################################################################
"""
-Sardana includes a framework allowing to test its features.
-This framework is aimed to be used with the objective of finding bugs and
+Sardana includes a framework allowing to test its features.
+This framework is aimed to be used with the objective of finding bugs and
promote test driven development. \n
-This Framework is the outcome of the Sardana Enhancement Proposal 5 (SEP5). Its
-documentation is located here:
+This Framework is the outcome of the Sardana Enhancement Proposal 5 (SEP5). Its
+documentation is located here:
http://sourceforge.net/p/sardana/wiki/SEP5/ \n
Ideally, each bug found should be accompanied by a test revealing the bug.
That eases the process of correcting bugs. \n
-The objective of the Sardana Test Framework is not to provide a test for
+The objective of the Sardana Test Framework is not to provide a test for
every piece of code, but rather to ease collaborations and allow people
from other institutions to provide their own test classes. \n
-At the moment the Sardana testing is focused on Unit Tests, but in the future
+At the moment the Sardana testing is focused on Unit Tests, but in the future
the objective is to extend it to integration and system tests as well. \n
-In order to run all the tests provided by Sardana test framework, at a given
+In order to run all the tests provided by Sardana test framework, at a given
moment, just go to 'sardana/src/sardana/test' and execute: \n
python testsuite.py
-Sardana Test Framework is based on 'unittest'. This means that each of the
+Sardana Test Framework is based on 'unittest'. This means that each of the
Sardana python test classes inherits from unittest.TestCase. \n
Each of the Sardana Tests has to be acompanied by a documentation that is
@@ -56,14 +56,14 @@ methods. \n
All tests have to be written in folders named 'test/'. \n
-Sardana Test Framework provides tools for testing macros. These tools comes
+Sardana Test Framework provides tools for testing macros. These tools comes
from: \n
* sardana/src/sardana/macroserver/macros/test/base.py
* sardana/src/sardana/macroserver/macros/test/macroexecutor.py
* sardana/src/sardana/macroserver/macros/test/sardemoenv.py
* sardana/src/sardana/tango/macroserver/test/macroexecutor.py
-Tests of macros are done using the motors and experimental channels created
+Tests of macros are done using the motors and experimental channels created
by Sardana demo. \n
base.py provides the mean of executing macros and test the function Run and
@@ -74,27 +74,25 @@ Macros as 'lsm' inherits from RunMacroTestCase as it is interesting to test
if the macros can be executed. The test methods can override the function
macro_runs() that is defined in the class RunMacroTestCase. \n
-However, scan macros inherits from RunStopMacroTestCase as it is interesting
+However, scan macros inherits from RunStopMacroTestCase as it is interesting
to test both: if the macros can be executed and if they can be aborted. \n
-Another capacity provided by the Framework is the option to execute the
-same test method with many different macro input parameters. These is done
+Another capacity provided by the Framework is the option to execute the
+same test method with many different macro input parameters. These is done
by the help of a decorator inserted at the beginning of the test function.
-One decorator has to be used for each set of macro input parameters. Examples
+One decorator has to be used for each set of macro input parameters. Examples
of the decorator usage can be seen in: test_scan.py \n
-If new tests of scan macros or list macros have to be added, that can be
-done in test_scan.py or in test_list.py where a useful base class is
+If new tests of scan macros or list macros have to be added, that can be
+done in test_scan.py or in test_list.py where a useful base class is
provided. \n
Examples of Sardana tests using tools of Sardana Test Framework are: \n
-* sardana/src/sardana/test/test_sardanavalue.py
+* sardana/src/sardana/test/test_sardanavalue.py
* sardana/src/sardana/test/test_parameter.py
* sardana/src/sardana/macroserver/macros/test_ct.py
* sardana/src/sardana/macroserver/macros/test_list.py
* sardana/src/sardana/macroserver/macros/test_wm.py
"""
-
-
diff --git a/src/sardana/test/test_sardanavalue.py b/src/sardana/test/test_sardanavalue.py
index 9d95609b..9c05df8a 100644
--- a/src/sardana/test/test_sardanavalue.py
+++ b/src/sardana/test/test_sardanavalue.py
@@ -3,21 +3,21 @@
##############################################################################
##
## This file is part of Sardana
-##
+##
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -30,65 +30,62 @@ from sardana.sardanavalue import SardanaValue
class SardanaValueTestCase(unittest.TestCase):
- """Instantiating in different ways a Sardana Value and perform some
+
+ """Instantiating in different ways a Sardana Value and perform some
verifications.
"""
def testInstanceCreation(self):
"""
Instantiate in different ways a SardanaValue object.
- """
+ """
sar_val = SardanaValue()
- self.assertIsInstance(sar_val, SardanaValue, 'Instantiation of an ' +
- 'object SardanaValue without arguments does not work')
-
+ self.assertIsInstance(sar_val, SardanaValue, 'Instantiation of an ' +
+ 'object SardanaValue without arguments does not work')
+
sar_val1 = SardanaValue(value=9)
self.assertIsInstance(sar_val1, SardanaValue, 'Instantiation of an ' +
- 'object SardanaValue with the value argument does not work')
+ 'object SardanaValue with the value argument does not work')
- sar_val2 = SardanaValue(value=8, exc_info=None,
- timestamp='09:30', dtype='int', dformat='int')
+ sar_val2 = SardanaValue(value=8, exc_info=None,
+ timestamp='09:30', dtype='int', dformat='int')
- self.assertIsInstance(sar_val2, SardanaValue, 'Instantiation of an ' +
- 'object SardanaValue with arguments and exc_info equal None, ' +
- 'does not work.')
+ self.assertIsInstance(sar_val2, SardanaValue, 'Instantiation of an ' +
+ 'object SardanaValue with arguments and exc_info equal None, ' +
+ 'does not work.')
- sar_val3 = SardanaValue(value = 7, exc_info = 'exception_info',
- timestamp = '09:30', dtype = 'int', dformat = 'int')
+ sar_val3 = SardanaValue(value=7, exc_info='exception_info',
+ timestamp='09:30', dtype='int', dformat='int')
- self.assertIsInstance(sar_val3, SardanaValue, 'Instantiation of an ' +
- 'object SardanaValue with arguments and exc_info ' +
- 'different of None, does not work.')
+ self.assertIsInstance(sar_val3, SardanaValue, 'Instantiation of an ' +
+ 'object SardanaValue with arguments and exc_info ' +
+ 'different of None, does not work.')
def testSardanaValueWithExceptionInfo(self):
"""Verify the creation of SardanaValue when exc_info != None.
- Verify that 'Error' is contained in the returned string.
+ Verify that 'Error' is contained in the returned string.
"""
val = 4
sar_val = SardanaValue(value=val, exc_info='exception_info')
- representation = repr(sar_val)
+ representation = repr(sar_val)
- self.assertEqual(sar_val.error, True,
- 'The error attribute should be True.')
-
- self.assertRegexpMatches(representation, ".*<Error>.*",
- 'The SardanaValue representation does not contain <Error>.')
+ self.assertEqual(sar_val.error, True,
+ 'The error attribute should be True.')
+
+ self.assertRegexpMatches(representation, ".*<Error>.*",
+ 'The SardanaValue representation does not contain <Error>.')
def testSardanaValueWithNoExceptionInfo(self):
"""Verify the creation of SardanaValue when exc_info is not specified
- and we give a value as argument of the SardanaValue constructor.
- SardanaValue representation shall contain its value.
- """
+ and we give a value as argument of the SardanaValue constructor.
+ SardanaValue representation shall contain its value.
+ """
value = 5
sar_val = SardanaValue(value=value)
returned_string = sar_val.__repr__()
- self.assertRegexpMatches(returned_string, repr(value),
- 'The SardanaValue representation does not contain its value')
-
- self.assertEqual(sar_val.error, False,
- 'The error attribute should be False')
-
-
-
+ self.assertRegexpMatches(returned_string, repr(value),
+ 'The SardanaValue representation does not contain its value')
+ self.assertEqual(sar_val.error, False,
+ 'The error attribute should be False')
diff --git a/src/sardana/test/testsuite.py b/src/sardana/test/testsuite.py
index e98dc385..a6371040 100644
--- a/src/sardana/test/testsuite.py
+++ b/src/sardana/test/testsuite.py
@@ -3,21 +3,21 @@
##############################################################################
##
## This file is part of Sardana
-##
+##
## http://www.tango-controls.org/static/sardana/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
-##
+##
## Sardana is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
-##
+##
## Sardana is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
-##
+##
## You should have received a copy of the GNU Lesser General Public License
## along with Sardana. If not, see <http://www.gnu.org/licenses/>.
##
@@ -26,10 +26,10 @@
"""
This module defines the test suite for the whole Sardana package
Usage::
-
+
from taurus.test import testsuite
testsuite.run()
-
+
"""
__docformat__ = 'restructuredtext'
@@ -51,4 +51,3 @@ def run(disableLogger=True):
if __name__ == '__main__':
run()
-