예제 #1
0
    def test_close(self, serial):
        driver = Driver().open('PORTNAME')

        driver.close()

        assert_that(serial().close, called())
        assert_that(driver._serial, is_(None))
예제 #2
0
def test_called_ok():
    matcher = called()
    mock = Mock()
    mock()

    ok = matcher.matches(mock)
    assert_that(ok, equal_to(True))
예제 #3
0
def test_called_ok():
    matcher = called()
    mock = Mock()
    mock()

    ok = matcher.matches(mock)
    assert_that(ok, equal_to(True))
예제 #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))
예제 #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))
예제 #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))
예제 #7
0
    def test_open(self, serial):
        driver = Driver().open('PORTNAME')

        assert_that(serial, called())
        assert_that(driver._serial, is_(serial()))
예제 #8
0
def test_called_ok_twice():
    mock = Mock()
    mock()
    mock()

    assert_that(mock, called())
예제 #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))
예제 #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))