import sys import unittest import audioop import socket import _ctypes import itertools import _overlapped import _io USAGE_STR = 'python_d.exe testBugsOrPatches.py bugs|patches' class BugsOrPatchesTester(unittest.TestCase): ##### begin Modules/audioop.c tests def test_ratecv(self): # test a call to PyArg_ParseTuple in audioop_ratecv_impl with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): audioop.ratecv(b'a', 1, 1, 1, 1, (1, (tuple(),))) def test_lin2adpcm(self): # test a call to PyArg_ParseTuple in audioop_lin2adpcm_impl with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): audioop.lin2adpcm(b'a', 1, tuple()) def test_adpcm2lin(self): # test a call to PyArg_ParseTuple in audioop_adpcm2lin_impl with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): audioop.adpcm2lin(b'a', 1, tuple()) ##### end Modules/audioop.c tests ##### begin Modules/itertoolsmodule.c tests def test_groupby__setstate__(self): groupbyObj = itertools.groupby([]) # test a call to PyArg_ParseTuple in groupby_setstate with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): groupbyObj.__setstate__(tuple()) def test_tee__setstate__(self): teeObj = itertools._tee([]) # test a call to PyArg_ParseTuple in tee_setstate with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): teeObj.__setstate__(tuple()) def test_cycle__setstate__(self): cycleObj = itertools.cycle([]) # test a call to PyArg_ParseTuple in cycle_setstate with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): cycleObj.__setstate__(tuple()) def test_chain__setstate__(self): chainObj = itertools.chain([]) # test a call to PyArg_ParseTuple in chain_setstate with self.assertRaisesRegex(TypeError, TAKES_AT_LEAST_OR_ILLEGAL_REGEX): chainObj.__setstate__(tuple()) def test_permutations__setstate__(self): permsObj = itertools.permutations([]) # test a call to PyArg_ParseTuple in permutations_setstate with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): permsObj.__setstate__(tuple()) ##### end Modules/itertoolsmodule.c tests ##### begin Modules/overlapped.c tests def test_Overlapped_ConnectEx(self): overlappedObj = _overlapped.Overlapped() # test a call to PyArg_ParseTuple in parse_address with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): overlappedObj.ConnectEx(1, tuple()) ##### end Modules/overlapped.c tests ##### begin Modules/socketmodule.c tests def test_getnameinfo(self): # test a call to PyArg_ParseTuple in socket_getnameinfo with self.assertRaisesRegex(TypeError, TAKES_AT_LEAST_OR_ILLEGAL_REGEX): socket.getnameinfo(tuple(), 1) ##### end Modules/socketmodule.c tests ##### begin Modules/_ctypes/_ctypes.c tests def test_PyCFuncPtr__new__(self): # test a call to PyArg_ParseTuple in PyCFuncPtr_FromDll with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): _ctypes.CFuncPtr(tuple()) ##### end Modules/_ctypes/_ctypes.c tests ##### begin Modules/_io/textio.c tests def test_IncrementalNewlineDecoder_setstate(self): decoder = _io.IncrementalNewlineDecoder(1, 1) # test a call to PyArg_ParseTuple in # _io_IncrementalNewlineDecoder_setstate with self.assertRaisesRegex(TypeError, TAKES_EXACTLY_OR_ILLEGAL_REGEX): decoder.setstate(tuple()) ##### end Modules/_io/textio.c tests if __name__ == '__main__': try: _, bugsOrPatches = sys.argv except ValueError: print(USAGE_STR) exit() if bugsOrPatches == 'bugs': TAKES_EXACTLY_OR_ILLEGAL_REGEX = (r'^(function|\w+\(\)) takes exactly ' r'\d arguments? \(0 given\)$') TAKES_AT_LEAST_OR_ILLEGAL_REGEX = (r'^(function|\w+\(\)) takes at ' r'least \d arguments? \(0 given\)$') elif bugsOrPatches == 'patches': TAKES_EXACTLY_OR_ILLEGAL_REGEX = TAKES_AT_LEAST_OR_ILLEGAL_REGEX = ( r'^.+: illegal .+ argument$') else: print(USAGE_STR) exit() unittest.main(argv=sys.argv[:1])