Skip to content

Commit 65a1752

Browse files
wmaynerclaude
andcommitted
Fix JSON version check test to re-enable validation
The test was failing because VALIDATE_JSON_VERSION is globally disabled in conftest.py. Use config.override() to temporarily enable it. Also fix SIM115 lint error in network_file fixture by using context manager. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a5e9074 commit 65a1752

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/test_json.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ def test_deserialization_memoizes_duplicate_objects(s):
9999

100100
@pytest.fixture
101101
def network_file(standard):
102-
f = tempfile.NamedTemporaryFile(mode="w+")
103-
jsonify.dump(standard, f)
104-
f.seek(0)
105-
return f
102+
with tempfile.NamedTemporaryFile(mode="w+") as f:
103+
jsonify.dump(standard, f)
104+
f.seek(0)
105+
yield f
106106

107107

108108
def test_load(network_file, standard):
@@ -116,14 +116,20 @@ def test_network_from_json(network_file, standard):
116116

117117

118118
def test_version_check_during_deserialization(s):
119+
import pyphi
120+
119121
string = jsonify.dumps(s)
120122

121123
# Change the version
122124
_obj = json.loads(string)
123125
_obj[jsonify.VERSION_KEY] = "0.1.bogus"
124126
string = json.dumps(_obj)
125127

126-
with pytest.raises(exceptions.JSONVersionError):
128+
# Re-enable version validation (disabled globally in conftest.py)
129+
with (
130+
pyphi.config.override(VALIDATE_JSON_VERSION=True),
131+
pytest.raises(exceptions.JSONVersionError),
132+
):
127133
jsonify.loads(string)
128134

129135

0 commit comments

Comments
 (0)