Skip to content

unpack-iterable and macros #2573

Answered by Kodiologist
wrobell asked this question in Q&A
Apr 26, 2024 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

Your page is very basic and it does not discuss parametrized unit tests.

That page is for documenting Hy-specific issues. Parametrization via pytest.mark.parametrize should work exactly the same in Hy as in Python.

I recognize I am still mixing up macro/function worlds.

Yes, as I understand your example, you're trying to splice the run-time variable filter into a macro call. The macro is expanded at compile-time, when filter is just a symbol. If you want to expand at run-time instead, you could say

(setv result (hy.eval `((fn/f ~@filter) ~arg)))

Or, instead of using pytest.mark.parametrize, which resolves at run-time, you could build the four test functions yourself with metaprogramm…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Kodiologist
Comment options

@wrobell
Comment options

@Kodiologist
Comment options

Answer selected by wrobell
Comment options

You must be logged in to vote
1 reply
@wrobell
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants