Skip to content

Commit

Permalink
bpo-29887: Test normalization now fails if download fails (python#905)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
vstinner authored Mar 30, 2017
1 parent f15c4d3 commit 722a3af
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Lib/test/test_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 722a3af

Please sign in to comment.