Skip to content

Commit

Permalink
Merge pull request #2472 from Kodiologist/hy2py-stdin
Browse files Browse the repository at this point in the history
Fix `hy2py` on standard input
  • Loading branch information
Kodiologist authored Jul 29, 2023
2 parents 72cddbf + 9dff46a commit 39be258
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hy/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def printing_source(hst):
hst.filename = filename

with filtered_hy_exceptions():
module_name = source_path.stem
module_name = source_path.stem if source_path else Path(filename).name
if parent_module:
module_name = f"{parent_module}.{module_name}"
module = types.ModuleType(module_name)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ def test_assert(tmp_path, monkeypatch):
assert ("bye" in err) == show_msg


def test_hy2py_stdin():
out, _ = run_cmd("hy2py", "(+ 482 223)")
assert "482 + 223" in out
assert "705" not in out


def test_hy2py_compile_only(monkeypatch):
def check(args):
output, _ = run_cmd(f"hy2py {args}")
Expand Down

0 comments on commit 39be258

Please sign in to comment.