# Path: mcm/tools.py
# class StopWatch:
# class ChainMap(UserDict):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
# def vcmp(v1, v2, op):
#     def __init__(self, *maps):
#     def __getitem__(self, key):


from mock import patch
from sys import version_info
    from time import monotonic
    from time import time
from mcm.tools import StopWatch, timer, vcmp, ChainMap
import operator
import pytest
        ('4.10','4.1',operator.ne,True),
        ('4.11','4.11',operator.ne,False),
        ))
def test_version_comparison(v1,v2,oper,result):
    assert vcmp(v1=v1,v2=v2,op=oper) == result


@patch('mcm.tools.timer', side_effect=[14705.275287508, 14711.190629636])
class Test_StopWatch:

    def test_sets_start_value_on_entering(self, timermock):
        with StopWatch() as st:
            assert st.start == 14705.275287508

    def test_sets_stop_value_on_exiting(self, timermock):
        with StopWatch() as st:
            pass
        assert st.stop == 14711.190629636

    def test_calculates_runtime_value_rounded_to_2_digits(self, timermock):
        with StopWatch() as st:
            pass
        assert st.runtime == 5.92


class Test_ChainMap:

    def setup(self):
        self.default_dict = dict(port=123, timeout=10)
        self.override_dict = dict(port=222)

# Path: mcm/tools.py
# class StopWatch:
# class ChainMap(UserDict):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
# def vcmp(v1, v2, op):
#     def __init__(self, *maps):
#     def __getitem__(self, key):


# Path: tests/test_tools.py
from mock import patch
from sys import version_info
    from time import monotonic
    from time import time
from mcm.tools import StopWatch, timer, vcmp, ChainMap
import operator
import pytest

        ('4.10','4.1',operator.ne,True),
        ('4.11','4.11',operator.ne,False),
        ))
def test_version_comparison(v1,v2,oper,result):
    assert vcmp(v1=v1,v2=v2,op=oper) == result


@patch('mcm.tools.timer', side_effect=[14705.275287508, 14711.190629636])
class Test_StopWatch:

    def test_sets_start_value_on_entering(self, timermock):
        with StopWatch() as st:
            assert st.start == 14705.275287508

    def test_sets_stop_value_on_exiting(self, timermock):
        with StopWatch() as st:
            pass
        assert st.stop == 14711.190629636

    def test_calculates_runtime_value_rounded_to_2_digits(self, timermock):
        with StopWatch() as st:
            pass
        assert st.runtime == 5.92


class Test_ChainMap:

    def setup(self):
        self.default_dict = dict(port=123, timeout=10)
        self.override_dict = dict(port=222)

        self.chained = ChainMap(self.override_dict, self.default_dict)