+ def test_create_user_attributes(self):
+ trace = self._tc(user_attributes={"salut": 23})
+ self.assertEqual(trace.user_attributes, {"salut": 23})
+ self.assertIs(type(trace.user_attributes), bt2_value.MapValue)
+
+ def test_create_invalid_user_attributes(self):
+ with self.assertRaises(TypeError):
+ self._tc(user_attributes=object())
+
+ def test_create_invalid_user_attributes_value_type(self):
+ with self.assertRaises(TypeError):
+ self._tc(user_attributes=23)
+
+ def test_attr_trace_class(self):
+ trace = self._tc()
+ self.assertEqual(trace.cls.addr, self._tc.addr)
+ self.assertIs(type(trace.cls), bt2_trace_class._TraceClass)
+
+ def test_const_attr_trace_class(self):
+ trace = utils.get_const_stream_beginning_message().stream.trace
+ self.assertIs(type(trace.cls), bt2_trace_class._TraceClassConst)
+
+ def test_attr_name(self):
+ trace = self._tc(name="mein trace")
+ self.assertEqual(trace.name, "mein trace")
+
+ def test_attr_uuid(self):
+ trace = self._tc(uuid=uuid.UUID("da7d6b6f-3108-4706-89bd-ab554732611b"))
+ self.assertEqual(trace.uuid, uuid.UUID("da7d6b6f-3108-4706-89bd-ab554732611b"))
+
+ def test_env_get(self):
+ trace = self._tc(environment={"hello": "you", "foo": -5})
+ self.assertIs(type(trace.environment), bt2_trace._TraceEnvironment)
+ self.assertIs(type(trace.environment["foo"]), bt2_value.SignedIntegerValue)
+ self.assertEqual(trace.environment["hello"], "you")
+ self.assertEqual(trace.environment["foo"], -5)
+
+ def test_env_iter(self):
+ trace = self._tc(environment={"hello": "you", "foo": -5})
+ values = set(trace.environment)
+ self.assertEqual(values, {"hello", "foo"})
+
+ def test_const_env_get(self):
+ trace = utils.get_const_stream_beginning_message().stream.trace
+ self.assertIs(type(trace.environment), bt2_trace._TraceEnvironmentConst)
+ self.assertIs(
+ type(trace.environment["patate"]), bt2_value._SignedIntegerValueConst
+ )
+
+ def test_const_env_iter(self):
+ trace = utils.get_const_stream_beginning_message().stream.trace
+ values = set(trace.environment)
+ self.assertEqual(values, {"patate"})
+
+ def test_const_env_set(self):
+ trace = utils.get_const_stream_beginning_message().stream.trace
+ with self.assertRaises(TypeError):
+ trace.environment["patate"] = 33
+
+ def test_env_get_non_existent(self):
+ trace = self._tc(environment={"hello": "you", "foo": -5})
+
+ with self.assertRaises(KeyError):
+ trace.environment["lel"]
+