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
def test_statistic_is_initially_empty(): st = Statistic() assert len(st) == 0 assert st.empty assert st.as_list() == [] assert st.as_tuple() == ()
def test_statistic_extend_adds_all_items(): st = Statistic([1]) st.extend([2, 3]) assert st.as_tuple() == (1, 2, 3)
def test_statistic_append_adds_values(): st = Statistic() st.append(1) st.append(20) assert st.as_tuple() == (1, 20)
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]