File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -756,6 +756,23 @@ def test_permissions_config_options():
756
756
assert "friendship" in opts
757
757
758
758
759
+ def _can_import_toml ():
760
+ """Return true if one valid toml module can be imported.
761
+ Work around importorskip only supporting one module name.
762
+ """
763
+ try :
764
+ __import__ ("tomllib" )
765
+ return True
766
+ except ImportError :
767
+ pass
768
+ try :
769
+ __import__ ("tomli" )
770
+ return True
771
+ except ImportError :
772
+ pass
773
+ return False
774
+
775
+
759
776
@pytest .mark .parametrize (
760
777
"json_str,ok" ,
761
778
[
@@ -943,9 +960,8 @@ def test_jsonschema_validation(json_str, ok):
943
960
),
944
961
],
945
962
)
963
+ @pytest .mark .skipif (not _can_import_toml (), reason = "no toml module" )
946
964
def test_toml_configs_no_validation (toml_str , ok ):
947
- pytest .importorskip ("tomllib" )
948
-
949
965
cfg = sambacc .config .GlobalConfig ()
950
966
fh = io .BytesIO (toml_str .encode ("utf8" ))
951
967
if ok :
@@ -1059,8 +1075,8 @@ def test_toml_configs_no_validation(toml_str, ok):
1059
1075
),
1060
1076
],
1061
1077
)
1078
+ @pytest .mark .skipif (not _can_import_toml (), reason = "no toml module" )
1062
1079
def test_toml_configs_validation (toml_str , ok ):
1063
- pytest .importorskip ("tomllib" )
1064
1080
jsonschema = pytest .importorskip ("jsonschema" )
1065
1081
1066
1082
cfg = sambacc .config .GlobalConfig ()
You can’t perform that action at this time.
0 commit comments