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

Side by Side Diff: Lib/test/test_capi.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_base64.py ('k') | Lib/test/test_cmd_line.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 # Run the _testcapi module tests (tests for the Python/C API): by defn, 1 # Run the _testcapi module tests (tests for the Python/C API): by defn,
2 # these are all functions _testcapi exports whose name begins with 'test_'. 2 # these are all functions _testcapi exports whose name begins with 'test_'.
3 3
4 import os 4 import os
5 import pickle 5 import pickle
6 import random 6 import random
7 import subprocess 7 import subprocess
8 import sys 8 import sys
9 import textwrap 9 import textwrap
10 import time 10 import time
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 self.assertEqual(id(inst), inst.id()) 42 self.assertEqual(id(inst), inst.id())
43 self.assertTrue(inst.testfunction() is inst) 43 self.assertTrue(inst.testfunction() is inst)
44 self.assertEqual(inst.testfunction.__doc__, testfunction.__doc__) 44 self.assertEqual(inst.testfunction.__doc__, testfunction.__doc__)
45 self.assertEqual(InstanceMethod.testfunction.__doc__, testfunction.__doc __) 45 self.assertEqual(InstanceMethod.testfunction.__doc__, testfunction.__doc __)
46 46
47 InstanceMethod.testfunction.attribute = "test" 47 InstanceMethod.testfunction.attribute = "test"
48 self.assertEqual(testfunction.attribute, "test") 48 self.assertEqual(testfunction.attribute, "test")
49 self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute ", "test") 49 self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute ", "test")
50 50
51 @unittest.skipUnless(threading, 'Threading required for this test.') 51 @unittest.skipUnless(threading, 'Threading required for this test.')
52 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
52 def test_no_FatalError_infinite_loop(self): 53 def test_no_FatalError_infinite_loop(self):
53 with support.SuppressCrashReport(): 54 with support.SuppressCrashReport():
54 p = subprocess.Popen([sys.executable, "-c", 55 p = subprocess.Popen([sys.executable, "-c",
55 'import _testcapi;' 56 'import _testcapi;'
56 '_testcapi.crash_no_current_thread()'], 57 '_testcapi.crash_no_current_thread()'],
57 stdout=subprocess.PIPE, 58 stdout=subprocess.PIPE,
58 stderr=subprocess.PIPE) 59 stderr=subprocess.PIPE)
59 (out, err) = p.communicate() 60 (out, err) = p.communicate()
60 self.assertEqual(out, b'') 61 self.assertEqual(out, b'')
61 # This used to cause an infinite loop. 62 # This used to cause an infinite loop.
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 def test_parse_tuple_and_keywords(self): 514 def test_parse_tuple_and_keywords(self):
514 # parse_tuple_and_keywords error handling tests 515 # parse_tuple_and_keywords error handling tests
515 self.assertRaises(TypeError, _testcapi.parse_tuple_and_keywords, 516 self.assertRaises(TypeError, _testcapi.parse_tuple_and_keywords,
516 (), {}, 42, []) 517 (), {}, 42, [])
517 self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords, 518 self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords,
518 (), {}, b'', 42) 519 (), {}, b'', 42)
519 self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords, 520 self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords,
520 (), {}, b'', [''] * 42) 521 (), {}, b'', [''] * 42)
521 self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords, 522 self.assertRaises(ValueError, _testcapi.parse_tuple_and_keywords,
522 (), {}, b'', [42]) 523 (), {}, b'', [42])
524
523 525
524 @unittest.skipUnless(threading, 'Threading required for this test.') 526 @unittest.skipUnless(threading, 'Threading required for this test.')
525 class TestThreadState(unittest.TestCase): 527 class TestThreadState(unittest.TestCase):
526 528
527 @support.reap_threads 529 @support.reap_threads
528 def test_thread_state(self): 530 def test_thread_state(self):
529 # some extra thread-state tests driven via _testcapi 531 # some extra thread-state tests driven via _testcapi
530 def target(): 532 def target():
531 idents = [] 533 idents = []
532 534
(...skipping 15 matching lines...) Expand all
548 class Test_testcapi(unittest.TestCase): 550 class Test_testcapi(unittest.TestCase):
549 def test__testcapi(self): 551 def test__testcapi(self):
550 for name in dir(_testcapi): 552 for name in dir(_testcapi):
551 if name.startswith('test_'): 553 if name.startswith('test_'):
552 with self.subTest("internal", name=name): 554 with self.subTest("internal", name=name):
553 test = getattr(_testcapi, name) 555 test = getattr(_testcapi, name)
554 test() 556 test()
555 557
556 if __name__ == "__main__": 558 if __name__ == "__main__":
557 unittest.main() 559 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_base64.py ('k') | Lib/test/test_cmd_line.py » ('j') | no next file with comments »

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