Beispiel #1
0
def test_assert_raises_subclass():
    class MyClass(ValueError):
        pass

    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            raise MyClass('herpderp')
Beispiel #2
0
def test_assert_raises_subclass():
    class MyClass(ValueError):
        pass

    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            raise MyClass('herpderp')
def test_readme_does_not_exist(tmpdir):
    with assert_raises_with_msg(
        FileValidationError,
        'README.md: File does not exist.\n\n'
        'To attempt automatic fixing, run with --fix.'
    ):
        check_readme(tmpdir.strpath)
Beispiel #4
0
def test_load_invalid_yaml(tmpdir):
    # It's surprisingly hard to make invalid yaml!
    _write_config_file(tmpdir.strpath, 'foo: "')

    with assert_raises_with_msg(
            ConfigValidationError,
            REMatcher(
                r'^.pypi-practices-config.yaml: Invalid Yaml:\n\n'
                r'while scanning a quoted scalar\n'
                r'  in ".+\.pypi-practices-config.yaml", line 1, column 6\n'
                r'found unexpected end of stream\n'
                r'  in ".+\.pypi-practices-config.yaml", line 1, column 7'),
    ):
        load_config(tmpdir.strpath)
def test_load_invalid_yaml(tmpdir):
    # It's surprisingly hard to make invalid yaml!
    _write_config_file(tmpdir.strpath, 'foo: "')

    with assert_raises_with_msg(
        ConfigValidationError,
        REMatcher(
            r'^.pypi-practices-config.yaml: Invalid Yaml:\n\n'
            r'while scanning a quoted scalar\n'
            r'  in ".+\.pypi-practices-config.yaml", line 1, column 6\n'
            r'found unexpected end of stream\n'
            r'  in ".+\.pypi-practices-config.yaml", line 1, column 7'
        ),
    ):
        load_config(tmpdir.strpath)
Beispiel #6
0
def test_valid_yaml_invalid_config(tmpdir):
    # autofix is a boolean
    _write_config_file(tmpdir.strpath, 'autofix: herp')

    with assert_raises_with_msg(
            ConfigValidationError,
            REMatcher(
                r"^.pypi-practices-config.yaml: File does not satisfy schema:\n\n"
                r"'herp' is not of type u?'boolean'\n\n"
                r"Failed validating u?'type' "
                r"in schema\[u?'properties'\]\[u?'autofix'\]:\n"
                r"    {u?'type': u?'boolean'}\n\n"
                r"On instance\[u?'autofix'\]:\n"
                r"    'herp'")):
        load_config(tmpdir.strpath)
def test_valid_yaml_invalid_config(tmpdir):
    # autofix is a boolean
    _write_config_file(tmpdir.strpath, 'autofix: herp')

    with assert_raises_with_msg(
        ConfigValidationError,
        REMatcher(
            r"^.pypi-practices-config.yaml: File does not satisfy schema:\n\n"
            r"'herp' is not of type u?'boolean'\n\n"
            r"Failed validating u?'type' "
            r"in schema\[u?'properties'\]\[u?'autofix'\]:\n"
            r"    {u?'type': u?'boolean'}\n\n"
            r"On instance\[u?'autofix'\]:\n"
            r"    'herp'"
        )
    ):
        load_config(tmpdir.strpath)
Beispiel #8
0
def test_assert_raise_exactly_passing():
    with assert_raises_with_msg(ValueError, 'herpderp'):
        raise ValueError('herpderp')
Beispiel #9
0
def test_assert_raises_does_not_raise():
    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            pass
Beispiel #10
0
def test_assert_raises_mismatched_message():
    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            raise ValueError('harpdarp')
Beispiel #11
0
def test_assert_raises_with_msg_mismatched_type():
    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            raise TypeError('herpderp')
Beispiel #12
0
def test_assert_raise_exactly_passing():
    with assert_raises_with_msg(ValueError, 'herpderp'):
        raise ValueError('herpderp')
Beispiel #13
0
def test_assert_raises_does_not_raise():
    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            pass
Beispiel #14
0
def test_assert_raises_mismatched_message():
    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            raise ValueError('harpdarp')
Beispiel #15
0
def test_assert_raises_with_msg_mismatched_type():
    with pytest.raises(AssertionError):
        with assert_raises_with_msg(ValueError, 'herpderp'):
            raise TypeError('herpderp')
def test_readme_does_not_exist(tmpdir):
    with assert_raises_with_msg(
            FileValidationError, 'README.md: File does not exist.\n\n'
            'To attempt automatic fixing, run with --fix.'):
        check_readme(tmpdir.strpath)