Repository navigation
quote string values in empty assertion failures - #1874
Closed
Bojun-Vvibe wants to merge 1 commit into
Closed
Bojun-Vvibe wants to merge 1 commit into
Bojun-Vvibe wants to merge 1 commit into
Conversation
fredbi
added a commit
to go-openapi/testify
that referenced
this pull request
Aug 23, 2026
Empty rendered the value with %v, so a string of whitespace left nothing on screen: Empty(t, " ") reported `Should be empty, but was `, which reads as a message that lost its value. NotEmpty had the same problem with the empty string. truncatingValue picks %q for anything of string kind, aliased string types included, and keeps %v for everything else. NotEmpty now goes through it too, so its value is truncated at maxMessageSize like every other failure message instead of being printed whole. reference: github.com/stretchr#1874 reference: github.com/stretchr#1875 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi
added a commit
to go-openapi/testify
that referenced
this pull request
Aug 23, 2026
The August sweep of stretchr/testify turned up four reports describing bugs we had inherited. Each now has a row in the implemented table saying what we adopted and what we left alone, and stretchr#1942 joins stretchr#1940 as the PR behind ErrorNotContains. stretchr#1776 goes in as informational: upstream's generated require documentation lists a bool return that the functions do not have, the same defect our own API pages carried until the signature tables were corrected. Nothing to adopt, but worth recording that both projects found it independently. Two more bugs surfaced while checking those four, neither of them reported upstream, so neither gets a row: InDeltaSlice named expected and actual the wrong way round in its failures, and EqualValues compared a negative signed integer equal to a large unsigned one. Also in this file: the review-frequency line was three months stale, [stretchr#1937] was referenced with no link definition and rendered as literal text, three definitions were duplicated, and the summary counts are recounted from the tables. reference: github.com/stretchr#1776 reference: github.com/stretchr#1874 reference: github.com/stretchr#1875 reference: github.com/stretchr#1898 reference: github.com/stretchr#1899 reference: github.com/stretchr#1908 reference: github.com/stretchr#1931 reference: github.com/stretchr#1940 reference: github.com/stretchr#1942 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> 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.
Repo: stretchr/testify (⭐ 23000)
Type: bugfix
Files changed: 2
Lines: +20/-22
What
This change updates
assert.Emptyandassert.NotEmptyto quote string values in failure messages, including aliased string types. The relatedassertpackage tests were updated so whitespace-only, newline-containing, and empty-string cases now assert against explicit, readable output like"\\n"and""instead of visually ambiguous raw text.Why
Current failure output for string values uses
%v, which makes empty strings and whitespace-heavy strings hard to distinguish from formatting noise. That weakens assertion diagnostics in exactly the cases where users need clarity. Quoting string values keeps behavior unchanged while making failures immediately understandable and resolves the existing TODO-marked test expectations around these messages.Testing
Ran
GOCACHE=$(pwd)/.gocache go test ./assert -run 'Test(Empty|NotEmpty)$'from the repo root. The targeted tests passed.Risk
Low / Message formatting only changes for string values in
EmptyandNotEmpty; assertion semantics are unchanged.