@@ -535,14 +535,6 @@ class BigItem:
535535 z : Optional [int ] = None
536536
537537
538- @attrs .define
539- class SmallItem :
540- """Same with ``BigItem`` but removes the required ``x`` field."""
541-
542- y : Optional [int ] = None
543- z : Optional [int ] = None
544-
545-
546538@attrs .define
547539class BigPage (ItemPage [BigItem ]):
548540 select_fields : Optional [SelectFields ] = None
@@ -804,27 +796,3 @@ async def test_select_fields_include_exclude() -> None:
804796 assert item == BigItem (x = 1 , y = None , z = 3 )
805797 assert page .fields_to_extract == {"x" , "z" }
806798 assert page .call_counter == {"x" : 1 , "z" : 1 }
807-
808-
809- @pytest .mark .asyncio
810- async def test_select_fields_swap_item_cls () -> None :
811- # Basic case
812- page = BigPage (SelectFields (exclude = ["x" ], swap_item_cls = SmallItem ))
813- item = await page .to_item ()
814- assert item == SmallItem (y = 2 , z = 3 )
815- assert page .fields_to_extract == {"y" , "z" }
816- assert page .call_counter == {"y" : 1 , "z" : 1 }
817-
818- page = BigPage (SelectFields (include = ["y" , "z" ], swap_item_cls = SmallItem ))
819- item = await page .to_item ()
820- assert item == SmallItem (y = 2 , z = 3 )
821- assert page .fields_to_extract == {"y" , "z" }
822- assert page .call_counter == {"y" : 1 , "z" : 1 }
823-
824- # If page object supplies the new item class with unknown fields, it should
825- # raise an error
826- expected_type_error_msg = r"__init__\(\) got an unexpected keyword argument 'x'"
827- page = BigPage (SelectFields (swap_item_cls = SmallItem ))
828- with pytest .raises (TypeError , match = expected_type_error_msg ):
829- await page .to_item ()
830- assert page .fields_to_extract == {"x" , "y" , "z" }
0 commit comments