Open
Conversation
dolmen
requested changes
Oct 20, 2025
| if h, ok := t.(tHelper); ok { | ||
| h.Helper() | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
The case where expectedKind == reflect.Invalid must be rejected (and added to test cases).
Author
There was a problem hiding this comment.
Thanks for catching this.
I've updated to handle this
| h.Helper() | ||
| } | ||
|
|
||
| objectKind := reflect.TypeOf(object).Kind() |
Collaborator
There was a problem hiding this comment.
object must be checked for nil and rejected before calling reflect.TypeOf (another missing test case).
Author
There was a problem hiding this comment.
Thanks for catching this.
I've updated to handle this
| if h, ok := t.(tHelper); ok { | ||
| h.Helper() | ||
| } | ||
|
|
Collaborator
There was a problem hiding this comment.
Same issues as in Kind:
- check for
reflect.InvalidexpectedKind - check for
nilobject
efa51f8 to
194f059
Compare
fredbi
added a commit
to fredbi/testify
that referenced
this pull request
Jan 11, 2026
This adapts stretchr#1803. We have adopted slightly different design choices: * we think checking for nil and reflect.Invalid is a legit use case * we prefer to use [reflect.Value.Kind] over [reflect.Type.Kind] so as to reflect the concrete type of the object. This way we don't have to handle the case when [reflect.TypeOf] is nil, which again may well be a legitimate assertion. Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
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.
Summary
Continues work from #1049 by @matinFT.
This PR rebases with the latest master, fixes according the original PR's comments by @dolmen , and also add
NotKindto adhere to the API convention.This fixes #633
Changes
Add
KindandNotKindfunction inassertpackage.Motivation
See #633
Related issues
Closes #633