Skip to content

Commit

Permalink
Merge pull request #37 from gregoil/feature/fix_merge
Browse files Browse the repository at this point in the history
fixed merge by review and conventions
  • Loading branch information
osherdp committed Mar 9, 2018
2 parents 9020fc6 + 410ab80 commit 0b51124
Show file tree
Hide file tree
Showing 48 changed files with 202 additions and 198 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Why Use Rotest?
Examples
========
For a complete step-by-step explanation about the framework, you can read
our documentation at `ReadTheDocs <http://rotest.rtfd.io>`_. If you just want
our documentation at `Read The Docs <http://rotest.rtfd.io>`_. If you just want
to see how it looks, read further.

For our example, let's look at an example for a `Calculator` resource:
Expand Down
8 changes: 4 additions & 4 deletions docs/advanced/blocks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TestBlock

.. code-block:: python
DemoBlock(TestBlock):
class DemoBlock(TestBlock):
inputs = ('field_name', 'other_field')
...
Expand All @@ -69,7 +69,7 @@ TestBlock

.. code-block:: python
DemoBlock(TestBlock):
class DemoBlock(TestBlock):
outputs = ('field_name', 'other_field')
...
Expand Down Expand Up @@ -166,7 +166,7 @@ methods:

.. code-block:: python
DemoFlow(TestFlow):
class DemoFlow(TestFlow):
common = {'field_name': 5,
'other_field': 'abc'}
...
Expand All @@ -184,7 +184,7 @@ methods:

.. code-block:: python
DemoFlow(TestFlow):
class DemoFlow(TestFlow):
blocks = (DemoBlock,
DemoBlock.parametrize(field_name=5,
other_field='abc'))
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ basicstruct==1.0.3
colorama==0.3.9
configparser==3.5.0
constantly==15.1.0
coverage>=4.4.1
decorator==4.1.2
Django==1.7.11
docopt==0.6.2
docutils==0.14
enum34==1.1.6
flake8==3.4.1
flake8==3.5.0
funcsigs==1.0.2
functools32==3.2.3.post2
hyperlink==17.3.1
Expand All @@ -41,7 +40,7 @@ py==1.4.34
pycodestyle==2.3.1
pyflakes==1.5.0
Pygments==2.2.0
pylint==1.7.2
pylint==1.7.6
pytest==3.2.2
pytest-django==3.1.2
python-daemon==2.1.2
Expand Down
2 changes: 1 addition & 1 deletion src/rotest/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_work_dir(base_dir, test_name):
work_dir = basic_work_dir

copy_count = count()
while os.path.exists(work_dir) is True:
while os.path.exists(work_dir):
work_dir = basic_work_dir + '(%s)' % copy_count.next()

os.makedirs(work_dir)
Expand Down
4 changes: 2 additions & 2 deletions src/rotest/core/abstract_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, indexer=count(), methodName='runTest',
run_data=None, enable_debug=True, resource_manager=None,
skip_init=False):

if enable_debug is True:
if enable_debug:
for method_name in (methodName, self.SETUP_METHOD_NAME,
self.TEARDOWN_METHOD_NAME):

Expand Down Expand Up @@ -110,7 +110,7 @@ def expect(self, expression, msg=None):
Returns:
bool. True if the validation passed, False otherwise.
"""
if expression is False:
if not expression:
failure = AssertionError(msg)
self.result.addFailure(self, (failure.__class__, failure, None))
return False
Expand Down
2 changes: 1 addition & 1 deletion src/rotest/core/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _validate_inputs(self, extra_inputs=[]):
AttributeError: not all inputs were passed to the block.
"""
missing_inputs = [input_name for input_name in self.inputs
if (hasattr(self, input_name) is False and
if (not hasattr(self, input_name) and
input_name not in extra_inputs and
input_name not in self._pipes)]

Expand Down
6 changes: 3 additions & 3 deletions src/rotest/core/case.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def setup_method_wrapper(*args, **kwargs):
setup_method(*args, **kwargs)
self.result.setupFinished(self)

except:
except Exception:
self.release_resources(dirty=True)
raise

Expand All @@ -157,15 +157,15 @@ def teardown_method_wrapper(*args, **kwargs):
try:
teardown_method(*args, **kwargs)

except:
except Exception:
result.addError(self, sys.exc_info())

finally:
self.release_resources(
dirty=self.data.exception_type == TestOutcome.ERROR,
force_release=False)

if self._is_client_local is True:
if self._is_client_local:
self.resource_manager.disconnect()

return teardown_method_wrapper
Expand Down
14 changes: 7 additions & 7 deletions src/rotest/core/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(self, base_work_dir=ROTEST_WORK_DIR, save_state=True,

self.share_data(**self.__class__.common)

if self.is_main is True:
if self.is_main:
self._validate_inputs()

self.logger.debug("Initialized %r test-flow successfully", self.data)
Expand Down Expand Up @@ -208,20 +208,20 @@ def add_resources(self, resources, from_block=None):

def was_successful(self):
"""Return whether the result of the flow-run was success or not."""
return all((block.was_successful() is not False for block in
self)) and super(TestFlow, self).was_successful()
return (all(block.was_successful() for block in self) and
super(TestFlow, self).was_successful())

def had_error(self):
"""Return whether any of the blocks had an exception during its run."""
return any((block.had_error() for block in self)) or \
super(TestFlow, self).had_error()
return (any(block.had_error() for block in self) or
super(TestFlow, self).had_error())

def test_run_blocks(self):
"""Main test method, run the blocks under the test-flow."""
for test in self:
test(self.result)

if self.had_error() is True:
if self.had_error():
error_blocks_list = [block.data.name for block in self if
block.had_error()]
flow_result_str = 'The following components had errors:' \
Expand All @@ -231,7 +231,7 @@ def test_run_blocks(self):
self.result.addError(self, (failure.__class__, failure, None))
return

if self.was_successful() is False:
if not self.was_successful():
failed_blocks_list = [block.data.name for block in self if
not block.was_successful()]
flow_result_str = 'The following components have failed:' \
Expand Down
16 changes: 8 additions & 8 deletions src/rotest/core/flow_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def parametrize(cls, **parameters):

def share_data(self, **parameters):
"""Inject the parameters to the parent and sibling components."""
if self.IS_COMPLEX is False:
if not self.IS_COMPLEX:
self.parent._set_parameters(**parameters)

else:
Expand Down Expand Up @@ -209,7 +209,7 @@ def setup_method_wrapper(*args, **kwargs):
* Executes the original setUp method.
* Upon exception, finalizes the resources.
"""
if self.is_main is True:
if self.is_main:
skip_reason = self.result.shouldSkip(self)
if skip_reason is not None:
self.skip_sub_components(skip_reason)
Expand All @@ -233,22 +233,22 @@ def setup_method_wrapper(*args, **kwargs):
except Exception as err:
self.logger.exception("Got an error while getting resources")

if isinstance(err, ServerError) is True:
if isinstance(err, ServerError):
self.skip_sub_components(self.NO_RESOURCES_MESSAGE)
self.skipTest(self.NO_RESOURCES_MESSAGE)

else:
raise

try:
if self.is_main is False:
if not self.is_main:
# Validate all required inputs were passed
self._validate_inputs()

setup_method(*args, **kwargs)
self.result.setupFinished(self)

except:
except Exception:
self.release_resources(self.locked_resources, dirty=True)
raise

Expand All @@ -274,16 +274,16 @@ def teardown_method_wrapper(*args, **kwargs):
try:
teardown_method(*args, **kwargs)

except:
except Exception:
result.addError(self, sys.exc_info())

finally:
self.release_resources(
dirty=self.data.exception_type == TestOutcome.ERROR,
force_release=False)

if (self._is_client_local is True and
self.resource_manager.is_connected() is True):
if (self._is_client_local and
self.resource_manager.is_connected()):

self.resource_manager.disconnect()

Expand Down
2 changes: 1 addition & 1 deletion src/rotest/core/models/case_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def should_skip(cls, test_name, run_data=None, exclude_pk=None):

matches = query_set.order_by(cls._RUNTIME_ORDER)

return matches.count() > 0 and matches.first().success is True
return matches.count() > 0 and matches.first().success

def resources_names(self):
"""Return a string representing the resources this test used.
Expand Down
2 changes: 1 addition & 1 deletion src/rotest/core/models/run_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ def get_return_value(self):
Returns:
number. 0 success, 1 otherwise.
"""
return int(self.main_test.success is False)
return int(not self.main_test.success)

0 comments on commit 0b51124

Please sign in to comment.