Skip to content

Commit 029a195

Browse files
committed
pytest: store output of tested script
This CL stores the output of a failing script for easy human comparison Signed-off-by: Sebastien Binet <binet@cern.ch>
1 parent 23774dd commit 029a195

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytest/pytest.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ func RunBenchmarks(b *testing.B, testDir string) {
133133
// RunScript runs the provided path to a script.
134134
// RunScript captures the stdout and stderr while executing the script
135135
// and compares it to a golden file:
136-
// RunScript("./testdata/foo.py")
136+
//
137+
// RunScript("./testdata/foo.py")
138+
//
137139
// will compare the output with "./testdata/foo_golden.txt".
138140
func RunScript(t *testing.T, fname string) {
139141
opts := py.DefaultContextOpts()
@@ -180,6 +182,8 @@ func RunScript(t *testing.T, fname string) {
180182

181183
diff := cmp.Diff(string(want), string(got))
182184
if !bytes.Equal(got, want) {
185+
out := fname[:len(fname)-len(".py")] + ".txt"
186+
_ = os.WriteFile(out, got, 0644)
183187
t.Fatalf("output differ: -- (-ref +got)\n%s", diff)
184188
}
185189
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy