Commit fa23cc84 authored by Éric Araujo's avatar Éric Araujo

Add test that was promised in a comment but not actually written

parent 9556a5ba
"""Tests for the uninstall command.""" """Tests for the uninstall command."""
import os import os
import sys import sys
import logging
from io import StringIO from io import StringIO
import stat import stat
import packaging.util import packaging.util
...@@ -105,14 +106,14 @@ class UninstallTestCase(support.TempdirManager, ...@@ -105,14 +106,14 @@ class UninstallTestCase(support.TempdirManager,
def test_remove_issue(self): def test_remove_issue(self):
# makes sure if there are OSErrors (like permission denied) # makes sure if there are OSErrors (like permission denied)
# remove() stops and display a clean error # remove() stops and displays a clean error
dist, site_packages = self.install_dist('Meh') dist, site_packages = self.install_dist('Meh')
# breaking os.rename # breaking os.rename
old = os.rename old = os.rename
def _rename(source, target): def _rename(source, target):
raise OSError raise OSError(42, 'impossible operation')
os.rename = _rename os.rename = _rename
try: try:
...@@ -120,6 +121,10 @@ class UninstallTestCase(support.TempdirManager, ...@@ -120,6 +121,10 @@ class UninstallTestCase(support.TempdirManager,
finally: finally:
os.rename = old os.rename = old
logs = [log for log in self.get_logs(logging.INFO)
if log.startswith('Error:')]
self.assertEqual(logs, ['Error: [Errno 42] impossible operation'])
self.assertTrue(remove('Meh', paths=[site_packages])) self.assertTrue(remove('Meh', paths=[site_packages]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment