def test_method_from_string(self): state = Tracestate() state.from_string('foo=1') state.from_string('bar=2') state.from_string('baz=3') self.assertEqual(state.to_string(), 'foo=1,bar=2,baz=3') # test load order state = Tracestate() state.from_string('baz=3') state.from_string('bar=2') state.from_string('foo=1') self.assertNotEqual(state.to_string(), 'foo=1,bar=2,baz=3')
def get_tracestate(self, headers): tracestate = Tracestate() for key, value in headers: if self.tracestate_name_re.match(key): tracestate.from_string(value) return tracestate