Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Side by Side Diff: Lib/packaging/tests/test_util.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/packaging/tests/test_uninstall.py ('k') | Lib/packaging/util.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Tests for packaging.util.""" 1 """Tests for packaging.util."""
2 import os 2 import os
3 import sys 3 import sys
4 import time 4 import time
5 import logging 5 import logging
6 import tempfile 6 import tempfile
7 import subprocess 7 import subprocess
8 from io import StringIO 8 from io import StringIO
9 9
10 from packaging.tests import support, unittest 10 from packaging.tests import support, unittest
11 from packaging.tests.test_config import SETUP_CFG 11 from packaging.tests.test_config import SETUP_CFG
12 from packaging.errors import ( 12 from packaging.errors import (
13 PackagingPlatformError, PackagingByteCompileError, PackagingFileError, 13 PackagingPlatformError, PackagingByteCompileError, PackagingFileError,
14 PackagingExecError, InstallationException) 14 PackagingExecError, InstallationException)
15 from packaging import util 15 from packaging import util
16 from packaging.dist import Distribution 16 from packaging.dist import Distribution
17 from packaging.util import ( 17 from packaging.util import (
18 convert_path, change_root, split_quoted, strtobool, rfc822_escape, 18 convert_path, change_root, split_quoted, strtobool, rfc822_escape,
19 get_compiler_versions, _MAC_OS_X_LD_VERSION, byte_compile, find_packages, 19 get_compiler_versions, _MAC_OS_X_LD_VERSION, byte_compile, find_packages,
20 spawn, get_pypirc_path, generate_pypirc, read_pypirc, resolve_name, iglob, 20 spawn, get_pypirc_path, generate_pypirc, read_pypirc, resolve_name, iglob,
21 RICH_GLOB, egginfo_to_distinfo, is_setuptools, is_distutils, is_packaging, 21 RICH_GLOB, egginfo_to_distinfo, is_setuptools, is_distutils, is_packaging,
22 get_install_method, cfg_to_args, encode_multipart) 22 get_install_method, cfg_to_args)
23 23
24 24
25 PYPIRC = """\ 25 PYPIRC = """\
26 [distutils] 26 [distutils]
27 index-servers = 27 index-servers =
28 pypi 28 pypi
29 server1 29 server1
30 30
31 [pypi] 31 [pypi]
32 username:me 32 username:me
(...skipping 13 matching lines...) Expand all
46 46
47 WANTED = """\ 47 WANTED = """\
48 [distutils] 48 [distutils]
49 index-servers = 49 index-servers =
50 pypi 50 pypi
51 51
52 [pypi] 52 [pypi]
53 username:tarek 53 username:tarek
54 password:xxx 54 password:xxx
55 """ 55 """
56
57 EXPECTED_MULTIPART_OUTPUT = [
58 b'---x',
59 b'Content-Disposition: form-data; name="username"',
60 b'',
61 b'wok',
62 b'---x',
63 b'Content-Disposition: form-data; name="password"',
64 b'',
65 b'secret',
66 b'---x',
67 b'Content-Disposition: form-data; name="picture"; filename="wok.png"',
68 b'',
69 b'PNG89',
70 b'---x--',
71 b'',
72 ]
73 56
74 57
75 class FakePopen: 58 class FakePopen:
76 test_class = None 59 test_class = None
77 60
78 def __init__(self, args, bufsize=0, executable=None, 61 def __init__(self, args, bufsize=0, executable=None,
79 stdin=None, stdout=None, stderr=None, 62 stdin=None, stdout=None, stderr=None,
80 preexec_fn=None, close_fds=False, 63 preexec_fn=None, close_fds=False,
81 shell=False, cwd=None, env=None, universal_newlines=False, 64 shell=False, cwd=None, env=None, universal_newlines=False,
82 startupinfo=None, creationflags=0, 65 startupinfo=None, creationflags=0,
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 self.assertEqual(args['description'], metadata['Summary']) 517 self.assertEqual(args['description'], metadata['Summary'])
535 self.assertEqual(args['long_description'], metadata['Description']) 518 self.assertEqual(args['long_description'], metadata['Description'])
536 self.assertEqual(args['classifiers'], metadata['Classifier']) 519 self.assertEqual(args['classifiers'], metadata['Classifier'])
537 self.assertEqual(args['requires'], metadata['Requires-Dist']) 520 self.assertEqual(args['requires'], metadata['Requires-Dist'])
538 self.assertEqual(args['provides'], metadata['Provides-Dist']) 521 self.assertEqual(args['provides'], metadata['Provides-Dist'])
539 522
540 self.assertEqual(args['package_dir'].get(''), dist.package_dir) 523 self.assertEqual(args['package_dir'].get(''), dist.package_dir)
541 self.assertEqual(args['packages'], dist.packages) 524 self.assertEqual(args['packages'], dist.packages)
542 self.assertEqual(args['scripts'], dist.scripts) 525 self.assertEqual(args['scripts'], dist.scripts)
543 self.assertEqual(args['py_modules'], dist.py_modules) 526 self.assertEqual(args['py_modules'], dist.py_modules)
544
545 def test_encode_multipart(self):
546 fields = [('username', 'wok'), ('password', 'secret')]
547 files = [('picture', 'wok.png', b'PNG89')]
548 content_type, body = encode_multipart(fields, files, b'-x')
549 self.assertEqual(b'multipart/form-data; boundary=-x', content_type)
550 self.assertEqual(EXPECTED_MULTIPART_OUTPUT, body.split(b'\r\n'))
551 527
552 528
553 class GlobTestCaseBase(support.TempdirManager, 529 class GlobTestCaseBase(support.TempdirManager,
554 support.LoggingCatcher, 530 support.LoggingCatcher,
555 unittest.TestCase): 531 unittest.TestCase):
556 532
557 def build_files_tree(self, files): 533 def build_files_tree(self, files):
558 tempdir = self.mkdtemp() 534 tempdir = self.mkdtemp()
559 for filepath in files: 535 for filepath in files:
560 is_dir = filepath.endswith('/') 536 is_dir = filepath.endswith('/')
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 def test_suite(): 966 def test_suite():
991 suite = unittest.makeSuite(UtilTestCase) 967 suite = unittest.makeSuite(UtilTestCase)
992 suite.addTest(unittest.makeSuite(GlobTestCase)) 968 suite.addTest(unittest.makeSuite(GlobTestCase))
993 suite.addTest(unittest.makeSuite(EggInfoToDistInfoTestCase)) 969 suite.addTest(unittest.makeSuite(EggInfoToDistInfoTestCase))
994 suite.addTest(unittest.makeSuite(PackagingLibChecks)) 970 suite.addTest(unittest.makeSuite(PackagingLibChecks))
995 return suite 971 return suite
996 972
997 973
998 if __name__ == "__main__": 974 if __name__ == "__main__":
999 unittest.main(defaultTest="test_suite") 975 unittest.main(defaultTest="test_suite")
OLDNEW
« no previous file with comments | « Lib/packaging/tests/test_uninstall.py ('k') | Lib/packaging/util.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+