Exemple #1
0
 def test_close_opened_files_on_error(self):
     non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata')
     with check_no_resource_warning(self):
         with self.assertRaises(aifc.Error):
             # Try opening a non-AIFC file, with the expectation that
             # `aifc.open` will fail (without raising a ResourceWarning)
             f = self.f = aifc.open(non_aifc_file, 'rb')
 def test_close_opened_files_on_error(self):
     non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata')
     with check_no_resource_warning(self):
         with self.assertRaises(aifc.Error):
             self.f = aifc.open(non_aifc_file, 'rb')
         with mock.patch.object(aifc.Aifc_write,
                                'initfp',
                                side_effect=RuntimeError):
             with self.assertRaises(RuntimeError):
                 self.fout = aifc.open(TESTFN, 'wb')
    def test_close_opened_files_on_error(self):
        non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata')
        with check_no_resource_warning(self):
            with self.assertRaises(aifc.Error):
                # Try opening a non-AIFC file, with the expectation that
                # `aifc.open` will fail (without raising a ResourceWarning)
                self.f = aifc.open(non_aifc_file, 'rb')

            # Aifc_write.initfp() won't raise in normal case.  But some errors
            # (e.g. MemoryError, KeyboardInterrupt, etc..) can happen.
            with mock.patch.object(aifc.Aifc_write, 'initfp',
                                   side_effect=RuntimeError):
                with self.assertRaises(RuntimeError):
                    self.fout = aifc.open(TESTFN, 'wb')
Exemple #4
0
    def test_close_opened_files_on_error(self):
        non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata')
        with check_no_resource_warning(self):
            with self.assertRaises(aifc.Error):
                # Try opening a non-AIFC file, with the expectation that
                # `aifc.open` will fail (without raising a ResourceWarning)
                self.f = aifc.open(non_aifc_file, 'rb')

            # Aifc_write.initfp() won't raise in normal case.  But some errors
            # (e.g. MemoryError, KeyboardInterrupt, etc..) can happen.
            with mock.patch.object(aifc.Aifc_write, 'initfp',
                                   side_effect=RuntimeError):
                with self.assertRaises(RuntimeError):
                    self.fout = aifc.open(TESTFN, 'wb')
Exemple #5
0
    def test_popen_error(self):
        # Issue #24763: check that the subprocess transport is closed
        # when BaseSubprocessTransport fails
        if sys.platform == "win32":
            target = "asyncio.windows_utils.Popen"
        else:
            target = "subprocess.Popen"
        with mock.patch(target) as popen:
            exc = ZeroDivisionError
            popen.side_effect = exc

            create = asyncio.create_subprocess_exec(sys.executable, "-c", "pass", loop=self.loop)
            with support.check_no_resource_warning(self):
                with self.assertRaises(exc):
                    self.loop.run_until_complete(create)
Exemple #6
0
    def test_popen_error(self):
        # Issue #24763: check that the subprocess transport is closed
        # when BaseSubprocessTransport fails
        if sys.platform == 'win32':
            target = 'asyncio.windows_utils.Popen'
        else:
            target = 'subprocess.Popen'
        with mock.patch(target) as popen:
            exc = ZeroDivisionError
            popen.side_effect = exc

            create = asyncio.create_subprocess_exec(sys.executable, '-c',
                                                    'pass', loop=self.loop)
            with support.check_no_resource_warning(self):
                with self.assertRaises(exc):
                    self.loop.run_until_complete(create)