Skip to content

Make ENIP tests tolerate missing root log handlers#121

Open
lazydreamy wants to merge 1 commit into
pjkundert:masterfrom
lazydreamy:pr/fix-enip-test-logging
Open

Make ENIP tests tolerate missing root log handlers#121
lazydreamy wants to merge 1 commit into
pjkundert:masterfrom
lazydreamy:pr/fix-enip-test-logging

Conversation

@lazydreamy

Copy link
Copy Markdown

Summary

Allow ENIP parser and UDT tests to be collected when pytest has not installed a root logging handler yet.

Some Python 2 / pytest environments leave the root logger without handlers during test module import. The existing tests immediately access handlers[0], which raises IndexError during collection before the tests can run.

Changes

  • Configure default logging with logging.basicConfig(**log_cfg) only when the root logger has no handlers.
  • Preserve the existing formatter behavior when a handler is already present.

Testing

  • py -2.7 -m pytest server/enip/parser_test.py server/enip/udt_test.py

Configure default logging in parser and UDT tests when pytest has not installed a root handler yet. This keeps the existing tests collectable on Python 2 with pytest 4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant