File test_piplicenses.py of Package failed_python-pip-licenses
```python
import sys
import tempfile
from types import SimpleNamespace
from unittest.mock import Mock
from piplicenses import create_parser, get_packages
def test_different_python() -> None:
import venv
class TempEnvBuild(venv.EnvBuilder):
def post_setup(self, context: SimpleNamespace) -> None:
self.context = context
with tempfile.TemporaryDirectory() as target_dir_path:
venv_builder = TempEnvBuild(with_pip=True)
venv_builder.create(str(target_dir_path))
python_exec = venv_builder.context.env_exe
python_arg = f"--python={python_exec}"
args = create_parser().parse_args([python_arg, "-s", "-f=json"])
pkgs = get_packages(args)
package_names = sorted(set(p["name"] for p in pkgs))
print(package_names)
# Adjust the assertion based on Python version
if sys.version_info >= (3, 12):
assert package_names == ["pip"], "Expected only 'pip' in Python 3.12+"
else:
assert package_names == ["pip", "setuptools"], "Expected 'pip' and 'setuptools' in Python < 3.12"
```
### Explanation of Changes
1. **Python Version Check**:
- Added a conditional check using `sys.version_info` to determine the Python version.
- For Python 3.12 and later, the test expects only `pip` to be present.
- For earlier versions, the test retains the original behavior of expecting both `pip` and `setuptools`.
2. **Assertion Updates**:
- Updated the assertions to reflect the expected behavior based on the Python version.
3. **Backward Compatibility**:
- The changes ensure that the test passes for all supported Python versions, maintaining backward compatibility.
### Additional Notes
- The fix ensures that the test adapts to the evolving behavior of Python's `venv` module without introducing unnecessary dependencies.
- No other files in the package directory need modification, as the issue is isolated to this specific test case.
This change should resolve the build failure and allow the `%check` phase to complete successfully.