Skip to content

Commit

Permalink
str(null_schema) returns "Null_schema" not None
Browse files Browse the repository at this point in the history
  • Loading branch information
hyanwong committed Mar 2, 2023
1 parent 29e9d05 commit 36576f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 6 additions & 7 deletions python/tests/test_tables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2018-2022 Tskit Developers
# Copyright (c) 2018-2023 Tskit Developers
# Copyright (c) 2017 University of Oxford
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down Expand Up @@ -1321,9 +1321,8 @@ def test_metadata_schema(self, table_5row):
table2.metadata_schema = tskit.MetadataSchema({"codec": "json"})
with pytest.raises(
AssertionError,
match=f"{type(table_5row).__name__} metadata schemas differ: self=None "
f"other=OrderedDict([('codec', "
"'json')])",
match=f"{type(table_5row).__name__} metadata schemas differ: "
"self=Null_schema other=OrderedDict([('codec', 'json')])",
):
table_5row.assert_equals(table2)
table_5row.assert_equals(table2, ignore_metadata=True)
Expand Down Expand Up @@ -3990,7 +3989,7 @@ def test_metadata_schema(self, t1, t2):
AssertionError,
match=re.escape(
"Metadata schemas differ: self=OrderedDict([('codec', 'json')]) "
"other=None"
"other=Null_schema"
),
):
t1.assert_equals(t2)
Expand Down Expand Up @@ -4039,7 +4038,7 @@ def test_ignore_metadata(self, t1, t2, table_name):
AssertionError,
match=re.escape(
f"{type(table).__name__} metadata schemas differ: "
f"self=OrderedDict([('codec', 'json')]) other=None"
f"self=OrderedDict([('codec', 'json')]) other=Null_schema"
),
):
t1.assert_equals(t2)
Expand Down Expand Up @@ -4100,7 +4099,7 @@ def test_ignore_reference_sequence(self, t1, t2):
AssertionError,
match=re.escape(
"Metadata schemas differ: "
"self=OrderedDict([('codec', 'json')]) other=None"
"self=OrderedDict([('codec', 'json')]) other=Null_schema"
),
):
t1.assert_equals(t2)
Expand Down
7 changes: 5 additions & 2 deletions python/tskit/metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MIT License
#
# Copyright (c) 2020-2022 Tskit Developers
# Copyright (c) 2020-2023 Tskit Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -654,7 +654,10 @@ def __repr__(self) -> str:
return self._string

def __str__(self) -> str:
return pprint.pformat(self._schema)
if self._schema is None:
return "Null_schema"
else:
return pprint.pformat(self._schema)

def __eq__(self, other) -> bool:
return self._string == other._string
Expand Down

0 comments on commit 36576f3

Please sign in to comment.