summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_normalization.py
diff options
context:
space:
mode:
authorMariatta <Mariatta@users.noreply.github.com>2017-06-20 06:31:11 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-06-20 06:31:11 (GMT)
commit070ba85a8f45819d9197bce4541cd594d79d247c (patch)
tree3a170e59a2ac60cd8a997d792acd902fbd68bf11 /Lib/test/test_normalization.py
parent2c899ccffda92a7f3d4e7a01f14a666504db07b5 (diff)
downloadcpython-070ba85a8f45819d9197bce4541cd594d79d247c.zip
cpython-070ba85a8f45819d9197bce4541cd594d79d247c.tar.gz
cpython-070ba85a8f45819d9197bce4541cd594d79d247c.tar.bz2
[3.5] bpo-29887: Test normalization now fails if download fails (GH-905) (#2272)
* [3.5] bpo-29887: Test normalization now fails if download fails (GH-905) * test_normalization fails if download fails bpo-29887. The test is still skipped if "-u urlfetch" option is not passed to regrtest (python3 -m test -u urlfetch test_normalization). * Fix ResourceWarning in test_normalization bpo-29887: Fix ResourceWarning in test_normalization if tests are interrupted by CTRL+c. (cherry picked from commit 722a3af092b94983aa26f5e591fb1b45e2c2a0ff) * bpo-29887: test_normalization handles PermissionError (#1196) Skip test_normalization.test_main() if download raises a permission error. (cherry picked from commit d13d54748d3a7db023d9db37223ea7d40bb8f8e3) * no f-strings :(
Diffstat (limited to 'Lib/test/test_normalization.py')
-rw-r--r--Lib/test/test_normalization.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
index 30fa612..40d5894 100644
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -37,15 +37,23 @@ def unistr(data):
class NormalizationTest(unittest.TestCase):
def test_main(self):
- part = None
- part1_data = {}
# Hit the exception early
try:
testdata = open_urlresource(TESTDATAURL, encoding="utf-8",
check=check_version)
+ except PermissionError:
+ self.skipTest("Permission error when downloading %s "
+ "into the test data directory" % TESTDATAURL)
except (OSError, HTTPException):
- self.skipTest("Could not retrieve " + TESTDATAURL)
- self.addCleanup(testdata.close)
+ self.fail("Could not retrieve %s" % TESTDATAURL)
+
+ with testdata:
+ self.run_normalization_tests(testdata)
+
+ def run_normalization_tests(self, testdata):
+ part = None
+ part1_data = {}
+
for line in testdata:
if '#' in line:
line = line.split('#')[0]