Skip to content

Commit

Permalink
Fix the MolerConnectionForSingleThreadRunner class (#422)
Browse files Browse the repository at this point in the history
* fix the MolerConnectionForSingleThreadRunner class

* fix the check

* for version 1.32.1

* update changelog

Co-authored-by: Tomasz Krol <[email protected]>
  • Loading branch information
marcin-usielski and tkrol88 authored Oct 6, 2021
1 parent b7ffbcb commit c6248a9
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
## moler 1.32.1

### Improved
* Check if passed object is ConnectionObserver instance in MolerConnectionForSingleThreadRunner

## moler 1.32.0

### Added
* add `ADDITIONAL_PARAMS` in device configuration
* add possibility use `single-threaded` runner for all ConnectionObservers

### Improved
* Add more readable traceback
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![image](https://img.shields.io/badge/pypi-v1.32.0-blue.svg)](https://pypi.org/project/moler/)
[![image](https://img.shields.io/badge/pypi-v1.32.1-blue.svg)](https://pypi.org/project/moler/)
[![image](https://img.shields.io/badge/python-2.7%20%7C%203.6%20%7C%203.7%20%7C%203.8-blue.svg)](https://pypi.org/project/moler/)
[![Build Status](https://travis-ci.org/nokia/moler.svg?branch=master)](https://travis-ci.org/nokia/moler)
[![Coverage Status](https://coveralls.io/repos/github/nokia/moler/badge.svg?branch=master)](https://coveralls.io/github/nokia/moler?branch=master)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
author = 'Nokia'

# The short X.Y version
version = '1.32.0'
version = '1.32.1'
# The full version, including alpha/beta/rc tags
release = 'stable'

Expand Down
6 changes: 3 additions & 3 deletions moler/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
from moler.helpers import compare_objects
from moler.exceptions import MolerException
from moler.exceptions import WrongUsage
from . import connections as conn_cfg
from . import devices as dev_cfg
from . import loggers as log_cfg
from moler.config import connections as conn_cfg
from moler.config import devices as dev_cfg
from moler.config import loggers as log_cfg

loaded_config = ["NOT_LOADED_YET"]

Expand Down
20 changes: 16 additions & 4 deletions moler/moler_connection_for_single_thread_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
__email__ = '[email protected]'


import moler.connection_observer
from moler.abstract_moler_connection import identity_transformation
from moler.observer_thread_wrapper import ObserverThreadWrapper, ObserverThreadWrapperForConnectionObserver
from moler.connection_observer import ConnectionObserver
from moler.threaded_moler_connection import ThreadedMolerConnection
from moler.runner_single_thread import RunnerSingleThread
import time
Expand Down Expand Up @@ -119,10 +119,22 @@ def _create_observer_wrapper(self, observer_reference, self_for_observer):
to a function.
:return: Instance of wrapper.
"""
if observer_reference is None or not isinstance(self_for_observer, ConnectionObserver):
otw = ObserverThreadWrapper(
if self._is_connection_observer_instance(self_for_observer) is True:
otw = ObserverThreadWrapperForConnectionObserver(
observer=observer_reference, observer_self=self_for_observer, logger=self.logger)
else:
otw = ObserverThreadWrapperForConnectionObserver(
otw = ObserverThreadWrapper(
observer=observer_reference, observer_self=self_for_observer, logger=self.logger)
return otw

def _is_connection_observer_instance(self, self_for_observer):
"""
Check if argument is an instance of subclass of ConnectionObserver.
:param self_for_observer: object to check.
:return: True if observer_reference is a subclass of ConnectionObserver, False otherwise.
"""
if self_for_observer is None:
return False
if isinstance(self_for_observer, moler.connection_observer.ConnectionObserver):
return True
return False
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='moler', # Required
version='1.32.0', # Required
version='1.32.1', # Required
description='Moler is library to help in building automated tests', # Required
long_description=long_description, # Optional
long_description_content_type='text/markdown', # Optional (see note above)
Expand Down
4 changes: 4 additions & 0 deletions test/integration/test_io_raw_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import pytest
import mock
import threading
import sys


pytestmark = pytest.mark.skipif(sys.version_info < (3, 4), reason="requires python3.4 or higher")


def test_can_create_passive_sshshell_connection_using_same_api(passive_sshshell_connection_class):
Expand Down

0 comments on commit c6248a9

Please sign in to comment.