Skip to content

Commit 39d14a6

Browse files
committed
Remove file tracking to stderr.
When output to stderr, it can get mixed up with warning messages from other libraries. Reporting to stdout or a specific file is therefore more useful.
1 parent fcd0399 commit 39d14a6

2 files changed

Lines changed: 0 additions & 111 deletions

File tree

pgfutils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,10 +1042,6 @@ def save(figure: "matplotlib.figure.Figure|None" = None):
10421042
if dest == "1":
10431043
sys.stdout.write(filestr)
10441044

1045-
# stderr.
1046-
elif dest == "2":
1047-
sys.stderr.write(filestr)
1048-
10491045
# A named file.
10501046
else:
10511047
with open(dest, "w") as f:

tests/test_tracking.py

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ def test_simple_stdout(self):
2222
assert res.returncode == 0
2323
assert len(res.stdout.strip()) == 0
2424

25-
def test_simple_stderr(self):
26-
"""File tracking to stderr with no dependencies or rasterisation..."""
27-
# Run the script and check no files were reported.
28-
env = {"PGFUTILS_TRACK_FILES": "2"}
29-
with build_pypgf(srcdir, "simple.py", env) as res:
30-
assert res.returncode == 0
31-
assert len(res.stderr.strip()) == 0
32-
3325
def test_simple_file(self):
3426
"""File tracking to file with no dependencies or rasterisation..."""
3527
# Run the script and check no files were reported.
@@ -51,17 +43,6 @@ def test_rasterisation_stdout(self):
5143
fn = "rasterisation-img0.png"
5244
assert res.stdout.strip() == "w:" + fn
5345

54-
def test_rasterisation_stderr(self):
55-
"""File tracking to stderr with rasterised image..."""
56-
# Run the script.
57-
env = {"PGFUTILS_TRACK_FILES": "2"}
58-
with build_pypgf(srcdir, "rasterisation.py", env) as res:
59-
assert res.returncode == 0
60-
61-
# Check the expected raster filename is reported.
62-
fn = "rasterisation-img0.png"
63-
assert res.stderr.strip() == "w:" + fn
64-
6546
def test_rasterisation_file(self):
6647
"""File tracking to file with rasterised image..."""
6748
# Run the script.
@@ -86,17 +67,6 @@ def test_loadtxt_stdout(self):
8667
fn = "scatter.csv"
8768
assert res.stdout.strip() == "r:" + fn
8869

89-
def test_loadtxt_stderr(self):
90-
"""File tracking to stderr with loadtxt dependency..."""
91-
# Run the script.
92-
env = {"PGFUTILS_TRACK_FILES": "2"}
93-
with build_pypgf(srcdir, "dependency_loadtxt.py", env) as res:
94-
assert res.returncode == 0
95-
96-
# Check the expected dependency filename is reported.
97-
fn = "scatter.csv"
98-
assert res.stderr.strip() == "r:" + fn
99-
10070
def test_loadtxt_file(self):
10171
"""File tracking to file with loadtxt dependency..."""
10272
# Run the script.
@@ -121,17 +91,6 @@ def test_pathlib_stdout(self):
12191
fn = "scatter.csv"
12292
assert res.stdout.strip() == "r:" + fn
12393

124-
def test_pathlib_stderr(self):
125-
"""File tracking to stderr with pathlib dependency..."""
126-
# Run the script.
127-
env = {"PGFUTILS_TRACK_FILES": "2"}
128-
with build_pypgf(srcdir, "dependency_pathlib.py", env) as res:
129-
assert res.returncode == 0
130-
131-
# Check the expected dependency filename is reported.
132-
fn = "scatter.csv"
133-
assert res.stderr.strip() == "r:" + fn
134-
13594
def test_pathlib_file(self):
13695
"""File tracking to file with pathlib dependency..."""
13796
# Run the script.
@@ -156,17 +115,6 @@ def test_load_stdout(self):
156115
fn = "noise.npy"
157116
assert res.stdout.strip() == "r:" + fn
158117

159-
def test_load_stderr(self):
160-
"""File tracking to stderr with NumPy format dependency..."""
161-
# Run the script.
162-
env = {"PGFUTILS_TRACK_FILES": "2"}
163-
with build_pypgf(srcdir, "dependency_npy.py", env) as res:
164-
assert res.returncode == 0
165-
166-
# Check the expected dependency filename is reported.
167-
fn = "noise.npy"
168-
assert res.stderr.strip() == "r:" + fn
169-
170118
def test_load_file(self):
171119
"""File tracking to file with NumPy format dependency..."""
172120
# Run the script.
@@ -198,24 +146,6 @@ def test_multi_stdout(self):
198146
actual = set(res.stdout.strip().splitlines())
199147
assert actual == expected
200148

201-
def test_multi_stderr(self):
202-
"""File tracking to stderr with multiple dependencies and rasterisation..."""
203-
# Run the script.
204-
env = {"PGFUTILS_TRACK_FILES": "2"}
205-
with build_pypgf(srcdir, "multi.py", env) as res:
206-
assert res.returncode == 0
207-
208-
# Check the results are as expected.
209-
expected = {
210-
"r:noise.npy",
211-
"r:scatter.csv",
212-
"r:extra.file",
213-
"w:multi-img0.png",
214-
"w:multi-img1.png",
215-
}
216-
actual = set(res.stderr.strip().splitlines())
217-
assert actual == expected
218-
219149
def test_multi_file(self):
220150
"""File tracking to file with multiple dependencies and rasterisation..."""
221151
# Run the script.
@@ -257,27 +187,6 @@ def test_extradirs_stdout(self):
257187
actual = set(res.stdout.strip().splitlines())
258188
assert actual == expected
259189

260-
def test_extradirs_stderr(self):
261-
"""File tracking to stderr with extra dependency directories."""
262-
# Run the script.
263-
extra_dir = srcdir / "extra_dirs"
264-
env = {"PGFUTILS_TRACK_FILES": "2"}
265-
with build_pypgf(extra_dir, "multi.py", env) as res:
266-
assert res.returncode == 0
267-
268-
# Check the results are as expected.
269-
absdir = extra_dir.resolve()
270-
expected = {
271-
"r:pgfutils.toml",
272-
f"r:{(absdir / '../noise.npy').resolve()}",
273-
"r:scatter.csv",
274-
f"r:{(absdir / '../../extra.file').resolve()}",
275-
"w:multi-img0.png",
276-
"w:multi-img1.png",
277-
}
278-
actual = set(res.stderr.strip().splitlines())
279-
assert actual == expected
280-
281190
def test_extradirs_file(self):
282191
"""File tracking to file with extra dependency directories."""
283192
# Run the script.
@@ -382,22 +291,6 @@ def test_manual_stdout(self):
382291
actual = set(res.stdout.strip().splitlines())
383292
assert actual == expected
384293

385-
def test_manual_stderr(self):
386-
"""File tracking to stderr with manual dependencies..."""
387-
env = {"PGFUTILS_TRACK_FILES": "2"}
388-
tests = {
389-
"manual_dependency.py": {"r:data.file"},
390-
"manual_dependencies.py": {"r:data.file", "r:another.file"},
391-
}
392-
for script, expected in tests.items():
393-
# Run the script and check it succeeded.
394-
with build_pypgf(srcdir, script, env) as res:
395-
assert res.returncode == 0, f"Running {srcdir / script} failed,"
396-
397-
# Check the output files are correct.
398-
actual = set(res.stderr.strip().splitlines())
399-
assert actual == expected
400-
401294
def test_manual_file(self):
402295
"""File tracking to file with manual dependencies..."""
403296
tfn = srcdir / "tracking.test.results"

0 commit comments

Comments
 (0)