Skip to content

Commit 450c112

Browse files
committed
Corrected formatting
1 parent e98253e commit 450c112

File tree

2 files changed

+44
-45
lines changed

2 files changed

+44
-45
lines changed

tests/schema/test_json_explicit_attributes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ def test_empty_lists_omitted(self):
165165
# But if Event doesn't have relatedTag, it should be omitted entirely
166166
if "relatedTag" in event["attributes"]:
167167
# If present, it must be non-empty
168-
self.assertNotEqual(event["attributes"]["relatedTag"], [],
169-
"relatedTag should be omitted entirely, not present as empty list")
170-
168+
self.assertNotEqual(
169+
event["attributes"]["relatedTag"], [], "relatedTag should be omitted entirely, not present as empty list"
170+
)
171+
171172
# Check that tags without certain attributes don't have empty lists
172173
item = tags.get("Item", {})
173174
if "relatedTag" in item.get("attributes", {}):
174-
self.assertNotEqual(item["attributes"]["relatedTag"], [],
175-
"Empty relatedTag should be omitted, not present as []")
175+
self.assertNotEqual(item["attributes"]["relatedTag"], [], "Empty relatedTag should be omitted, not present as []")
176176

177177

178178
class TestJSONBackwardsCompatibility(unittest.TestCase):

tests/schema/test_schema_format_roundtrip.py

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -256,113 +256,112 @@ def test_library_schema_header_attributes(self):
256256
def test_json_empty_list_attributes_omitted(self):
257257
"""Test that empty list attributes (suggestedTag, relatedTag, etc.) are omitted from JSON."""
258258
import json
259-
259+
260260
schema = load_schema_version("8.4.0")
261261
json_path = os.path.join(self.temp_dir, "empty_lists.json")
262262
schema.save_as_json(json_path)
263-
263+
264264
# Read the JSON file and check for empty list attributes
265-
with open(json_path, 'r', encoding='utf-8') as f:
265+
with open(json_path, "r", encoding="utf-8") as f:
266266
json_data = json.load(f)
267-
267+
268268
# Check ALL tags for empty lists
269269
tags_with_empty_lists = []
270-
270+
271271
for tag_name, tag_data in json_data.get("tags", {}).items():
272272
# Check attributes dict
273273
attrs = tag_data.get("attributes", {})
274274
for list_attr in ["suggestedTag", "relatedTag", "valueClass", "unitClass"]:
275275
if list_attr in attrs and attrs[list_attr] == []:
276276
tags_with_empty_lists.append(f"{tag_name}.attributes.{list_attr}")
277-
277+
278278
# Check explicitAttributes dict
279279
explicit_attrs = tag_data.get("explicitAttributes", {})
280280
for list_attr in ["suggestedTag", "relatedTag", "valueClass", "unitClass"]:
281281
if list_attr in explicit_attrs and explicit_attrs[list_attr] == []:
282282
tags_with_empty_lists.append(f"{tag_name}.explicitAttributes.{list_attr}")
283-
284-
self.assertEqual(len(tags_with_empty_lists), 0,
285-
f"Found {len(tags_with_empty_lists)} empty list attributes: {tags_with_empty_lists[:5]}")
286-
283+
284+
self.assertEqual(
285+
len(tags_with_empty_lists),
286+
0,
287+
f"Found {len(tags_with_empty_lists)} empty list attributes: {tags_with_empty_lists[:5]}",
288+
)
289+
287290
# Verify that tags WITH these attributes have non-empty lists
288291
if "Sensory-event" in json_data.get("tags", {}):
289292
sensory_attrs = json_data["tags"]["Sensory-event"].get("attributes", {})
290293
if "suggestedTag" in sensory_attrs:
291-
self.assertTrue(len(sensory_attrs["suggestedTag"]) > 0,
292-
"Sensory-event suggestedTag should be non-empty if present")
294+
self.assertTrue(
295+
len(sensory_attrs["suggestedTag"]) > 0, "Sensory-event suggestedTag should be non-empty if present"
296+
)
293297

294298
def test_extras_sections_roundtrip(self):
295299
"""Test that extras sections (Sources, Prefixes, AnnotationPropertyExternal) roundtrip correctly."""
296300
schema = load_schema_version("8.4.0")
297-
301+
298302
# Check that original has extras
299-
orig_extras = getattr(schema, 'extras', {}) or {}
303+
orig_extras = getattr(schema, "extras", {}) or {}
300304
self.assertGreater(len(orig_extras), 0, "Schema should have extras sections")
301-
305+
302306
# Save and reload
303307
json_path = os.path.join(self.temp_dir, "with_extras.json")
304308
schema.save_as_json(json_path)
305309
reloaded = load_schema(json_path)
306-
310+
307311
# Check reloaded has extras
308-
reloaded_extras = getattr(reloaded, 'extras', {}) or {}
309-
312+
reloaded_extras = getattr(reloaded, "extras", {}) or {}
313+
310314
# Compare each extras section
311-
self.assertEqual(set(orig_extras.keys()), set(reloaded_extras.keys()),
312-
"Extras sections should match")
313-
315+
self.assertEqual(set(orig_extras.keys()), set(reloaded_extras.keys()), "Extras sections should match")
316+
314317
for key in orig_extras.keys():
315318
orig_df = orig_extras[key]
316319
reloaded_df = reloaded_extras[key]
317-
self.assertTrue(orig_df.equals(reloaded_df),
318-
f"Extras section '{key}' should match after roundtrip")
320+
self.assertTrue(orig_df.equals(reloaded_df), f"Extras section '{key}' should match after roundtrip")
319321

320322
def test_library_schema_extras_roundtrip(self):
321323
"""Test that library schema extras (external annotations, etc.) roundtrip correctly."""
322324
schema = load_schema_version("score_2.1.0")
323-
325+
324326
# Check that library schema has extras
325-
orig_extras = getattr(schema, 'extras', {}) or {}
327+
orig_extras = getattr(schema, "extras", {}) or {}
326328
self.assertGreater(len(orig_extras), 0, "Library schema should have extras sections")
327-
329+
328330
# Check for external annotations specifically
329-
self.assertIn("AnnotationPropertyExternal", orig_extras,
330-
"Library schema should have external annotations")
331-
331+
self.assertIn("AnnotationPropertyExternal", orig_extras, "Library schema should have external annotations")
332+
332333
# Save and reload
333334
json_path = os.path.join(self.temp_dir, "library_with_extras.json")
334335
schema.save_as_json(json_path, save_merged=False)
335336
reloaded = load_schema(json_path)
336-
337+
337338
# Check reloaded has all extras
338-
reloaded_extras = getattr(reloaded, 'extras', {}) or {}
339-
self.assertEqual(set(orig_extras.keys()), set(reloaded_extras.keys()),
340-
"Library schema extras sections should match")
341-
339+
reloaded_extras = getattr(reloaded, "extras", {}) or {}
340+
self.assertEqual(set(orig_extras.keys()), set(reloaded_extras.keys()), "Library schema extras sections should match")
341+
342342
# Verify each extras dataframe matches
343343
for key in orig_extras.keys():
344344
orig_df = orig_extras[key]
345345
reloaded_df = reloaded_extras[key]
346-
self.assertTrue(orig_df.equals(reloaded_df),
347-
f"Library schema extras '{key}' should match after roundtrip")
346+
self.assertTrue(orig_df.equals(reloaded_df), f"Library schema extras '{key}' should match after roundtrip")
348347

349348
def test_library_schema_score(self):
350349
"""Test score library schema roundtrip specifically."""
351350
schema = load_schema_version("score_2.1.0")
352-
351+
353352
# Test unmerged format
354353
json_path = os.path.join(self.temp_dir, "score_unmerged.json")
355354
schema.save_as_json(json_path, save_merged=False)
356355
reloaded = load_schema(json_path)
357-
356+
358357
# Verify library attributes
359358
self.assertEqual(schema.library, reloaded.library)
360359
self.assertEqual(schema.version, reloaded.version)
361360
self.assertEqual(schema.with_standard, reloaded.with_standard)
362-
361+
363362
# Verify tag counts match
364363
self.assertEqual(len(schema.tags.all_entries), len(reloaded.tags.all_entries))
365-
364+
366365
# Verify prologue and epilogue
367366
self.assertEqual(schema.prologue, reloaded.prologue)
368367
self.assertEqual(schema.epilogue, reloaded.epilogue)

0 commit comments

Comments
 (0)