-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathdtrace_cython_test.py
More file actions
64 lines (48 loc) · 1.23 KB
/
Copy pathdtrace_cython_test.py
File metadata and controls
64 lines (48 loc) · 1.23 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Unittest for cython based consumer.
"""
__author__ = 'tmetsch'
import unittest
import dtrace
SCRIPT = 'dtrace:::BEGIN {trace("Hello World");}'
class TestDTraceConsumer(unittest.TestCase):
"""
Test DTrace consumer.
"""
def setUp(self):
self.out = ''
self.consumer = dtrace.DTraceConsumer(out_func=self._get_output)
# Test fo success.
def test_compile_for_success(self):
"""
Test for success.
"""
self.consumer.compile(SCRIPT)
def test_run_for_success(self):
"""
Test for success.
"""
self.consumer.run(SCRIPT)
# Test fo failure.
def test_compile_for_failure(self):
"""
Test for failure.
"""
self.assertRaises(Exception, self.consumer.compile, 'foo')
def test_run_for_failure(self):
"""
Test for failure.
"""
self.assertRaises(Exception, self.consumer.run, 'sadf')
# Test fo sanity.
def test_run_for_sanity(self):
"""
Test for sanity.
"""
self.consumer.run(SCRIPT)
self.assertEqual(b'Hello World', self.out)
def _get_output(self, tmp):
"""
Test for sanity.
"""
self.out = tmp