Example #1
0
def test_mx_wrong_matrix():
    assert Matrix('A', [[1, 2], [1, 2, 3], [1, 2]])
Example #2
0
def test_mx_more_para(test_input, expected):
    a = Matrix('', test_input)
    print(a)
    assert Matrix('', test_input) == expected
Example #3
0
def test_mx_string():
    assert Matrix('A', [1, 2, 3]) == [[1, 2, 3]]
Example #4
0
def test_mx_multiple_7():
    A = Matrix('A', [[12, 7, 3], [4, 5, 6], [7, 8, 9]])
    B = Matrix('B', [[5, 8, 1, 2], [6, 7, 3, 0], [4, 5, 9, 1]])
    C = Matrix('C',
               [[114, 160, 60, 27], [74, 97, 73, 14], [119, 157, 112, 23]])
    assert A * B == C
Example #5
0
def test_mx_multiple_8():
    A = Matrix('A', [[1, 2], [5, 3], [6, 7]])
    B = Matrix('B', [[5], [1], [1]])
    with pytest.raises(ValueError):
        C = A * B
Example #6
0
def test_mx_multiple_5():
    with pytest.raises(ValueError):
        A = Matrix('A', [[1, 2], [1, 2, 3], [1, 2]])
Example #7
0
def test_mx_multiple_6():
    A = Matrix('A', [[1, 2], [5, 3], [6, 7]])
    B = Matrix('B', [[5], [1]])
    C = Matrix('C', [[7], [28], [37]])
    assert A * B == C
Example #8
0
def test_mx_multiple_4():
    with pytest.raises(ValueError):
        A = Matrix('A', [['1'], [2], [3]])
Example #9
0
def test_mx_multiple_3():
    A = Matrix('A', [1, 2, 3])
    assert A == [[1, 2, 3]]
Example #10
0
def test_mx_multiple_2():
    A = Matrix('A', [[1], [2], [3]])
    assert A == [[1], [2], [3]]
Example #11
0
def test_mx_multiple_1():
    A = Matrix('A', [])
    assert A == []
Example #12
0

''' pytest - Decorator
@pytest.mark.parametrize("test_input,expected", [
    ('ll', LikeState.empty),
    ('dd', LikeState.empty),
    ('ddl', LikeState.liked),
])
@pytest.mark.skip(reason="regexes not supported yet")
@pytest.mark.xfail
@pytest.fixture
'''


@pytest.mark.parametrize("test_input, expected", [
    (Matrix('A', [1, 2, 3]), [[1, 2, 3]]),
    (Matrix('B', [4, 5, 6]), [[4, 5, 6]]),
    (Matrix('C', [7, 8, 9]), [[7, 8, 9]]),
])
def test_mx_more_para(test_input, expected):
    a = Matrix('', test_input)
    print(a)
    assert Matrix('', test_input) == expected


@pytest.mark.skip(reason="string input not supported yet")
def test_mx_string():
    assert Matrix('A', [1, 2, 3]) == [[1, 2, 3]]


@pytest.mark.xfail