Пример #1
0
def test_cnset_raises_SettingsError_if_names_kwarg_causes_errors():
    """Calls to the ``cnset`` factory should produce a RangeSet object
    with internal Unit objects representing RangeSet endpoints that
    have blank names if the provided ``names`` kwarg .
    """
    types = [FactoryTestType]
    ranges = [('AB 100', 'AB 150'), ('CA 0', 'CA 1300')]
    names = [('R1 Start', 'R1 End')]
    with pytest.raises(e.SettingsError):
        f.cnset(ranges, names=names, unittypes=types)
Пример #2
0
def test_cnset_returns_object_or_raises_error(ranges, expected):
    """Calls to the ``cnset`` factory should successfully create the
    expected RangeSet object or raise the expected error, based on the
    provided values for ranges.
    """
    types = [FactoryTestType, AnotherFactoryTestType]
    if isinstance(expected, type) and issubclass(expected, Exception):
        with pytest.raises(expected):
            f.cnset(ranges, unittypes=types)
    else:
        assert f.cnset(ranges, unittypes=types) == expected
Пример #3
0
def test_cnset_assigns_unit_names_correctly_with_names_kwarg():
    """Calls to the ``cnset`` factory should produce a RangeSet object
    with internal Unit objects representing RangeSet endpoints that
    have correct names based on the provided ``names`` kwarg.
    """
    types = [FactoryTestType]
    ranges = [('AB 100', 'AB 150'), ('CA 0', 'CA 1300')]
    names = [('R1 Start', 'R1 End'), ('R2 Start', 'R2 End')]
    myset = f.cnset(ranges, names=names, unittypes=types)
    assert (myset.ranges[0].start.name == 'R1 Start' and
            myset.ranges[0].end.name == 'R1 End' and
            myset.ranges[1].start.name == 'R2 Start' and
            myset.ranges[1].end.name == 'R2 End')