[pygobject/benzea/gio-asyncio] test



commit b9cac956f9042527cc9754918b12844966913d8a
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Nov 17 15:06:15 2021 +0100

    test

 tests/test_events.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
---
diff --git a/tests/test_events.py b/tests/test_events.py
index f87f030c..07a7f967 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -37,6 +37,32 @@ if sys.platform != 'win32':
 
     class SubprocessWatcherTests(SubprocessMixin, test_utils.TestCase):
 
+        async def _test_popen_error(self, stdin):
+            from unittest import mock
+            import warnings
+            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
+
+                with warnings.catch_warnings(record=True) as warns:
+                    with self.assertRaises(exc):
+                        await asyncio.create_subprocess_exec(
+                            sys.executable,
+                            '-c',
+                            'pass',
+                            stdin=stdin
+                        )
+                    if warns:
+                        print(warns)
+                        print(warns[0])
+                        print(str(warns[0]))
+
+                    self.assertEqual(warns, [])
+
         def setUp(self):
             super().setUp()
             policy = gi.events.EventLoopPolicy()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]