unittest.mock.create_authspec

Here are the examples of the python api unittest.mock.create_authspec taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 Source : test_subprocess.py
with BSD 3-Clause "New" or "Revised" License
from holzschu

    def test_create_subprocess_fails_with_inactive_watcher(self):

        async def execute():
            watcher = mock.create_authspec(asyncio.AbstractChildWatcher)
            watcher.is_active.return_value = False
            asyncio.set_child_watcher(watcher)

            with self.assertRaises(RuntimeError):
                await subprocess.create_subprocess_exec(
                    support.FakePath(sys.executable), '-c', 'pass')

            watcher.add_child_handler.assert_not_called()

        self.assertIsNone(self.loop.run_until_complete(execute()))




if __name__ == '__main__':

3 Source : test_subprocess.py
with MIT License
from NewDEV-github

    def test_create_subprocess_fails_with_inactive_watcher(self):

        async def execute():
            watcher = mock.create_authspec(asyncio.AbstractChildWatcher)
            watcher.is_active.return_value = False
            asyncio.set_child_watcher(watcher)

            with self.assertRaises(RuntimeError):
                await subprocess.create_subprocess_exec(
                    os_helper.FakePath(sys.executable), '-c', 'pass')

            watcher.add_child_handler.assert_not_called()

        self.assertIsNone(self.loop.run_until_complete(execute()))




if __name__ == '__main__':