Exemplo n.º 1
0
    def test_close(self, serial):
        driver = Driver().open('PORTNAME')

        driver.close()

        assert_that(serial().close, called())
        assert_that(driver._serial, is_(None))
Exemplo n.º 2
0
def test_called_ok():
    matcher = called()
    mock = Mock()
    mock()

    ok = matcher.matches(mock)
    assert_that(ok, equal_to(True))
Exemplo n.º 3
0
def test_called_ok():
    matcher = called()
    mock = Mock()
    mock()

    ok = matcher.matches(mock)
    assert_that(ok, equal_to(True))
Exemplo n.º 4
0
def test_called_fail(desc):
    expected = 'was called 0 times'
    matcher = called()
    mock = Mock()

    ok = matcher.matches(mock, desc)
    assert_that(ok, equal_to(False))
    assert_that(str(desc), equal_to(expected))
Exemplo n.º 5
0
def test_called_fail(desc):
    expected = 'was called 0 times'
    matcher = called()
    mock = Mock()

    ok = matcher.matches(mock, desc)
    assert_that(ok, equal_to(False))
    assert_that(str(desc), equal_to(expected))
Exemplo n.º 6
0
def test_called_fail():
    expected = '''
Expected: Mock called with ANYTHING None times
     but: was called 0 times
'''

    mock = Mock()

    with assert_raises(AssertionError) as e:
        assert_that(mock, called())

    assert_that(str(e.exception), equal_to(expected))
Exemplo n.º 7
0
    def test_open(self, serial):
        driver = Driver().open('PORTNAME')

        assert_that(serial, called())
        assert_that(driver._serial, is_(serial()))
Exemplo n.º 8
0
def test_called_ok_twice():
    mock = Mock()
    mock()
    mock()

    assert_that(mock, called())
Exemplo n.º 9
0
def test_called_description(desc):
    expected = 'Mock called a value greater than <0> times with ANYTHING'
    matcher = called()
    matcher.describe_to(desc)
    assert_that(str(desc), equal_to(expected))
Exemplo n.º 10
0
def test_called_description(desc):
    expected = 'Mock called a value greater than <0> times with ANYTHING'
    matcher = called()
    matcher.describe_to(desc)
    assert_that(str(desc), equal_to(expected))