Skip to content

Conversation

@uh-oh-monteiro
Copy link

@uh-oh-monteiro uh-oh-monteiro commented Oct 27, 2025

New method, similar to the matches_regex validator, but takes in a list(s) of patterns. Validation passes if at least one pattern is matched.
Usage can be like:

@htf.measures(htf.Measurement('P5_MAIN_SMT_ID').matches_any_regex(MainBoardStandardRegex.all_patterns, MainBoardOmniRegex.all_patterns))
def P5_MAIN_SMT_ID(test: htf.TestApi):

or

@htf.measures(htf.Measurement('P5_BATTERY_SN').matches_any_regex(BatteryRegex.all_patterns))
def P5_BATTERY_SN(test: htf.TestApi, prompts: UserInput):

This is to accomodate validating the part numbers for entity binding. There are often multiple acceptable formats per part. There is no overarching structure (apart from the datecode). It's easier to have classes for each part number which keep track of the acceptable regex patterns. https://github.com/halter-corp/hardware-test-framework/pull/960

We pass this object (a list of the patterns) into the validator matches_any_regex.

Unfortunately, it displays this horrendous string (amalgamation of the acceptable patterns) as a validator:
image

@coveralls
Copy link

coveralls commented Oct 27, 2025

Pull Request Test Coverage Report for Build 19165234214

Details

  • 22 of 27 (81.48%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 61.598%

Changes Missing Coverage Covered Lines Changed/Added Lines %
openhtf/util/validators.py 22 27 81.48%
Totals Coverage Status
Change from base Build 17748747896: 0.07%
Covered Lines: 4711
Relevant Lines: 7648

💛 - Coveralls

@uh-oh-monteiro uh-oh-monteiro deleted the feat/multi-pattern-regex branch November 10, 2025 13:32
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.

3 participants