Add SCPI parser tests

Comprehensive test suite for SCPI command parsing:
- SCPICommand dataclass tests (creation, keyword property)
- Parser tests for queries, commands, arguments
- IEEE 488.2 common command tests (*IDN?, *RST, etc.)
- Edge cases (whitespace, empty strings)
- Instrument-specific command tests

Also fixed bug where is_query was determined from command string
ending rather than header ending (handles queries with arguments).
This commit is contained in:
2025-04-21 13:10:50 +00:00
parent 5e69085875
commit 510e1ba683
2 changed files with 206 additions and 2 deletions

View File

@@ -67,8 +67,6 @@ class SCPIParser:
if not command_string:
return SCPICommand(header="", arguments=[], is_query=False)
is_query = command_string.endswith("?")
# Split into header and arguments on first whitespace
parts = command_string.split(None, 1)
header = parts[0]
@@ -79,6 +77,9 @@ class SCPIParser:
arg_string = parts[1]
arguments = [arg.strip() for arg in arg_string.split(",")]
# Query is determined by whether the header ends with '?'
is_query = header.endswith("?")
return SCPICommand(
header=header,
arguments=arguments,