Exemple #1
0
    def _validate_check(self, check):
        import reframe.utility as util

        name = type(check).__name__
        checkfile = os.path.relpath(inspect.getfile(type(check)))
        required_attrs = [
            'sanity_patterns', 'valid_systems', 'valid_prog_environs'
        ]
        for attr in required_attrs:
            if getattr(check, attr) is None:
                getlogger().warning(
                    f'{checkfile}: {attr!r} not defined for test {name!r}; '
                    f'skipping...')
                return False

        is_copyable = util.attr_validator(lambda obj: util.is_copyable(obj))
        valid, attr = is_copyable(check)
        if not valid:
            getlogger().warning(
                f'{checkfile}: {attr!r} is not copyable; '
                f'not copyable attributes are not '
                f'allowed inside the __init__() method; '
                f'consider setting them in a pipeline hook instead')
            return False

        return True
Exemple #2
0
def test_is_copyable():
    class X:
        pass

    x = X()
    assert util.is_copyable(x)

    class Y:
        def __copy__(self):
            pass

    y = Y()
    assert util.is_copyable(y)

    class Z:
        def __deepcopy__(self, memo):
            pass

    z = Z()
    assert util.is_copyable(z)

    def foo():
        yield

    assert util.is_copyable(foo)
    assert util.is_copyable(len)
    assert util.is_copyable(int)
    assert not util.is_copyable(foo())