Replace catch_warnings with check_warnings when it makes sense. Use assertRaises context manager to simplify some tests.
diff --git a/Lib/test/test_macostools.py b/Lib/test/test_macostools.py
index 642a584..4f15982 100644
--- a/Lib/test/test_macostools.py
+++ b/Lib/test/test_macostools.py
@@ -23,14 +23,8 @@
rfp.close()
def tearDown(self):
- try:
- os.unlink(test_support.TESTFN)
- except:
- pass
- try:
- os.unlink(TESTFN2)
- except:
- pass
+ test_support.unlink(test_support.TESTFN)
+ test_support.unlink(TESTFN2)
def compareData(self):
fp = open(test_support.TESTFN, 'r')
@@ -53,36 +47,25 @@
def test_touched(self):
# This really only tests that nothing unforeseen happens.
- import warnings
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore', 'macostools.touched*',
- DeprecationWarning)
+ with test_support.check_warnings(('macostools.touched*',
+ DeprecationWarning), quiet=True):
macostools.touched(test_support.TESTFN)
if sys.maxint < 2**32:
def test_copy(self):
- try:
- os.unlink(TESTFN2)
- except:
- pass
+ test_support.unlink(TESTFN2)
macostools.copy(test_support.TESTFN, TESTFN2)
self.assertEqual(self.compareData(), '')
if sys.maxint < 2**32:
def test_mkalias(self):
- try:
- os.unlink(TESTFN2)
- except:
- pass
+ test_support.unlink(TESTFN2)
macostools.mkalias(test_support.TESTFN, TESTFN2)
fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0)
self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
def test_mkalias_relative(self):
- try:
- os.unlink(TESTFN2)
- except:
- pass
+ test_support.unlink(TESTFN2)
# If the directory doesn't exist, then chances are this is a new
# install of Python so don't create it since the user might end up
# running ``sudo make install`` and creating the directory here won't