aboutsummaryrefslogtreecommitdiff
blob: d3cd94b351fb987f537c2d7928294ab15d825bc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright 2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

try:
	import asyncio
except ImportError:
	asyncio = None

from portage.tests import TestCase
from portage.util.futures.unix_events import DefaultEventLoopPolicy


class PolicyWrapperRecursionTestCase(TestCase):
	def testPolicyWrapperRecursion(self):
		if asyncio is None:
			self.skipTest('asyncio is not available')

		initial_policy = asyncio.get_event_loop_policy()
		if not isinstance(initial_policy, DefaultEventLoopPolicy):
			asyncio.set_event_loop_policy(DefaultEventLoopPolicy())

		try:
			with self.assertRaises(NotImplementedError):
				asyncio.get_event_loop()

			with self.assertRaises(NotImplementedError):
				asyncio.get_child_watcher()
		finally:
			asyncio.set_event_loop_policy(initial_policy)