Skip to content

Commit 6e5bf84

Browse files
committed
add test for shebang
1 parent 022db25 commit 6e5bf84

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/entry_points/py_console_script_gen_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,35 @@ def test_a_second_entry_point_class_method(self):
198198
self.assertRegex(got, "from foo\.baz import Bar")
199199
self.assertRegex(got, "sys\.exit\(Bar\.baz\(\)\)")
200200

201+
def test_shebang_included(self):
202+
with tempfile.TemporaryDirectory() as tmpdir:
203+
tmpdir = pathlib.Path(tmpdir)
204+
given_contents = (
205+
textwrap.dedent(
206+
"""
207+
[console_scripts]
208+
foo = foo.bar:baz
209+
"""
210+
).strip()
211+
+ "\n"
212+
)
213+
entry_points = tmpdir / "entry_points.txt"
214+
entry_points.write_text(given_contents)
215+
out = tmpdir / "foo.py"
216+
217+
shebang = "#!/usr/bin/env python3"
218+
run(
219+
entry_points=entry_points,
220+
out=out,
221+
console_script=None,
222+
console_script_guess="foo",
223+
shebang=shebang,
224+
)
225+
226+
got = out.read_text()
227+
228+
self.assertTrue(got.startswith(shebang + "\n"))
229+
201230

202231
if __name__ == "__main__":
203232
unittest.main()

0 commit comments

Comments
 (0)