Skip to content

Commit da471a8

Browse files
committed
Do not change global config flag in printing test
Also make test slightly more restrictive
1 parent e3fb498 commit da471a8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

tests/test_printing.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pytest
1010

1111
import pytensor
12+
from pytensor import config
1213
from pytensor.compile.mode import get_mode
1314
from pytensor.compile.ops import deep_copy_op
1415
from pytensor.printing import (
@@ -464,8 +465,10 @@ def test_Print(capsys):
464465
assert "hello" in stdout
465466

466467

467-
def test_summary():
468-
old_profile_optimizer_config_value = pytensor.config.profile_optimizer = True
469-
f = pytensor.function(inputs=[], outputs=[], profile=True)
470-
f.profile.summary()
471-
pytensor.config.profile_optimizer = old_profile_optimizer_config_value
468+
def test_summary_with_profile_optimizer():
469+
with config.change_flags(profile_optimizer=True):
470+
f = pytensor.function(inputs=[], outputs=[], profile=True)
471+
472+
s = StringIO()
473+
f.profile.summary(file=s)
474+
assert "Rewriter Profile" in s.getvalue()

0 commit comments

Comments
 (0)