@@ -69,13 +69,13 @@ def test_spatial_extent_from_coordinates(self) -> None:
6969 bbox = extent .bboxes [0 ]
7070 assert len (bbox ) == 4
7171 for x in bbox :
72- self . assertTrue ( isinstance (x , float ) )
72+ assert isinstance (x , float )
7373
7474 def test_read_eo_items_are_heritable (self ) -> None :
7575 cat = TestCases .case_5 ()
7676 item = next (cat .get_items (recursive = True ))
7777
78- self . assertTrue ( EOExtension .has_extension (item ) )
78+ assert EOExtension .has_extension (item )
7979
8080 def test_save_uses_previous_catalog_type (self ) -> None :
8181 collection = TestCases .case_8 ()
@@ -97,16 +97,15 @@ def test_clone_uses_previous_catalog_type(self) -> None:
9797
9898 def test_clone_cant_mutate_original (self ) -> None :
9999 collection = TestCases .case_8 ()
100- assert collection .keywords is not None
101- self .assertListEqual (collection .keywords , ["disaster" , "open" ])
100+ assert collection .keywords == ["disaster" , "open" ]
102101 clone = collection .clone ()
103102 clone .extra_fields ["test" ] = "extra"
104- self . assertNotIn ( "test" , collection .extra_fields )
103+ assert "test" not in collection .extra_fields
105104 assert clone .keywords is not None
106105 clone .keywords .append ("clone" )
107- self . assertListEqual ( clone .keywords , ["disaster" , "open" , "clone" ])
108- self . assertListEqual ( collection .keywords , ["disaster" , "open" ])
109- self . assertNotEqual ( id (collection .summaries ), id (clone .summaries ) )
106+ assert clone .keywords == ["disaster" , "open" , "clone" ]
107+ assert collection .keywords == ["disaster" , "open" ]
108+ assert id (collection .summaries ) != id (clone .summaries )
110109
111110 def test_multiple_extents (self ) -> None :
112111 cat1 = TestCases .case_1 ()
@@ -115,26 +114,26 @@ def test_multiple_extents(self) -> None:
115114 col1 = country .get_child ("area-1-1" )
116115 assert col1 is not None
117116 col1 .validate ()
118- self . assertIsInstance (col1 , Collection )
117+ assert isinstance (col1 , Collection )
119118 validate_dict (col1 .to_dict (), pystac .STACObjectType .COLLECTION )
120119
121120 multi_ext_uri = TestCases .get_path ("data-files/collections/multi-extent.json" )
122121 with open (multi_ext_uri ) as f :
123122 multi_ext_dict = json .load (f )
124123 validate_dict (multi_ext_dict , pystac .STACObjectType .COLLECTION )
125- self . assertIsInstance (Collection .from_dict (multi_ext_dict ), Collection )
124+ assert isinstance (Collection .from_dict (multi_ext_dict ), Collection )
126125
127126 multi_ext_col = Collection .from_file (multi_ext_uri )
128127 multi_ext_col .validate ()
129128 ext = multi_ext_col .extent
130129 extent_dict = multi_ext_dict ["extent" ]
131- self . assertIsInstance (ext , Extent )
132- self . assertIsInstance (ext .spatial .bboxes [0 ], list )
130+ assert isinstance (ext , Extent )
131+ assert isinstance (ext .spatial .bboxes [0 ], list )
133132 assert len (ext .spatial .bboxes ) == 3
134- self . assertDictEqual ( ext .to_dict (), extent_dict )
133+ assert ext .to_dict () == extent_dict
135134
136135 cloned_ext = ext .clone ()
137- self . assertDictEqual ( cloned_ext .to_dict (), multi_ext_dict ["extent" ])
136+ assert cloned_ext .to_dict () == multi_ext_dict ["extent" ]
138137
139138 def test_extra_fields (self ) -> None :
140139 catalog = TestCases .case_2 ()
@@ -148,11 +147,11 @@ def test_extra_fields(self) -> None:
148147 collection .save_object (include_self_link = False , dest_href = p )
149148 with open (p ) as f :
150149 col_json = json .load (f )
151- self . assertTrue ( "test" in col_json )
150+ assert "test" in col_json
152151 assert col_json ["test" ] == "extra"
153152
154153 read_col = pystac .Collection .from_file (p )
155- self . assertTrue ( "test" in read_col .extra_fields )
154+ assert "test" in read_col .extra_fields
156155 assert read_col .extra_fields ["test" ] == "extra"
157156
158157 def test_update_extents (self ) -> None :
@@ -187,29 +186,19 @@ def test_update_extents(self) -> None:
187186
188187 collection .update_extent_from_items ()
189188 assert [[- 180 , - 90 , 180 , 90 ]] == collection .extent .spatial .bboxes
190- self .assertEqual (
191- len (base_extent .spatial .bboxes [0 ]), len (collection .extent .spatial .bboxes [0 ])
192- )
189+ assert len (base_extent .spatial .bboxes [0 ]) == len (collection .extent .spatial .bboxes [0 ])
190+ assert base_extent .temporal .intervals != collection .extent .temporal .intervals
193191
194- self .assertNotEqual (
195- base_extent .temporal .intervals , collection .extent .temporal .intervals
196- )
197192 collection .remove_item ("test-item-1" )
198193 collection .update_extent_from_items ()
199- self . assertNotEqual ( [[- 180 , - 90 , 180 , 90 ]], collection .extent .spatial .bboxes )
194+ assert [[- 180 , - 90 , 180 , 90 ]] != collection .extent .spatial .bboxes
200195 collection .add_item (item2 )
201196
202197 collection .update_extent_from_items ()
203198
204- self .assertEqual (
205- [
206- [
207- item2 .common_metadata .start_datetime ,
199+ assert ( [ [ item2 .common_metadata .start_datetime ,
208200 base_extent .temporal .intervals [0 ][1 ],
209- ]
210- ],
211- collection .extent .temporal .intervals ,
212- )
201+ ] ] == collection .extent .temporal .intervals )
213202
214203 def test_supplying_href_in_init_does_not_fail (self ) -> None :
215204 test_href = "http://example.com/collection.json"
@@ -247,17 +236,17 @@ def test_get_assets(self) -> None:
247236 )
248237
249238 media_type_filter = collection .get_assets (media_type = pystac .MediaType .PNG )
250- self . assertCountEqual (media_type_filter .keys (), ["thumbnail" ])
239+ assert list (media_type_filter .keys ()) == ["thumbnail" ]
251240 role_filter = collection .get_assets (role = "thumbnail" )
252- self . assertCountEqual (role_filter .keys (), ["thumbnail" ])
241+ assert list (role_filter .keys ()) == ["thumbnail" ]
253242 multi_filter = collection .get_assets (
254243 media_type = pystac .MediaType .PNG , role = "thumbnail"
255244 )
256- self . assertCountEqual (multi_filter .keys (), ["thumbnail" ])
245+ assert list (multi_filter .keys ()) == ["thumbnail" ]
257246
258247 no_filter = collection .get_assets ()
259- self . assertIsNot ( no_filter , collection .assets )
260- self . assertCountEqual (no_filter .keys (), ["thumbnail" ])
248+ assert no_filter is not collection .assets
249+ assert list (no_filter .keys ()) == ["thumbnail" ]
261250 no_filter ["thumbnail" ].description = "foo"
262251 assert collection .assets ["thumbnail" ].description != "foo"
263252
@@ -314,15 +303,15 @@ def test_from_dict_preserves_dict(self) -> None:
314303 # assert that the parameter is not preserved with
315304 # non-default parameter
316305 _ = Collection .from_dict (param_dict , preserve_dict = False , migrate = False )
317- self . assertNotEqual ( param_dict , collection_dict )
306+ assert param_dict != collection_dict
318307
319308 def test_from_dict_set_root (self ) -> None :
320309 path = TestCases .get_path ("data-files/examples/hand-0.8.1/collection.json" )
321310 with open (path ) as f :
322311 collection_dict = json .load (f )
323312 catalog = pystac .Catalog (id = "test" , description = "test desc" )
324313 collection = Collection .from_dict (collection_dict , root = catalog )
325- self . assertIs ( collection .get_root (), catalog )
314+ assert collection .get_root () is catalog
326315
327316 def test_schema_summary (self ) -> None :
328317 collection = pystac .Collection .from_file (
@@ -336,14 +325,14 @@ def test_schema_summary(self) -> None:
336325 "instruments" ,
337326 )
338327
339- self . assertIsInstance (instruments_schema , dict )
328+ assert isinstance (instruments_schema , dict )
340329
341330 def test_from_invalid_dict_raises_exception (self ) -> None :
342331 stac_io = pystac .StacIO .default ()
343332 catalog_dict = stac_io .read_json (
344333 TestCases .get_path ("data-files/catalogs/test-case-1/catalog.json" )
345334 )
346- with self . assertRaises (pystac .STACTypeError ):
335+ with pytest . raises (pystac .STACTypeError ):
347336 _ = pystac .Collection .from_dict (catalog_dict )
348337
349338 def test_clone_preserves_assets (self ) -> None :
@@ -359,11 +348,11 @@ def test_clone_preserves_assets(self) -> None:
359348
360349 for key in original_collection .assets :
361350 with self .subTest (f"Preserves { key } asset" ):
362- self . assertIn ( key , cloned_collection .assets )
351+ assert key in cloned_collection .assets
363352 cloned_asset = cloned_collection .assets .get (key )
364353 if cloned_asset is not None :
365- with self . subTest ( f"Sets owner for { key } " ):
366- self . assertIs ( cloned_asset . owner , cloned_collection )
354+ assert cloned_asset . owner in cloned_collection , \
355+ f"Failed to set owner for { key } "
367356
368357 def test_to_dict_no_self_href (self ) -> None :
369358 temporal_extent = TemporalExtent (intervals = [[TEST_DATETIME , None ]])
@@ -520,13 +509,11 @@ def test_to_from_dict(self) -> None:
520509
521510 extent = Extent .from_dict (extent_dict )
522511
523- self .assertDictEqual (expected_extent_extra_fields , extent .extra_fields )
524- self .assertDictEqual (expected_spatial_extra_fields , extent .spatial .extra_fields )
525- self .assertDictEqual (
526- expected_temporal_extra_fields , extent .temporal .extra_fields
527- )
512+ assert expected_extent_extra_fields == extent .extra_fields
513+ assert expected_spatial_extra_fields == extent .spatial .extra_fields
514+ assert expected_temporal_extra_fields == extent .temporal .extra_fields
528515
529- self . assertDictEqual ( extent_dict , extent .to_dict () )
516+ assert extent_dict == extent .to_dict ()
530517
531518
532519class CollectionSubClassTest (unittest .TestCase ):
@@ -549,18 +536,18 @@ def test_from_dict_returns_subclass(self) -> None:
549536 collection_dict = self .stac_io .read_json (self .MULTI_EXTENT )
550537 custom_collection = self .BasicCustomCollection .from_dict (collection_dict )
551538
552- self . assertIsInstance (custom_collection , self .BasicCustomCollection )
539+ assert isinstance (custom_collection , self .BasicCustomCollection )
553540
554541 def test_from_file_returns_subclass (self ) -> None :
555542 custom_collection = self .BasicCustomCollection .from_file (self .MULTI_EXTENT )
556543
557- self . assertIsInstance (custom_collection , self .BasicCustomCollection )
544+ assert isinstance (custom_collection , self .BasicCustomCollection )
558545
559546 def test_clone (self ) -> None :
560547 custom_collection = self .BasicCustomCollection .from_file (self .MULTI_EXTENT )
561548 cloned_collection = custom_collection .clone ()
562549
563- self . assertIsInstance (cloned_collection , self .BasicCustomCollection )
550+ assert isinstance (cloned_collection , self .BasicCustomCollection )
564551
565552 def test_collection_get_item_works (self ) -> None :
566553 path = TestCases .get_path (
0 commit comments