-
Notifications
You must be signed in to change notification settings - Fork 39
/
test_Locker.py
41 lines (26 loc) · 1.15 KB
/
test_Locker.py
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
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import STPyV8
class TestLocker(unittest.TestCase):
def testLocker(self):
with STPyV8.JSIsolate():
self.assertFalse(STPyV8.JSLocker.locked)
with STPyV8.JSLocker() as outter_locker:
self.assertTrue(STPyV8.JSLocker.locked)
self.assertTrue(outter_locker)
with STPyV8.JSLocker() as inner_locker:
self.assertTrue(STPyV8.JSLocker.locked)
self.assertTrue(outter_locker)
self.assertTrue(inner_locker)
with STPyV8.JSUnlocker():
self.assertFalse(STPyV8.JSLocker.locked)
self.assertTrue(outter_locker)
self.assertTrue(inner_locker)
self.assertTrue(STPyV8.JSLocker.locked)
self.assertFalse(STPyV8.JSLocker.locked)
locker = STPyV8.JSLocker()
with STPyV8.JSContext():
self.assertRaises(RuntimeError, locker.__enter__)
self.assertRaises(RuntimeError, locker.__exit__, None, None, None)
del locker