summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep277.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-10-05 17:54:56 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-10-05 17:54:56 (GMT)
commit1ee401fcf6a5b561cbed54051077784a11d9d438 (patch)
tree452476f847e293b60d334de3751e2258253464a0 /Lib/test/test_pep277.py
parenta844f2d165fa7ee4ac1119b53105af5d350063d8 (diff)
downloadcpython-1ee401fcf6a5b561cbed54051077784a11d9d438.zip
cpython-1ee401fcf6a5b561cbed54051077784a11d9d438.tar.gz
cpython-1ee401fcf6a5b561cbed54051077784a11d9d438.tar.bz2
This test fails on Win98, which is fine, but when it failed it left
a junk directory behind that caused 4 other tests to fail later. Now it cleans up after itself, and the 4 bogus later failures don't happen.
Diffstat (limited to 'Lib/test/test_pep277.py')
-rw-r--r--Lib/test/test_pep277.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
index f543a5a..bd11226 100644
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -6,7 +6,7 @@ from test.test_support import TESTFN, TestSkipped, TestFailed, run_suite
try:
from nt import _getfullpathname
except ImportError:
- raise TestSkipped, "test works only on NT"
+ raise TestSkipped, "test works only on NT+"
filenames = [
"abc",
@@ -20,9 +20,19 @@ filenames = [
unicode("曨שんдΓß","utf-8"),
]
+# Destroy directory dirname and all files under it, to one level.
+def deltree(dirname):
+ # Don't hide legitimate errors: if one of these suckers exists, it's
+ # an error if we can't remove it.
+ if os.path.exists(dirname):
+ for fname in os.listdir(dirname):
+ os.unlink(os.path.join(dirname, fname))
+ os.rmdir(dirname)
+
class UnicodeFileTests(unittest.TestCase):
+ files = [os.path.join(TESTFN, f) for f in filenames]
+
def setUp(self):
- self.files = [os.path.join(TESTFN, f) for f in filenames]
try:
os.mkdir(TESTFN)
except OSError:
@@ -34,9 +44,7 @@ class UnicodeFileTests(unittest.TestCase):
os.stat(name)
def tearDown(self):
- for name in self.files:
- os.unlink(name)
- os.rmdir(TESTFN)
+ deltree(TESTFN)
def _apply_failure(self, fn, filename, expected_exception,
check_fn_in_exception = True):
@@ -100,7 +108,10 @@ class UnicodeFileTests(unittest.TestCase):
def test_main():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(UnicodeFileTests))
- run_suite(suite)
+ try:
+ run_suite(suite)
+ finally:
+ deltree(TESTFN)
if __name__ == "__main__":
test_main()