diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-03-30 15:06:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-30 15:06:53 (GMT) |
commit | 722a3af092b94983aa26f5e591fb1b45e2c2a0ff (patch) | |
tree | 172e680ca202d69d341db1e6cce10288d4f1dc81 | |
parent | f15c4d374a07c576c0e8349b16604f6dbad0b953 (diff) | |
download | cpython-722a3af092b94983aa26f5e591fb1b45e2c2a0ff.zip cpython-722a3af092b94983aa26f5e591fb1b45e2c2a0ff.tar.gz cpython-722a3af092b94983aa26f5e591fb1b45e2c2a0ff.tar.bz2 |
bpo-29887: Test normalization now fails if download fails (#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.
-rw-r--r-- | Lib/test/test_normalization.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py index 5b590e1..c6f8c93 100644 --- a/Lib/test/test_normalization.py +++ b/Lib/test/test_normalization.py @@ -36,15 +36,20 @@ 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 (OSError, HTTPException): - self.skipTest("Could not retrieve " + TESTDATAURL) - self.addCleanup(testdata.close) + self.fail(f"Could not retrieve {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] |