Skip to content

Commit

Permalink
Add pre-test cleanup to corpse equipment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinEady committed Mar 24, 2024
1 parent 3a1d6de commit c9e0e5c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions testsuite/pol/testpkgs/client/test_client_corpse.src
Expand Up @@ -43,6 +43,11 @@ endfunction
exported function test_corpse_equipment()
var res, corpse_equipment, corpse_content, goldcoin;

// Clean up old, leftover corpses from other tests
foreach corpse in ListItemsNearLocationOfType( 100, 100, 0, 15, 0x2006 )
DestroyItem( corpse );
endforeach

if ( !( res := MoveObjectToLocation( char, 100, 100, 0, flags := MOVEOBJECT_FORCELOCATION ) ) )
return cleanup_ret_error( $"Could not move player: {res}" );
endif
Expand Down
3 changes: 2 additions & 1 deletion testsuite/testclient/pyuo/pyuo/client.py
Expand Up @@ -194,7 +194,7 @@ def __getitem__(self, key):
return self.content[key]

class Corpse(Container):
equip = {}
equip = None

def __init__(self, client):
super().__init__(client)
Expand Down Expand Up @@ -826,6 +826,7 @@ def handlePacket(self, pkt):
if pkt.serial in self.objects:
corpse = self.objects[pkt.serial]
if isinstance(corpse, Corpse):
corpse.equip = {}
for item in pkt.equip:
corpse.equip[item['layer']] = item['serial']

Expand Down
2 changes: 1 addition & 1 deletion testsuite/testclient/pyuo/testclient.py
Expand Up @@ -282,7 +282,7 @@ def sendEvent(self, ev):
res["objs"][-1]["parent"]=o.parent.serial
elif ev.type==Event.EVT_LIST_EQUIPPED_ITEMS:
res["objs"]=[]
if ev.owner is not None and ev.owner.equip is not None:
if ev.owner is not None and hasattr(ev.owner, 'equip') and ev.owner.equip is not None:
for k,o in ev.owner.equip.items():
res["objs"].append(
{'serial':o, 'layer':k} if isinstance(o, int) else
Expand Down

0 comments on commit c9e0e5c

Please sign in to comment.