Exemple #1
0
def test_nochangestatus_magic():
    """ Test that operators unique to NoChangeStatus work """
    obj = status.NoChangeStatus('Test')
    stat = status.Status('Test', 0, (0, 0))

    # generator equality tests
    for comp, type_ in [(obj, 'status.NoChangeStatus'),
                        (stat, 'status.Status'), ('Test', 'unicode')]:
        check_operator_equal.description = (
            'Status.NoChangeStatus: Operator eq works with type: {}'.format(
                type_))
        yield check_operator_equal, obj, comp, lambda x, y: x.__eq__(y), True

        check_operator_not_equal.description = (
            'status.NoChangeStatus: Operator ne works with type: {}'.format(
                type_))
        yield check_operator_not_equal, obj, comp, lambda x, y: x.__ne__(
            y), True
Exemple #2
0
@pytest.mark.parametrize('new,old', FIXES)
def test_fixes(new, old):
    assert status.status_lookup(new) > status.status_lookup(old)


@pytest.mark.parametrize('new,old', itertools.permutations(STATUSES, 2))
def test_changes(new, old):
    assert status.status_lookup(new) != status.status_lookup(old)


@pytest.mark.parametrize('new,old', itertools.permutations(NO_OPS, 2))
def test_no_change(new, old):
    new = status.status_lookup(new)
    old = status.status_lookup(old)
    assert not new < old
    assert not new > old


@pytest.mark.parametrize("stat,op,expected", [
    (status.Status('Test', 0, (0, 0)), str, 'Test'),
    (status.Status('Test', 0, (0, 0)), bytes, b'Test'),
    (status.Status('Test', 0, (0, 0)), int, 0),
    (status.Status('Test', 0, (0, 0)), repr, 'Status("Test", 0, (0, 0))'),
    (status.Status('Test', 0, (0, 0)), hash, hash('Test')),
    (status.NoChangeStatus('No'), hash, hash('No')),
])
def test_status_comparisons(stat, op, expected):
    """Test status.Status equality protocol."""
    assert op(stat) == expected
Exemple #3
0
def initialize_nochangestatus():
    """ NoChangeStatus initializes """
    nc = status.NoChangeStatus('test')
    assert nc
Exemple #4
0
def initialize_nochangestatus():
    """status.NoChangeStatus: class initializes"""
    status.NoChangeStatus('test')