Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# SPDX-FileCopyrightText: 2021 Helmholtz-Zentrum für Umweltforschung GmbH - UFZ
#
# SPDX-License-Identifier: GPL-3.0-or-later
import pytest
import saqc.lib.tools as tools
import pandas as pd
import numpy as np
class _ListLike(list):
pass
@pytest.mark.parametrize('value,expected', [
(None, [None]),
([None], [None]),
(1, [1]),
(np.nan, [np.nan]),
([1], [1]),
('foo', ['foo']),
(['foo'], ['foo']),
([1, 2], [1, 2]),
(_ListLike("ab"), ['a', 'b'])
])
def test_toSequence(value, expected):
result = tools.toSequence(value)
assert isinstance(result, list)
assert result == expected
@pytest.mark.parametrize('value,expected', [
([1], 1),
([[]], []),
([[1, 2]], [1, 2]),
(_ListLike('a'), 'a')
])
def test_squeezeSequence(value, expected):
result = tools.squeezeSequence(value)
assert result == expected