def METHOD_NAME(self):
    import pytest
    mod = self.make_module("""
        HPyDef_METH(f, "f", HPyFunc_VARARGS)
        static HPy f_impl(HPyContext *ctx, HPy self, const HPy *args,
                          size_t nargs)
        {
            HPy src;
            long len;
            const char *buf;
            if (!HPyArg_Parse(ctx, NULL, args, nargs, "Ol", &src, &len)) {
                return HPy_NULL;
            }
            buf = HPyBytes_AsString(ctx, src);
            return HPyBytes_FromStringAndSize(ctx, buf, len);
        }
        HPyDef_METH(f_null, "f_null", HPyFunc_VARARGS)
        static HPy f_null_impl(HPyContext *ctx, HPy self, const HPy *args,
                               size_t nargs)
        {
            long len;
            if (!HPyArg_Parse(ctx, NULL, args, nargs, "l", &len)) {
                return HPy_NULL;
            }
            return HPyBytes_FromStringAndSize(ctx, NULL, len);
        }
        @EXPORT(f)
        @EXPORT(f_null)
        @INIT
    """)
    assert mod.f(b"aaa", 3) == b"aaa"
    assert mod.f(b"abc", 2) == b"ab"
    assert mod.f(b"", 0) == b""
    with pytest.raises(SystemError):
        # negative size passed to HPyBytes_FromStringAndSize
        mod.f(b"abc", -1)
    for i in (-1, 0, 1):
        with pytest.raises(ValueError) as err:
            mod.f_null(i)
        assert str(err.value) == (
            "NULL char * passed to HPyBytes_FromStringAndSize")