示例#1
0
def test_path_regex_bad():
    for path in (
            '/xfoo',
            '/xfoo/',
            '/xfoo/bar',
            '/xfoo/bar/',
            '/x/foo/bar/',
            '/x//foo',
            '/y',
            '/y/x/foo',
    ):
        assert_not_regex(path, path_pat)
def test_docstring_addition():
    @unpack_labeled_data()
    def funcy(ax, *args, **kwargs):
        """Funcy does nothing"""
        pass

    assert_regex(funcy.__doc__,
                 r".*All positional and all keyword arguments\.")
    assert_not_regex(funcy.__doc__, r".*All positional arguments\.")
    assert_not_regex(funcy.__doc__,
                     r".*All arguments with the following names: .*")

    @unpack_labeled_data(replace_all_args=True, replace_names=[])
    def funcy(ax, x, y, z, bar=None):
        """Funcy does nothing"""
        pass

    assert_regex(funcy.__doc__, r".*All positional arguments\.")
    assert_not_regex(funcy.__doc__,
                     r".*All positional and all keyword arguments\.")
    assert_not_regex(funcy.__doc__,
                     r".*All arguments with the following names: .*")

    @unpack_labeled_data(replace_all_args=True, replace_names=["bar"])
    def funcy(ax, x, y, z, bar=None):
        """Funcy does nothing"""
        pass

    assert_regex(funcy.__doc__, r".*All positional arguments\.")
    assert_regex(funcy.__doc__,
                 r".*All arguments with the following names: 'bar'\.")
    assert_not_regex(funcy.__doc__,
                     r".*All positional and all keyword arguments\.")

    @unpack_labeled_data(replace_names=["x", "bar"])
    def funcy(ax, x, y, z, bar=None):
        """Funcy does nothing"""
        pass

    # lists can print in any order, so test for both x,bar and bar,x
    assert_regex(funcy.__doc__,
                 r".*All arguments with the following names: '.*', '.*'\.")
    assert_regex(funcy.__doc__, r".*'x'.*")
    assert_regex(funcy.__doc__, r".*'bar'.*")
    assert_not_regex(funcy.__doc__,
                     r".*All positional and all keyword arguments\.")
    assert_not_regex(funcy.__doc__, r".*All positional arguments\.")
def test_docstring_addition():
    @unpack_labeled_data()
    def funcy(ax, *args, **kwargs):
        """Funcy does nothing"""
        pass

    assert_regex(funcy.__doc__,
                          r".*All positional and all keyword arguments\.")
    assert_not_regex(funcy.__doc__, r".*All positional arguments\.")
    assert_not_regex(funcy.__doc__,
                              r".*All arguments with the following names: .*")

    @unpack_labeled_data(replace_all_args=True, replace_names=[])
    def funcy(ax, x, y, z, bar=None):
        """Funcy does nothing"""
        pass

    assert_regex(funcy.__doc__, r".*All positional arguments\.")
    assert_not_regex(funcy.__doc__,
                              r".*All positional and all keyword arguments\.")
    assert_not_regex(funcy.__doc__,
                              r".*All arguments with the following names: .*")

    @unpack_labeled_data(replace_all_args=True, replace_names=["bar"])
    def funcy(ax, x, y, z, bar=None):
        """Funcy does nothing"""
        pass

    assert_regex(funcy.__doc__, r".*All positional arguments\.")
    assert_regex(funcy.__doc__,
                          r".*All arguments with the following names: 'bar'\.")
    assert_not_regex(funcy.__doc__,
                              r".*All positional and all keyword arguments\.")

    @unpack_labeled_data(replace_names=["x", "bar"])
    def funcy(ax, x, y, z, bar=None):
        """Funcy does nothing"""
        pass

    # lists can print in any order, so test for both x,bar and bar,x
    assert_regex(funcy.__doc__,
                    r".*All arguments with the following names: '.*', '.*'\.")
    assert_regex(funcy.__doc__, r".*'x'.*")
    assert_regex(funcy.__doc__, r".*'bar'.*")
    assert_not_regex(funcy.__doc__,
                              r".*All positional and all keyword arguments\.")
    assert_not_regex(funcy.__doc__, r".*All positional arguments\.")