| 2660 | |
| 2661 | @unittest.skipIf(multiprocessing is None, 'test requires multiprocessing') |
| 2662 | def test_regression_gh94675(self): |
| 2663 | pattern = re.compile(r'(?<=[({}])(((//[^\n]*)?[\n])([\000-\040])*)*' |
| 2664 | r'((/[^/\[\n]*(([^\n]|(\[\n]*(]*)*\]))' |
| 2665 | r'[^/\[]*)*/))((((//[^\n]*)?[\n])' |
| 2666 | r'([\000-\040]|(/\*[^*]*\*+' |
| 2667 | r'([^/*]\*+)*/))*)+(?=[^\000-\040);\]}]))') |
| 2668 | input_js = '''a(function() { |
| 2669 | /////////////////////////////////////////////////////////////////// |
| 2670 | });''' |
| 2671 | p = multiprocessing.Process(target=pattern.sub, args=('', input_js)) |
| 2672 | p.start() |
| 2673 | p.join(SHORT_TIMEOUT) |
| 2674 | try: |
| 2675 | self.assertFalse(p.is_alive(), 'pattern.sub() timed out') |
| 2676 | finally: |
| 2677 | if p.is_alive(): |
| 2678 | p.terminate() |
| 2679 | p.join() |
| 2680 | |
| 2681 | def test_fail(self): |
| 2682 | self.assertEqual(re.search(r'12(?!)|3', '123')[0], '3') |