MCPcopy Index your code
hub / github.com/python/cpython / test_cli_make

Method test_cli_make

Lib/test/test_clinic.py:3045–3086  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3043 self.assertEndsWith(generated, checksum)
3044
3045 def test_cli_make(self):
3046 c_code = dedent("""
3047 /*[clinic input]
3048 [clinic start generated code]*/
3049 """)
3050 py_code = "pass"
3051 c_files = "file1.c", "file2.c"
3052 py_files = "file1.py", "file2.py"
3053
3054 def create_files(files, srcdir, code):
3055 for fn in files:
3056 path = os.path.join(srcdir, fn)
3057 with open(path, "w", encoding="utf-8") as f:
3058 f.write(code)
3059
3060 with os_helper.temp_dir() as tmp_dir:
3061 # add some folders, some C files and a Python file
3062 create_files(c_files, tmp_dir, c_code)
3063 create_files(py_files, tmp_dir, py_code)
3064
3065 # create C files in externals/ dir
3066 ext_path = os.path.join(tmp_dir, "externals")
3067 with os_helper.temp_dir(path=ext_path) as externals:
3068 create_files(c_files, externals, c_code)
3069
3070 # run clinic in verbose mode with --make on tmpdir
3071 out = self.expect_success("-v", "--make", "--srcdir", tmp_dir)
3072
3073 # expect verbose mode to only mention the C files in tmp_dir
3074 for filename in c_files:
3075 with self.subTest(filename=filename):
3076 path = os.path.join(tmp_dir, filename)
3077 self.assertIn(path, out)
3078 for filename in py_files:
3079 with self.subTest(filename=filename):
3080 path = os.path.join(tmp_dir, filename)
3081 self.assertNotIn(path, out)
3082 # don't expect C files from the externals dir
3083 for filename in c_files:
3084 with self.subTest(filename=filename):
3085 path = os.path.join(ext_path, filename)
3086 self.assertNotIn(path, out)
3087
3088 def test_cli_make_exclude(self):
3089 code = dedent("""

Callers

nothing calls this directly

Calls 7

expect_successMethod · 0.95
dedentFunction · 0.90
temp_dirMethod · 0.80
assertInMethod · 0.80
assertNotInMethod · 0.80
joinMethod · 0.45
subTestMethod · 0.45

Tested by

no test coverage detected