X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tests%2Fbindings%2Fpython%2Fbt2%2Ftest_trace_class.py;h=2ad8300147b691b6bbe728c6f39d019fbca6c74b;hb=f3c9a159782f70dbd0e5dedb37e4a1ef8a6d304e;hp=265b0de8b40ed8ac0604216688235a870a7a8a95;hpb=fbbe93021d7cd3793003911931bb3abd5e69596a;p=babeltrace.git diff --git a/tests/bindings/python/bt2/test_trace_class.py b/tests/bindings/python/bt2/test_trace_class.py index 265b0de8..2ad83001 100644 --- a/tests/bindings/python/bt2/test_trace_class.py +++ b/tests/bindings/python/bt2/test_trace_class.py @@ -1,11 +1,27 @@ -import uuid +# +# Copyright (C) 2019 EfficiOS Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; only version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + import unittest import bt2 from utils import run_in_component_init, get_default_trace_class class TraceClassTestCase(unittest.TestCase): - def test_create_default(self): def f(comp_self): return comp_self._create_trace_class() @@ -13,18 +29,8 @@ class TraceClassTestCase(unittest.TestCase): tc = run_in_component_init(f) self.assertEqual(len(tc), 0) - self.assertEqual(len(tc.env), 0) - self.assertIsNone(tc.uuid) self.assertTrue(tc.assigns_automatic_stream_class_id) - def test_uuid(self): - def f(comp_self): - return comp_self._create_trace_class(uuid=uuid.UUID('da7d6b6f-3108-4706-89bd-ab554732611b')) - - tc = run_in_component_init(f) - - self.assertEqual(tc.uuid, uuid.UUID('da7d6b6f-3108-4706-89bd-ab554732611b')) - def test_automatic_stream_class_id(self): def f(comp_self): return comp_self._create_trace_class(assigns_automatic_stream_class_id=True) @@ -45,12 +51,14 @@ class TraceClassTestCase(unittest.TestCase): tc = run_in_component_init(f) self.assertTrue(tc.assigns_automatic_stream_class_id) - with self.assertRaises(bt2.CreationError): + with self.assertRaises(ValueError): sc1 = tc.create_stream_class(23) def test_no_assigns_automatic_stream_class_id(self): def f(comp_self): - return comp_self._create_trace_class(assigns_automatic_stream_class_id=False) + return comp_self._create_trace_class( + assigns_automatic_stream_class_id=False + ) tc = run_in_component_init(f) self.assertFalse(tc.assigns_automatic_stream_class_id) @@ -60,37 +68,23 @@ class TraceClassTestCase(unittest.TestCase): def test_no_assigns_automatic_stream_class_id_raises(self): def f(comp_self): - return comp_self._create_trace_class(assigns_automatic_stream_class_id=False) + return comp_self._create_trace_class( + assigns_automatic_stream_class_id=False + ) tc = run_in_component_init(f) self.assertFalse(tc.assigns_automatic_stream_class_id) # In this mode, it is required to pass an explicit id. - with self.assertRaises(bt2.CreationError): + with self.assertRaises(ValueError): tc.create_stream_class() - def test_env_get(self): - def f(comp_self): - return comp_self._create_trace_class(env={'hello': 'you', 'foo': -5}) - - tc = run_in_component_init(f) - - self.assertEqual(tc.env['hello'], 'you') - self.assertEqual(tc.env['foo'], -5) - - def test_env_get_non_existent(self): - def f(comp_self): - return comp_self._create_trace_class(env={'hello': 'you', 'foo': -5}) - - tc = run_in_component_init(f) - - with self.assertRaises(KeyError): - tc.env['lel'] - @staticmethod def _create_trace_class_with_some_stream_classes(): def f(comp_self): - return comp_self._create_trace_class(assigns_automatic_stream_class_id=False) + return comp_self._create_trace_class( + assigns_automatic_stream_class_id=False + ) tc = run_in_component_init(f) sc1 = tc.create_stream_class(id=12) @@ -122,8 +116,6 @@ class TraceClassTestCase(unittest.TestCase): tc, sc1, sc2, sc3 = self._create_trace_class_with_some_stream_classes() for sc_id, stream_class in tc.items(): - self.assertIsInstance(stream_class, bt2.stream_class.StreamClass) - if sc_id == 12: self.assertEqual(stream_class.addr, sc1.addr) elif sc_id == 54: