コード例 #1
0
def test_statistic_can_be_created_from_list():
    data = [1, 2, 3]
    st = Statistic(data)
    assert len(st) == 3
    assert not st.empty
    assert st.as_list() == [1, 2, 3]
    assert st.as_tuple() == tuple(data)
    assert st.as_list() is not data  # check that data was copied
コード例 #2
0
def test_statistic_is_initially_empty():
    st = Statistic()
    assert len(st) == 0
    assert st.empty
    assert st.as_list() == []
    assert st.as_tuple() == ()
コード例 #3
0
def test_statistic_extend_adds_all_items():
    st = Statistic([1])
    st.extend([2, 3])
    assert st.as_tuple() == (1, 2, 3)
コード例 #4
0
def test_statistic_append_adds_values():
    st = Statistic()
    st.append(1)
    st.append(20)
    assert st.as_tuple() == (1, 20)
コード例 #5
0
def test_statistic_copy_data_content_instead_of_pointer():
    data = [1, 2]
    st = Statistic(data)
    st.append(3)
    assert st.as_tuple() == (1, 2, 3)
    assert data == [1, 2]