diff options
| author | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-01-11 17:08:12 +0000 |
|---|---|---|
| committer | Anderson Bravalheri <andersonbravalheri@gmail.com> | 2023-01-11 17:08:12 +0000 |
| commit | 8019ad70b1ecadc5b889570d5db1de04538704de (patch) | |
| tree | 8e67f7ed3e17b075ac5f8e02b76221b69f9772f0 /setuptools | |
| parent | ee4d6f1d87868ea025bfe01e626c2e4079aee60b (diff) | |
| parent | 88018bf721916bb96dc39e9662fa3082b90598fb (diff) | |
| download | python-setuptools-git-8019ad70b1ecadc5b889570d5db1de04538704de.tar.gz | |
Merge: Catching excption from utime and providing human-readable error description (#3716)
Diffstat (limited to 'setuptools')
| -rw-r--r-- | setuptools/command/egg_info.py | 6 | ||||
| -rw-r--r-- | setuptools/tests/test_egg_info.py | 16 |
2 files changed, 21 insertions, 1 deletions
diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 25888ed8..95c81845 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -295,7 +295,11 @@ class egg_info(InfoCommon, Command): def run(self): self.mkpath(self.egg_info) - os.utime(self.egg_info, None) + try: + os.utime(self.egg_info, None) + except OSError as e: + msg = f"Cannot update time stamp of directory '{self.egg_info}'" + raise distutils.errors.DistutilsFileError(msg) from e for ep in metadata.entry_points(group='egg_info.writers'): writer = ep.load() writer(self, ep.name, os.path.join(self.egg_info, ep.name)) diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 387773c1..6a2a9893 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -7,6 +7,7 @@ import stat import time from typing import List, Tuple from pathlib import Path +from unittest import mock import pytest from jaraco import path @@ -158,6 +159,21 @@ class TestEggInfo: ] assert sorted(actual) == expected + def test_handling_utime_error(self, tmpdir_cwd, env): + dist = Distribution() + ei = egg_info(dist) + utime_patch = mock.patch('os.utime', side_effect=OSError("TEST")) + mkpath_patch = mock.patch( + 'setuptools.command.egg_info.egg_info.mkpath', return_val=None + ) + + with utime_patch, mkpath_patch: + import distutils.errors + + msg = r"Cannot update time stamp of directory 'None'" + with pytest.raises(distutils.errors.DistutilsFileError, match=msg): + ei.run() + def test_license_is_a_string(self, tmpdir_cwd, env): setup_config = DALS(""" [metadata] |
