mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Revert 1.170. Add tests.
This commit is contained in:
		
							parent
							
								
									803ce801ab
								
							
						
					
					
						commit
						2bdec7bfb0
					
				
					 2 changed files with 12 additions and 3 deletions
				
			
		|  | @ -353,6 +353,12 @@ def test_quoting_space(self): | ||||||
|         self.assertEqual(expect, result, |         self.assertEqual(expect, result, | ||||||
|                          "using quote_plus(): %s != %s" % (expect, result)) |                          "using quote_plus(): %s != %s" % (expect, result)) | ||||||
| 
 | 
 | ||||||
|  |     def test_quoting_plus(self): | ||||||
|  |         self.assertEqual(urllib.quote_plus('alpha+beta gamma'), | ||||||
|  |                          'alpha%2Bbeta+gamma') | ||||||
|  |         self.assertEqual(urllib.quote_plus('alpha+beta gamma', '+'), | ||||||
|  |                          'alpha+beta+gamma') | ||||||
|  | 
 | ||||||
| class UnquotingTests(unittest.TestCase): | class UnquotingTests(unittest.TestCase): | ||||||
|     """Tests for unquote() and unquote_plus() |     """Tests for unquote() and unquote_plus() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1110,8 +1110,11 @@ def quote(s, safe = '/'): | ||||||
| def quote_plus(s, safe = ''): | def quote_plus(s, safe = ''): | ||||||
|     """Quote the query fragment of a URL; replacing ' ' with '+'""" |     """Quote the query fragment of a URL; replacing ' ' with '+'""" | ||||||
|     if ' ' in s: |     if ' ' in s: | ||||||
|         s = s.replace(' ', '+') |         l = s.split(' ') | ||||||
|         safe += '+' |         for i in range(len(l)): | ||||||
|  |             l[i] = quote(l[i], safe) | ||||||
|  |         return '+'.join(l) | ||||||
|  |     else: | ||||||
|         return quote(s, safe) |         return quote(s, safe) | ||||||
| 
 | 
 | ||||||
| def urlencode(query,doseq=0): | def urlencode(query,doseq=0): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Raymond Hettinger
						Raymond Hettinger