Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_generate_random_128bit_string(rand):
rand.return_value = b'17133d482ba4f60517133d482ba4f605'
random_string = utils.generate_random_128bit_string()
assert random_string == '17133d482ba4f60517133d482ba4f605'
# This acts as a contract test of sorts. This should return a str
# in both py2 and py3. IOW, no unicode objects.
assert isinstance(random_string, str)
def _next_context(self,
context: Optional[TraceContext] = None,
sampled: OptBool = None,
debug: bool = False) -> TraceContext:
span_id = generate_random_64bit_string()
if context is not None:
new_context = context._replace(
span_id=span_id,
parent_id=context.span_id,
shared=False)
return new_context
trace_id = generate_random_128bit_string()
if sampled is None:
sampled = self._sampler.is_sampled(trace_id)
new_context = TraceContext(
trace_id=trace_id,
parent_id=None,
span_id=span_id,
sampled=sampled,
debug=debug,
shared=False)
return new_context