Skip to content

Commit 426bb6c

Browse files
committed
Add a test case for mimetypes checking file URLs
Add two checks for file URLs, and remove a vestigial line from a nearby test.
1 parent 9652321 commit 426bb6c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎Lib/test/test_mimetypes.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ def test_filename_with_url_delimiters(self):
457457
eq(self.db.guess_type(r'scheme:foo\.tar.gz'), gzip_expected)
458458

459459
def test_url(self):
460-
result = self.db.guess_type('http://example.com/host.html')
461460
result = self.db.guess_type('http://host.html')
462461
msg = 'URL only has a host name, not a file'
463462
self.assertSequenceEqual(result, (None, None), msg)
@@ -469,6 +468,13 @@ def test_url(self):
469468
result = self.db.guess_type('http://example.com/host.html?q=x.tar')
470469
self.assertSequenceEqual(result, ('text/html', None))
471470

471+
def test_file_url(self):
472+
result = self.db.guess_type('file:///a/b/c/file.txt')
473+
self.assertSequenceEqual(result, ('text/plain', None))
474+
# a local path URL which looks a bit like a netloc
475+
result = self.db.guess_type('file:///host.html')
476+
self.assertSequenceEqual(result, ('text/html', None))
477+
472478
def test_guess_all_types(self):
473479
# First try strict. Use a set here for testing the results because if
474480
# test_urllib2 is run before test_mimetypes, global state is modified

0 commit comments

Comments
 (0)