Skip to content

Commit

Permalink
Rely on tree builder in test_build_scripts. Ref #232.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 2, 2024
1 parent 3a48a77 commit bc6d149
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions distutils/tests/test_build_scripts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Tests for distutils.command.build_scripts."""

import os
import textwrap

import jaraco.path

from distutils.command.build_scripts import build_scripts
from distutils.core import Distribution
Expand Down Expand Up @@ -46,37 +49,25 @@ def get_build_scripts_cmd(self, target, scripts):
return build_scripts(dist)

def write_sample_scripts(self, dir):
expected = []
expected.append("script1.py")
self.write_script(
dir,
"script1.py",
(
"#! /usr/bin/env python2.3\n"
"# bogus script w/ Python sh-bang\n"
"pass\n"
),
)
expected.append("script2.py")
self.write_script(
dir,
"script2.py",
("#!/usr/bin/python\n" "# bogus script w/ Python sh-bang\n" "pass\n"),
)
expected.append("shell.sh")
self.write_script(
dir,
"shell.sh",
("#!/bin/sh\n" "# bogus shell script w/ sh-bang\n" "exit 0\n"),
)
return expected

def write_script(self, dir, name, text):
f = open(os.path.join(dir, name), "w")
try:
f.write(text)
finally:
f.close()
spec = {
'script1.py': textwrap.dedent("""
#! /usr/bin/env python2.3
# bogus script w/ Python sh-bang
pass
""").lstrip(),
'script2.py': textwrap.dedent("""
#!/usr/bin/python
# bogus script w/ Python sh-bang
pass
""").lstrip(),
'shell.sh': textwrap.dedent("""
#!/bin/sh
# bogus shell script w/ sh-bang
exit 0
""").lstrip(),
}
jaraco.path.build(spec, dir)
return list(spec)

def test_version_int(self):
source = self.mkdtemp()
Expand Down

0 comments on commit bc6d149

Please sign in to comment.