def test_trace_context_from_bad_string(self): tests = [ (123.321, 'not a string'), ('bad value', 'bad string'), ('1:1:1:1:1', 'Too many colons'), ('1:1:1', 'Too few colons'), ('x:1:1:1', 'Not all numbers'), ('1:x:1:1', 'Not all numbers'), ('1:1:x:1', 'Not all numbers'), ('1:1:1:x', 'Not all numbers'), ('0:1:1:1', 'Trace ID cannot be zero'), ('1:0:1:1', 'Span ID cannot be zero'), ('1:1:-1:1', 'Parent ID cannot be negative'), ('1:1::1', 'Parent ID is missing'), ('1:1:1:-1', 'Flags cannot be negative'), ] for test in tests: try: val = span_context_from_string(test[0]) except SpanContextCorruptedException: val = None self.assertEqual(val, None, test[1])