summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRonan Pigott <ronan@rjp.ie>2023-09-19 23:18:23 (GMT)
committerGitHub <noreply@github.com>2023-09-19 23:18:23 (GMT)
commitddf2e953c27d529b7e321c972ede2afce5dfb0b0 (patch)
tree4b26a45749135b495b76e754578c7c6b7b1a9297 /Lib/test
parentfd7e08a6f35581e1189b9bf12feb51f7167a86c5 (diff)
downloadcpython-ddf2e953c27d529b7e321c972ede2afce5dfb0b0.zip
cpython-ddf2e953c27d529b7e321c972ede2afce5dfb0b0.tar.gz
cpython-ddf2e953c27d529b7e321c972ede2afce5dfb0b0.tar.bz2
gh-109033: Return filename with os.utime errors (#109034)
The filename was previously intentionally omitted from exception because "it might confuse the user". Uncaught exceptions are not generally a replacement for user-facing error messages, so obscuring this information only has the effect of making the programmer's life more difficult.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_os.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 34cd27b..66aece2 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -913,6 +913,13 @@ class UtimeTests(unittest.TestCase):
os.utime(self.fname, None)
self._test_utime_current(set_time)
+ def test_utime_nonexistent(self):
+ now = time.time()
+ filename = 'nonexistent'
+ with self.assertRaises(FileNotFoundError) as cm:
+ os.utime(filename, (now, now))
+ self.assertEqual(cm.exception.filename, filename)
+
def get_file_system(self, path):
if sys.platform == 'win32':
root = os.path.splitdrive(os.path.abspath(path))[0] + '\\'