diff options
| author | Benjamin Peterson <benjamin@python.org> | 2011-07-08 18:39:56 (GMT) |
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2011-07-08 18:39:56 (GMT) |
| commit | 910789f10fb314fe7149be84aa57d6ec12ad4a7b (patch) | |
| tree | a658027493df6d758e5d0b802ffa72e66594ad1e /Lib/packaging/tests/test_util.py | |
| parent | ae10c0653e5469e7f41f12cee35bfe653a389cbc (diff) | |
| parent | 4a183b47f353a25b76aaaf1b7043458dbcab8890 (diff) | |
| download | cpython-910789f10fb314fe7149be84aa57d6ec12ad4a7b.zip cpython-910789f10fb314fe7149be84aa57d6ec12ad4a7b.tar.gz cpython-910789f10fb314fe7149be84aa57d6ec12ad4a7b.tar.bz2 | |
merge heads
Diffstat (limited to 'Lib/packaging/tests/test_util.py')
| -rw-r--r-- | Lib/packaging/tests/test_util.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Lib/packaging/tests/test_util.py b/Lib/packaging/tests/test_util.py index e3ccfd5..21ac4e2 100644 --- a/Lib/packaging/tests/test_util.py +++ b/Lib/packaging/tests/test_util.py @@ -19,7 +19,7 @@ from packaging.util import ( get_compiler_versions, _MAC_OS_X_LD_VERSION, byte_compile, find_packages, spawn, get_pypirc_path, generate_pypirc, read_pypirc, resolve_name, iglob, RICH_GLOB, egginfo_to_distinfo, is_setuptools, is_distutils, is_packaging, - get_install_method, cfg_to_args) + get_install_method, cfg_to_args, encode_multipart) PYPIRC = """\ @@ -54,6 +54,23 @@ username:tarek password:xxx """ +EXPECTED_MULTIPART_OUTPUT = [ + b'---x', + b'Content-Disposition: form-data; name="username"', + b'', + b'wok', + b'---x', + b'Content-Disposition: form-data; name="password"', + b'', + b'secret', + b'---x', + b'Content-Disposition: form-data; name="picture"; filename="wok.png"', + b'', + b'PNG89', + b'---x--', + b'', +] + class FakePopen: test_class = None @@ -525,6 +542,13 @@ class UtilTestCase(support.EnvironRestorer, self.assertEqual(args['scripts'], dist.scripts) self.assertEqual(args['py_modules'], dist.py_modules) + def test_encode_multipart(self): + fields = [('username', 'wok'), ('password', 'secret')] + files = [('picture', 'wok.png', b'PNG89')] + content_type, body = encode_multipart(fields, files, b'-x') + self.assertEqual(b'multipart/form-data; boundary=-x', content_type) + self.assertEqual(EXPECTED_MULTIPART_OUTPUT, body.split(b'\r\n')) + class GlobTestCaseBase(support.TempdirManager, support.LoggingCatcher, |
