Add unit tests for low_level S7Client, S7Server, and S7Partner modules #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds comprehensive unit tests for the pure Python implementations in the
snap7/low_level/directory, specifically fors7_client.py,s7_server.py, ands7_partner.py.Overview
The low_level directory contains native Python implementations of the S7 protocol (similar to Sharp7), which provide an alternative to the C library wrapper. These implementations previously lacked dedicated unit tests.
Changes
New Test Files
tests/test_low_level_s7_client.py- 11 tests covering:S7Clientinitialization and configurationset_connection_params)get_param,set_param)S7SZL,S7SZLHeader)tests/test_low_level_s7_server.py- 12 tests covering:S7Serverinitialization and state managementtests/test_low_level_s7_partner.py- 20 tests covering:S7Partnerinitialization (both active and passive modes)Configuration Updates
pyproject.tomlto add pytest markers for the new test modules:low_level_client,low_level_server,low_level_partnerTest Coverage
All 43 new tests pass successfully and cover:
The tests are designed to run without requiring an actual PLC connection or the native snap7 library, making them suitable for CI/CD pipelines and local development.
Testing
Fixes #[issue_number]
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.