Repository navigation
Pytest assertion rewriting #2673
|
[ Disclaimer: I am very new to Hy, but consider myself intermediate at both Lisp(s) and Python. I may be wrong, though. ] The problemI just came across Hy recently. I usually learn new languages through tests, so I can verify my assumptions easily. So I installed Pytest and Hy, got both working together, but noticed that I do not get the feedback of Pytest's What I triedI set up testing with the following code (which I import os
from pathlib import Path
import hy, pytest
NATIVE_TESTS = Path.cwd() / "tests/hy_tests"
def pytest_collect_file(file_path, parent):
if (
file_path.suffix == ".hy"
and NATIVE_TESTS in file_path.parents
and file_path.name != "__init__.hy"
):
return pytest.Module.from_parent(parent, path=file_path)This Hy test: (defn test-always-fail []
(assert (= (pow 10 2) 42)))fails with , while this Python test: def test_always_fail():
assert pow(10, 2) == 42fails with What I got from the source code of both projects is that they both use custom loaders via I also tried I feel like I am almost there and it should work, but do not know how, or even if. Any answers would be greatly appreciated, as it would make the learning of Hy a tad easier. 😃 |
Replies: 1 comment 2 replies
|
Assertion rewriting for Hy just plain isn't implemented in pytest. I doubt they'd even accept a patch, since it would probably create a dependency on Hy. You'd have to make your own pytest plugin or something. |
Assertion rewriting for Hy just plain isn't implemented in pytest. I doubt they'd even accept a patch, since it would probably create a dependency on Hy. You'd have to make your own pytest plugin or something.