Add more test for bytearray.pop and fix the panic message

This commit is contained in:
janczer
2019-02-20 06:57:53 +01:00
parent bfdb82b5c1
commit 24176f7bbb
2 changed files with 11 additions and 2 deletions

View File

@@ -43,3 +43,12 @@ c = bytearray([123, 255, 111])
assert len(c) == 3
c.pop()
assert len(c) == 2
c.pop()
c.pop()
try:
c.pop()
except IndexError:
pass
else:
assert False

View File

@@ -185,7 +185,7 @@ pub fn get_value<'a>(obj: &'a PyObjectRef) -> impl Deref<Target = Vec<u8>> + 'a
if let PyObjectPayload::Bytes { ref value } = py_obj.payload {
value
} else {
panic!("Inner error getting int {:?}", obj);
panic!("Inner error getting bytearray {:?}", obj);
}
})
}
@@ -195,7 +195,7 @@ pub fn get_mut_value<'a>(obj: &'a PyObjectRef) -> impl DerefMut<Target = Vec<u8>
if let PyObjectPayload::Bytes { ref mut value } = py_obj.payload {
value
} else {
panic!("Inner error getting int {:?}", obj);
panic!("Inner error getting bytearray {:?}", obj);
}
})
}