Skip to content

Commit

Permalink
fixup! tests: small refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jimf5 committed Dec 10, 2023
1 parent 4b28fbc commit d19c007
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions tests/test_otel.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@


def span_attr(span, attr, atype):
for a in span.attributes:
if a.key == attr:
return getattr(a.value, atype)
for _value in (a.value for a in span.attributes if a.key == attr):
return getattr(_value, atype)


def collect_rheaders(headers):
Expand All @@ -120,25 +119,16 @@ def rheaders():
@pytest.fixture
def span_list(http_ver, spans):
span_list = []
for spn in (
sp
for sp in (
ss[0].spans
for ss in (
s[0].scope_spans
for s in (
batch
for batch in spans
if span_attr(
batch[0].resource, "service.name", "string_value"
)
== f"test_http{http_ver}"
)
)
for _spans in (
_res[0].scope_spans[0].spans
for _res in (
_batch
for _batch in spans
if span_attr(_batch[0].resource, "service.name", "string_value")
== f"test_http{http_ver}"
)
):
for _span in spn:
span_list.append(_span)
span_list += _spans
return span_list


Expand Down

0 comments on commit d19c007

Please sign in to comment.