1 |
commit: 3a55ecd1f79c31f477d7bdd0b9f0e97d8a15eb9e |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed May 9 14:19:11 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed May 9 14:19:11 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3a55ecd1 |
7 |
|
8 |
DefaultEventLoopPolicy: test NotImplementedError due to recursion |
9 |
|
10 |
.../asyncio/test_policy_wrapper_recursion.py | 29 ++++++++++++++++++++++ |
11 |
1 file changed, 29 insertions(+) |
12 |
|
13 |
diff --git a/pym/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py b/pym/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py |
14 |
new file mode 100644 |
15 |
index 000000000..d3cd94b35 |
16 |
--- /dev/null |
17 |
+++ b/pym/portage/tests/util/futures/asyncio/test_policy_wrapper_recursion.py |
18 |
@@ -0,0 +1,29 @@ |
19 |
+# Copyright 2018 Gentoo Foundation |
20 |
+# Distributed under the terms of the GNU General Public License v2 |
21 |
+ |
22 |
+try: |
23 |
+ import asyncio |
24 |
+except ImportError: |
25 |
+ asyncio = None |
26 |
+ |
27 |
+from portage.tests import TestCase |
28 |
+from portage.util.futures.unix_events import DefaultEventLoopPolicy |
29 |
+ |
30 |
+ |
31 |
+class PolicyWrapperRecursionTestCase(TestCase): |
32 |
+ def testPolicyWrapperRecursion(self): |
33 |
+ if asyncio is None: |
34 |
+ self.skipTest('asyncio is not available') |
35 |
+ |
36 |
+ initial_policy = asyncio.get_event_loop_policy() |
37 |
+ if not isinstance(initial_policy, DefaultEventLoopPolicy): |
38 |
+ asyncio.set_event_loop_policy(DefaultEventLoopPolicy()) |
39 |
+ |
40 |
+ try: |
41 |
+ with self.assertRaises(NotImplementedError): |
42 |
+ asyncio.get_event_loop() |
43 |
+ |
44 |
+ with self.assertRaises(NotImplementedError): |
45 |
+ asyncio.get_child_watcher() |
46 |
+ finally: |
47 |
+ asyncio.set_event_loop_policy(initial_policy) |