@@ -109,9 +109,20 @@ def test_unsupported_numpy_dtypes(tmp_path):
109109 with pytest .raises (TypeError ):
110110 file .mkrntuple ("ntuple4" , {"x" : dt_unknown })
111111
112+ with pytest .raises (AttributeError ):
113+ file .mktree ("tree5" , {1 : "unknown type" })
114+ with pytest .raises (ValueError ):
115+ file .mkrntuple ("ntuple5" , {1 : "unknown type" })
116+
117+ with pytest .raises (TypeError ):
118+ # this one ends up creating a tree, but fails when writing the data
119+ file .mktree ("tree6" , {"x" : "unknown type" })
120+ with pytest .raises (ValueError ):
121+ file .mkrntuple ("ntuple6" , {"x" : "unknown type" })
122+
112123 # make sure that things were written as data instead of being interpreted as dtypes
113124 with uproot .open (filepath ) as file :
114- assert file .keys (cycle = False ) == ["tree" , "ntuple" , "ntuple3" ]
125+ assert file .keys (cycle = False ) == ["tree" , "ntuple" , "ntuple3" , "tree6" ]
115126 assert file ["tree" ].arrays ().x [0 ] == "int32"
116127 assert file ["tree" ].arrays ().x [1 ] == "not a type"
117128 assert file ["ntuple" ].arrays ().x [0 ] == "int32"
@@ -120,3 +131,21 @@ def test_unsupported_numpy_dtypes(tmp_path):
120131 assert ak .array_equal (
121132 file ["ntuple3" ].arrays ().x [1 ], [("real" , "float32" ), ("imag" , "float32" )]
122133 )
134+
135+
136+ def test_type_specification_to_awkward_form ():
137+ form = ak .forms .EmptyForm ()
138+ assert uproot .writing .writable ._type_specification_to_awkward_form (form ) is form
139+
140+ assert uproot .writing .writable ._type_specification_to_awkward_form (
141+ ak .types .NumpyType ("int32" )
142+ ) == ak .forms .NumpyForm ("int32" )
143+
144+ with pytest .raises (TypeError ):
145+ uproot .writing .writable ._type_specification_to_awkward_form (frozenset )
146+
147+ with pytest .raises (TypeError ):
148+ uproot .writing .writable ._type_specification_to_awkward_form ((1 , 2 , 3 ))
149+
150+ with pytest .raises (TypeError ):
151+ uproot .writing .writable ._type_specification_to_awkward_form (0 )
0 commit comments