7 class UserComponentTestCase(unittest
.TestCase
):
9 def _create_comp(comp_cls
, name
=None, log_level
=bt2
.LoggingLevel
.NONE
):
15 return graph
.add_component(comp_cls
, name
, logging_level
=log_level
)
18 class MySink(bt2
._UserSinkComponent
):
19 def __init__(comp_self
, params
):
20 self
.assertEqual(comp_self
.name
, 'yaes')
25 comp
= self
._create
_comp
(MySink
, 'yaes')
27 def test_logging_level(self
):
28 class MySink(bt2
._UserSinkComponent
):
29 def __init__(comp_self
, params
):
30 self
.assertEqual(comp_self
.logging_level
, bt2
.LoggingLevel
.INFO
)
35 comp
= self
._create
_comp
(MySink
, 'yaes', bt2
.LoggingLevel
.INFO
)
38 class MySink(bt2
._UserSinkComponent
):
39 def __init__(comp_self
, params
):
40 self
.assertEqual(comp_self
.cls
, MySink
)
45 self
._create
_comp
(MySink
)
48 class MySink(bt2
._UserSinkComponent
):
49 def __init__(comp_self
, params
):
50 self
.assertIsInstance(comp_self
.addr
, int)
51 self
.assertNotEqual(comp_self
.addr
, 0)
56 self
._create
_comp
(MySink
)
58 def test_finalize(self
):
61 class MySink(bt2
._UserSinkComponent
):
65 def _finalize(comp_self
):
70 comp
= graph
.add_component(MySink
, 'lel')
74 self
.assertTrue(finalized
)
77 class GenericComponentTestCase(unittest
.TestCase
):
79 def _create_comp(comp_cls
, name
=None, log_level
=bt2
.LoggingLevel
.NONE
):
85 return graph
.add_component(comp_cls
, name
, logging_level
=log_level
)
88 class MySink(bt2
._UserSinkComponent
):
92 comp
= self
._create
_comp
(MySink
, 'yaes')
93 self
.assertEqual(comp
.name
, 'yaes')
95 def test_logging_level(self
):
96 class MySink(bt2
._UserSinkComponent
):
100 comp
= self
._create
_comp
(MySink
, 'yaes', bt2
.LoggingLevel
.WARN
)
101 self
.assertEqual(comp
.logging_level
, bt2
.LoggingLevel
.WARN
)
103 def test_class(self
):
104 class MySink(bt2
._UserSinkComponent
):
108 comp
= self
._create
_comp
(MySink
)
109 self
.assertEqual(comp
.cls
, MySink
)
112 class MySink(bt2
._UserSinkComponent
):
116 comp
= self
._create
_comp
(MySink
)
117 self
.assertIsInstance(comp
.addr
, int)
118 self
.assertNotEqual(comp
.addr
, 0)
This page took 0.032654 seconds and 5 git commands to generate.