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

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

Issue 19600: Use specific asserts in distutils tests
Patch Set: Created 5 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
OLDNEW
1 """Tests for distutils.util.""" 1 """Tests for distutils.util."""
2 import os 2 import os
3 import sys 3 import sys
4 import unittest 4 import unittest
5 from copy import copy 5 from copy import copy
6 from test.support import run_unittest 6 from test.support import run_unittest
7 7
8 from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError 8 from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError
9 from distutils.util import (get_platform, convert_path, change_root, 9 from distutils.util import (get_platform, convert_path, change_root,
10 check_environ, split_quoted, strtobool, 10 check_environ, split_quoted, strtobool,
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 ['one', 'two', 'three', 'four']) 259 ['one', 'two', 'three', 'four'])
260 260
261 def test_strtobool(self): 261 def test_strtobool(self):
262 yes = ('y', 'Y', 'yes', 'True', 't', 'true', 'True', 'On', 'on', '1') 262 yes = ('y', 'Y', 'yes', 'True', 't', 'true', 'True', 'On', 'on', '1')
263 no = ('n', 'no', 'f', 'false', 'off', '0', 'Off', 'No', 'N') 263 no = ('n', 'no', 'f', 'false', 'off', '0', 'Off', 'No', 'N')
264 264
265 for y in yes: 265 for y in yes:
266 self.assertTrue(strtobool(y)) 266 self.assertTrue(strtobool(y))
267 267
268 for n in no: 268 for n in no:
269 self.assertTrue(not strtobool(n)) 269 self.assertFalse(strtobool(n))
270 270
271 def test_rfc822_escape(self): 271 def test_rfc822_escape(self):
272 header = 'I am a\npoor\nlonesome\nheader\n' 272 header = 'I am a\npoor\nlonesome\nheader\n'
273 res = rfc822_escape(header) 273 res = rfc822_escape(header)
274 wanted = ('I am a%(8s)spoor%(8s)slonesome%(8s)s' 274 wanted = ('I am a%(8s)spoor%(8s)slonesome%(8s)s'
275 'header%(8s)s') % {'8s': '\n'+8*' '} 275 'header%(8s)s') % {'8s': '\n'+8*' '}
276 self.assertEqual(res, wanted) 276 self.assertEqual(res, wanted)
277 277
278 def test_dont_write_bytecode(self): 278 def test_dont_write_bytecode(self):
279 # makes sure byte_compile raise a DistutilsError 279 # makes sure byte_compile raise a DistutilsError
280 # if sys.dont_write_bytecode is True 280 # if sys.dont_write_bytecode is True
281 old_dont_write_bytecode = sys.dont_write_bytecode 281 old_dont_write_bytecode = sys.dont_write_bytecode
282 sys.dont_write_bytecode = True 282 sys.dont_write_bytecode = True
283 try: 283 try:
284 self.assertRaises(DistutilsByteCompileError, byte_compile, []) 284 self.assertRaises(DistutilsByteCompileError, byte_compile, [])
285 finally: 285 finally:
286 sys.dont_write_bytecode = old_dont_write_bytecode 286 sys.dont_write_bytecode = old_dont_write_bytecode
287 287
288 def test_suite(): 288 def test_suite():
289 return unittest.makeSuite(UtilTestCase) 289 return unittest.makeSuite(UtilTestCase)
290 290
291 if __name__ == "__main__": 291 if __name__ == "__main__":
292 run_unittest(test_suite()) 292 run_unittest(test_suite())
OLDNEW
« Lib/distutils/tests/test_clean.py ('K') | « Lib/distutils/tests/test_sysconfig.py ('k') | no next file » | no next file with comments »

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