Skip to content

Commit 51f40a8

Browse files
Mariattavstinner
authored andcommitted
[3.6] bpo-29887: Test normalization now fails if download fails (GH-905) (#2271)
* 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 722a3af)
1 parent ccc06d3 commit 51f40a8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Lib/test/test_normalization.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,20 @@ def unistr(data):
3636

3737
class NormalizationTest(unittest.TestCase):
3838
def test_main(self):
39-
part = None
40-
part1_data = {}
4139
# Hit the exception early
4240
try:
4341
testdata = open_urlresource(TESTDATAURL, encoding="utf-8",
4442
check=check_version)
4543
except (OSError, HTTPException):
46-
self.skipTest("Could not retrieve " + TESTDATAURL)
47-
self.addCleanup(testdata.close)
44+
self.fail(f"Could not retrieve {TESTDATAURL}")
45+
46+
with testdata:
47+
self.run_normalization_tests(testdata)
48+
49+
def run_normalization_tests(self, testdata):
50+
part = None
51+
part1_data = {}
52+
4853
for line in testdata:
4954
if '#' in line:
5055
line = line.split('#')[0]

0 commit comments

Comments
 (0)