testify
testify copied to clipboard
Add `NotImplements` and variants
Summary
Add assert.NotImplements (and variants)
Changes
Added assert.NotImplements (and variants)
Motivation
There was no way to test an object did not implement a specific interface yet. Its counterpart does exist, so it was somewhat surprising to not be able to test the inverse.
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_NotASigner(t *testing.T) {
e, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
require.NoError(t, err)
assert.NotImplements(t, (*crypto.Signer)(nil), e.Public()) // public key only isn't a signer
}
Related issues
Closes #1065
@CodiumAI-Agent please review
PR Analysis
- ๐ฏ Main theme: Adding a new assertion method
- ๐ Description and title: Yes
- ๐ Type of PR: Enhancement
- ๐งช Relevant tests added: Yes
- โจ Minimal and focused: Yes, because the PR is focused on adding a new assertion method and all changes are relevant to this addition.
- ๐ Security concerns: No, because the PR is focused on adding a new assertion method and does not involve any security-sensitive operations.
PR Feedback
- ๐ก General PR suggestions: The PR is well-structured and follows the existing code style. The new method is added in all the necessary places and the tests cover the main use cases.
How to use
Tag me in a comment '@CodiumAI-Agent' to ask for a new review after you update the PR. You can also tag me and ask any question, for example '@CodiumAI-Agent is the PR ready for merge?'
Patch is good.
However I'm not sure we want to extend the API. At least the must wait for 1.9.0.