@@ -961,6 +961,27 @@ def test_read_site_toml_basic(self):
961961 self .assertEqual (tomldata .dirs , ['subdir' ])
962962 self .assertEqual (tomldata .init , ['os' ])
963963
964+ def test_missing_schema_version_is_okay (self ):
965+ # It's okay for the schema_version to be missing, or even the [metadata] section entirely
966+ # (which is tested below). A missing schema_version just means that no future compatibility
967+ # can be guaranteed.
968+ name = self ._make_site_toml ("""\
969+ [metadata]
970+ """ )
971+ tomldata = site ._read_site_toml (self .sitedir , name )
972+ self .assertIsNotNone (tomldata )
973+ self .assertEqual (tomldata .metadata , {})
974+
975+ def test_unexpected_schema_version_is_not_okay (self ):
976+ # If [metadata].schema_version exists, but isn't a supported number, then the entire TOML
977+ # file is invalid and ignored.
978+ name = self ._make_site_toml ("""\
979+ [metadata]
980+ schema_version = 801
981+ """ )
982+ tomldata = site ._read_site_toml (self .sitedir , name )
983+ self .assertIsNone (tomldata )
984+
964985 def test_read_site_toml_parse_error (self ):
965986 # Invalid pkg.site.toml content is skipped.
966987 name = self ._make_site_toml ("not valid [[[toml" )
@@ -996,7 +1017,7 @@ def test_read_site_toml_empty_file(self):
9961017 # Empty .site.toml is a no-op.
9971018 name = self ._make_site_toml ("" )
9981019 tomldata = site ._read_site_toml (self .sitedir , name )
999- self .assertEqual (tomldata .metadata , [] )
1020+ self .assertEqual (tomldata .metadata , {} )
10001021 self .assertEqual (tomldata .dirs , [])
10011022 self .assertEqual (tomldata .init , [])
10021023
0 commit comments