Esempio n. 1
0
def test_bounds(peak):
    peak = copy.copy(peak)

    # Setter
    peak.bounds = (11, 12, 13)

    for obj in [
            test_string, *test_numbers, test_dict, ['a', 'b', 'c'], test_tuple
    ]:
        with pytest.raises(TypeError):
            peak.bounds = obj

    for obj in [*test_lists, (1, 2), [1, 2, 3, 4]]:
        with pytest.raises(ValueError,
                           match="'Peak.bounds' must have exactly 3 elements"):
            peak.bounds = obj

    # Getter
    assert peak.bounds == (11, 12, 13)
    assert isinstance(peak.bounds, tuple)
    peak2 = Peak(test_float)
    peak2.bounds = [11, 12, 13]  # type: ignore
    assert peak2.bounds == (11, 12, 13)
    assert isinstance(peak2.bounds, tuple)

    # set_bounds
    peak3 = Peak(test_float)
    peak3.set_bounds(11, 12, 13)
    assert peak3.bounds == (11, 12, 13)
    assert isinstance(peak3.bounds, tuple)

    for obj in [*test_sequences, test_string, test_dict, test_float]:
        print(obj)

        with pytest.raises(TypeError):
            peak3.set_bounds(obj, 12, 13)  # type: ignore
        with pytest.raises(TypeError):
            peak3.set_bounds(11, obj, 13)  # type: ignore
        with pytest.raises(TypeError):
            peak3.set_bounds(11, 12, obj)  # type: ignore
Esempio n. 2
0
def test_bounds(peak):
    peak = copy.copy(peak)

    # Setter
    peak.bounds = (11, 12, 13)

    for obj in [
            test_string, *test_numbers, test_dict, ["a", "b", "c"], test_tuple
    ]:
        with pytest.raises(TypeError):
            peak.bounds = obj

    for obj in [*test_lists, (1, 2), [1, 2, 3, 4]]:
        with pytest.raises(ValueError):
            peak.bounds = obj

    # Getter
    assert peak.bounds == (11, 12, 13)
    assert isinstance(peak.bounds, tuple)
    peak2 = Peak(test_float)
    peak2.bounds = [11, 12, 13]
    assert peak2.bounds == [11, 12, 13]
    assert isinstance(peak2.bounds, list)

    # set_bounds
    peak3 = Peak(test_float)
    peak3.set_bounds(11, 12, 13)
    assert peak3.bounds == (11, 12, 13)
    assert isinstance(peak3.bounds, tuple)

    for obj in [*test_sequences, test_string, test_dict, test_float]:
        with pytest.raises(TypeError):
            print(obj)
            peak3.set_bounds(obj, 12, 13)
        with pytest.raises(TypeError):
            peak3.set_bounds(11, obj, 13)
        with pytest.raises(TypeError):
            peak3.set_bounds(11, 12, obj)