(self, missing_as_none)
| 1155 | |
| 1156 | @support.subTests('missing_as_none', (False, True)) |
| 1157 | def test_anyscheme(self, missing_as_none): |
| 1158 | # Issue 7904: s3://foo.com/stuff has netloc "foo.com". |
| 1159 | none = None if missing_as_none else '' |
| 1160 | self.assertEqual(urlparse("s3://foo.com/stuff", missing_as_none=missing_as_none), |
| 1161 | ('s3', 'foo.com', '/stuff', none, none, none)) |
| 1162 | self.assertEqual(urlparse("x-newscheme://foo.com/stuff", missing_as_none=missing_as_none), |
| 1163 | ('x-newscheme', 'foo.com', '/stuff', none, none, none)) |
| 1164 | self.assertEqual(urlparse("x-newscheme://foo.com/stuff?query#fragment", missing_as_none=missing_as_none), |
| 1165 | ('x-newscheme', 'foo.com', '/stuff', none, 'query', 'fragment')) |
| 1166 | self.assertEqual(urlparse("x-newscheme://foo.com/stuff?query", missing_as_none=missing_as_none), |
| 1167 | ('x-newscheme', 'foo.com', '/stuff', none, 'query', none)) |
| 1168 | |
| 1169 | # And for bytes... |
| 1170 | none = None if missing_as_none else b'' |
| 1171 | self.assertEqual(urlparse(b"s3://foo.com/stuff", missing_as_none=missing_as_none), |
| 1172 | (b's3', b'foo.com', b'/stuff', none, none, none)) |
| 1173 | self.assertEqual(urlparse(b"x-newscheme://foo.com/stuff", missing_as_none=missing_as_none), |
| 1174 | (b'x-newscheme', b'foo.com', b'/stuff', none, none, none)) |
| 1175 | self.assertEqual(urlparse(b"x-newscheme://foo.com/stuff?query#fragment", missing_as_none=missing_as_none), |
| 1176 | (b'x-newscheme', b'foo.com', b'/stuff', none, b'query', b'fragment')) |
| 1177 | self.assertEqual(urlparse(b"x-newscheme://foo.com/stuff?query", missing_as_none=missing_as_none), |
| 1178 | (b'x-newscheme', b'foo.com', b'/stuff', none, b'query', none)) |
| 1179 | |
| 1180 | @support.subTests('func', (urllib.parse.urlparse, urllib.parse.urlsplit)) |
| 1181 | def test_default_scheme(self, func): |
nothing calls this directly
no test coverage detected