Skip to content

Commit 3a83b40

Browse files
TimPansinohmstepanek
authored andcommitted
Fix structlog tests (#1556)
1 parent 8a3eb42 commit 3a83b40

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/logger_structlog/test_attributes.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import sys
16+
1517
import pytest
1618
from testing_support.validators.validate_log_event_count import validate_log_event_count
1719
from testing_support.validators.validate_log_events import validate_log_events
@@ -23,12 +25,18 @@
2325
def logger(structlog_caplog):
2426
import structlog
2527

28+
# For Python < 3.11 co_qualname does not exist and causes errors.
29+
# Remove it from the CallsiteParameterAdder input list.
30+
_callsite_params = set(structlog.processors.CallsiteParameter)
31+
if sys.version_info < (3, 11) and hasattr(structlog.processors.CallsiteParameter, "QUAL_NAME"):
32+
_callsite_params.remove(structlog.processors.CallsiteParameter.QUAL_NAME)
33+
2634
structlog.configure(
2735
processors=[
2836
structlog.contextvars.merge_contextvars,
2937
structlog.processors.format_exc_info,
3038
structlog.processors.StackInfoRenderer(),
31-
structlog.processors.CallsiteParameterAdder(),
39+
structlog.processors.CallsiteParameterAdder(parameters=_callsite_params),
3240
],
3341
logger_factory=lambda *args, **kwargs: structlog_caplog,
3442
)

0 commit comments

Comments
 (0)