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

Side by Side Diff: Lib/test/test_mailcap.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 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/test/test_logging.py ('k') | Lib/test/test_marshal.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 import mailcap 1 import mailcap
2 import os 2 import os
3 import shutil 3 import shutil
4 import sys
4 import test.support 5 import test.support
5 import unittest 6 import unittest
6 7
7 # Location of mailcap file 8 # Location of mailcap file
8 MAILCAPFILE = test.support.findfile("mailcap.txt") 9 MAILCAPFILE = test.support.findfile("mailcap.txt")
9 10
10 # Dict to act as mock mailcap entry for this test 11 # Dict to act as mock mailcap entry for this test
11 # The keys and values should match the contents of MAILCAPFILE 12 # The keys and values should match the contents of MAILCAPFILE
12 MAILCAPDICT = { 13 MAILCAPDICT = {
13 'application/x-movie': 14 'application/x-movie':
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 ('"An audio fragment"', audio_basic_entry)), 184 ('"An audio fragment"', audio_basic_entry)),
184 ([c, "audio/*"], 185 ([c, "audio/*"],
185 {"filename": fname}, 186 {"filename": fname},
186 ("/usr/local/bin/showaudio audio/*", audio_entry)), 187 ("/usr/local/bin/showaudio audio/*", audio_entry)),
187 ([c, "message/external-body"], 188 ([c, "message/external-body"],
188 {"plist": plist}, 189 {"plist": plist},
189 ("showexternal /dev/null default john python.org /tmp foo bar", message_entry)) 190 ("showexternal /dev/null default john python.org /tmp foo bar", message_entry))
190 ] 191 ]
191 self._run_cases(cases) 192 self._run_cases(cases)
192 193
193 @unittest.skipUnless(os.name == "posix", "Requires 'test' command on system" ) 194 @unittest.skipUnless(os.name == "posix" and sys.platform != 'ios', "Requires 'test' command on system")
194 def test_test(self): 195 def test_test(self):
195 # findmatch() will automatically check any "test" conditions and skip 196 # findmatch() will automatically check any "test" conditions and skip
196 # the entry if the check fails. 197 # the entry if the check fails.
197 caps = {"test/pass": [{"test": "test 1 -eq 1"}], 198 caps = {"test/pass": [{"test": "test 1 -eq 1"}],
198 "test/fail": [{"test": "test 1 -eq 0"}]} 199 "test/fail": [{"test": "test 1 -eq 0"}]}
199 # test case: (findmatch args, findmatch keyword args, expected output) 200 # test case: (findmatch args, findmatch keyword args, expected output)
200 # positional args: caps, MIMEtype, key ("test") 201 # positional args: caps, MIMEtype, key ("test")
201 # keyword args: N/A 202 # keyword args: N/A
202 # output: (command line, mailcap entry) 203 # output: (command line, mailcap entry)
203 cases = [ 204 cases = [
204 # findmatch will return the mailcap entry for test/pass because it e valuates to true 205 # findmatch will return the mailcap entry for test/pass because it e valuates to true
205 ([caps, "test/pass", "test"], {}, ("test 1 -eq 1", {"test": "test 1 -eq 1"})), 206 ([caps, "test/pass", "test"], {}, ("test 1 -eq 1", {"test": "test 1 -eq 1"})),
206 # findmatch will return None because test/fail evaluates to false 207 # findmatch will return None because test/fail evaluates to false
207 ([caps, "test/fail", "test"], {}, (None, None)) 208 ([caps, "test/fail", "test"], {}, (None, None))
208 ] 209 ]
209 self._run_cases(cases) 210 self._run_cases(cases)
210 211
211 def _run_cases(self, cases): 212 def _run_cases(self, cases):
212 for c in cases: 213 for c in cases:
213 self.assertEqual(mailcap.findmatch(*c[0], **c[1]), c[2]) 214 self.assertEqual(mailcap.findmatch(*c[0], **c[1]), c[2])
214 215
215 216
216 if __name__ == '__main__': 217 if __name__ == '__main__':
217 unittest.main() 218 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_logging.py ('k') | Lib/test/test_marshal.py » ('j') | no next file with comments »

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