summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
9442c9a)
This is useful to use the `in` Python operator like we do with regular
Python `str` objects:
if 'my_env_var' in env_string_value:
...
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I8f7f5c02d71bc089e14c3b8f2ffa81045a9e8f15
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1954
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
def __len__(self):
return len(self._value)
def __len__(self):
return len(self._value)
+ def __contains__(self, item):
+ return self._value_to_str(item) in self._value
+
def __iadd__(self, value):
curvalue = self._value
curvalue += self._value_to_str(value)
def __iadd__(self, value):
curvalue = self._value
curvalue += self._value_to_str(value)
s1 = bt2.StringValue('allo')
self.assertGreaterEqual('bateau', s1)
s1 = bt2.StringValue('allo')
self.assertGreaterEqual('bateau', s1)
+ def test_in_string(self):
+ s1 = bt2.StringValue('beau grand bateau')
+ self.assertIn('bateau', s1)
+
+ def test_in_vstring(self):
+ s1 = bt2.StringValue('beau grand bateau')
+ s2 = bt2.StringValue('bateau')
+ self.assertIn(s2, s1)
+
def test_bool_op(self):
self.assertEqual(bool(self._def), bool(self._def_value))
def test_bool_op(self):
self.assertEqual(bool(self._def), bool(self._def_value))