Repository navigation
[3/8] Use assert(Not)Regex instead of assertTrue or assertFalse in tests - #5242
Merged
Merged
Conversation
akesandgren
reviewed
Sep 14, 2026
|
|
||
| sha = gh.fetch_latest_commit_sha('easybuild-framework', 'easybuilders', github_user=GITHUB_TEST_ACCOUNT) | ||
| self.assertTrue(re.match('^[0-9a-f]{40}$', sha)) | ||
| self.assertRegex(sha, '^[0-9a-f]{40}$') |
Contributor
There was a problem hiding this comment.
Would probably be better to make this a "constant", SHA_PATTERN or something
akesandgren
reviewed
Sep 14, 2026
| for regex in regexs: | ||
| regex = re.compile(regex) | ||
| self.assertTrue(regex.search(cmd), "Pattern '%s' found in: %s" % (regex.pattern, cmd)) | ||
| self.assert_multi_regex(regexs, cmd) |
Contributor
There was a problem hiding this comment.
multi_line = False here? probably doesn't matter but...
akesandgren
reviewed
Sep 14, 2026
… in tests This makes the tests shorter and hence easier to read, avoids `re.compile` calls and manual failure message composing. In some cases `assert_multi_regex` could be used to avoid the explicit loops.
Flamefire
force-pushed
the
assertregex-3
branch
from
September 15, 2026 12:27
6fd82f9 to
ffc1827
Compare
Contributor
|
Going in, thanks @Flamefire! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 makes the tests shorter and hence easier to read, avoids
re.compilecalls and manual failure message composing. In some casesassert_multi_regexcould be used to avoid the explicit loops.