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

Method test_no_change

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

Source from the content-addressed store, hash-verified

2985 self.assertEqual(new_contents, orig_contents)
2986
2987 def test_no_change(self):
2988 # bpo-42398: Test that the destination file is left unchanged if the
2989 # content does not change. Moreover, check also that the file
2990 # modification time does not change in this case.
2991 code = dedent("""
2992 /*[clinic input]
2993 [clinic start generated code]*/
2994 /*[clinic end generated code: output=da39a3ee5e6b4b0d input=da39a3ee5e6b4b0d]*/
2995 """)
2996 with os_helper.temp_dir() as tmp_dir:
2997 fn = os.path.join(tmp_dir, "test.c")
2998 with open(fn, "w", encoding="utf-8") as f:
2999 f.write(code)
3000 pre_mtime = os.stat(fn).st_mtime_ns
3001 self.expect_success(fn)
3002 post_mtime = os.stat(fn).st_mtime_ns
3003 # Don't change the file modification time
3004 # if the content does not change
3005 self.assertEqual(pre_mtime, post_mtime)
3006
3007 def test_cli_force(self):
3008 invalid_input = dedent("""

Callers

nothing calls this directly

Calls 8

expect_successMethod · 0.95
dedentFunction · 0.90
temp_dirMethod · 0.80
openFunction · 0.50
joinMethod · 0.45
writeMethod · 0.45
statMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected