mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
mark fail tests
This commit is contained in:
1 parent
b91ec2690f
commit
10020a910c
8 files changed
+40
-28
No files matched your search
Vendored
+6
@@ -989,6 +989,8 @@ class BaseBytesTest:
|
||||
class BytesTest(BaseBytesTest, unittest.TestCase):
|
||||
type2test = bytes
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_getitem_error(self):
|
||||
b = b'python'
|
||||
msg = "byte indices must be integers or slices"
|
||||
@@ -1181,12 +1183,16 @@ class BytesTest(BaseBytesTest, unittest.TestCase):
|
||||
class ByteArrayTest(BaseBytesTest, unittest.TestCase):
|
||||
type2test = bytearray
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_getitem_error(self):
|
||||
b = bytearray(b'python')
|
||||
msg = "bytearray indices must be integers or slices"
|
||||
with self.assertRaisesRegex(TypeError, msg):
|
||||
b['a']
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_setitem_error(self):
|
||||
b = bytearray(b'python')
|
||||
msg = "bytearray indices must be integers or slices"
|
||||
|
||||
Vendored
+2
@@ -18,6 +18,8 @@ JUST_SHOW_HASH_RESULTS = False # if RUN_ALL_HASH_TESTS, just display
|
||||
class TupleTest(seq_tests.CommonTest):
|
||||
type2test = tuple
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_getitem_error(self):
|
||||
t = ()
|
||||
msg = "tuple indices must be integers or slices"
|
||||
|
||||
Vendored
+1
@@ -2515,6 +2515,7 @@ class BadElementTest(ElementTestCase, unittest.TestCase):
|
||||
e.append(ET.Element('child'))
|
||||
e[0:10:X()] # shouldn't crash
|
||||
|
||||
@unittest.skip("TODO: RUSTPYTHON, hangs")
|
||||
def test_ass_subscr(self):
|
||||
# Issue #27863
|
||||
class X:
|
||||
|
||||
@@ -176,8 +176,7 @@ impl PyValue for PySequenceIterator {
|
||||
#[pyimpl(with(IterNext))]
|
||||
impl PySequenceIterator {
|
||||
pub fn new(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<Self> {
|
||||
let seq = PySequence::from(obj.as_ref());
|
||||
seq.try_protocol(vm)?;
|
||||
let seq = PySequence::try_protocol(obj.as_ref(), vm)?;
|
||||
let seq_methods = seq.methods_cow(vm).clone();
|
||||
Ok(Self {
|
||||
seq_methods,
|
||||
|
||||
@@ -4,9 +4,10 @@ use super::{PyDict, PyGenericAlias, PyList, PyStr, PyStrRef, PyTuple, PyTypeRef}
|
||||
use crate::{
|
||||
function::{IntoPyObject, OptionalArg},
|
||||
protocol::{PyMapping, PyMappingMethods, PySequence, PySequenceMethods},
|
||||
pyref_type_error,
|
||||
types::{AsMapping, AsSequence, Constructor, Iterable},
|
||||
PyClassImpl, PyContext, PyObject, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
|
||||
TypeProtocol, VirtualMachine, pyref_type_error,
|
||||
TypeProtocol, VirtualMachine,
|
||||
};
|
||||
|
||||
#[pyclass(module = false, name = "mappingproxy")]
|
||||
|
||||
@@ -9,7 +9,9 @@ use crate::{
|
||||
lock::OnceCell,
|
||||
},
|
||||
function::{FuncArgs, IntoPyObject, OptionalArg},
|
||||
protocol::{BufferDescriptor, BufferMethods, PyBuffer, PyMappingMethods, VecBuffer, PySequenceMethods},
|
||||
protocol::{
|
||||
BufferDescriptor, BufferMethods, PyBuffer, PyMappingMethods, PySequenceMethods, VecBuffer,
|
||||
},
|
||||
sequence::SequenceOp,
|
||||
sliceable::wrap_index,
|
||||
stdlib::pystruct::FormatSpec,
|
||||
|
||||
@@ -15,8 +15,8 @@ use crate::{
|
||||
Iterable, PyComparisonOp, Unconstructible,
|
||||
},
|
||||
utils::Either,
|
||||
IdProtocol, PyClassImpl, PyComparisonValue, PyContext, PyObject, PyObjectRef,
|
||||
PyObjectView, PyRef, PyResult, PyValue, TypeProtocol, VirtualMachine,
|
||||
IdProtocol, PyClassImpl, PyComparisonValue, PyContext, PyObject, PyObjectRef, PyObjectView,
|
||||
PyRef, PyResult, PyValue, TypeProtocol, VirtualMachine,
|
||||
};
|
||||
use ascii::{AsciiStr, AsciiString};
|
||||
use bstr::ByteSlice;
|
||||
|
||||
+23
-22
@@ -72,6 +72,15 @@ impl<'a> PySequence<'a> {
|
||||
methods: OnceCell::from(methods),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn try_protocol(obj: &'a PyObject, vm: &VirtualMachine) -> PyResult<Self> {
|
||||
let zelf = Self::from(obj);
|
||||
if zelf.check(vm) {
|
||||
Ok(zelf)
|
||||
} else {
|
||||
Err(vm.new_type_error(format!("'{}' is not a sequence", obj.class())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PySequence<'_> {
|
||||
@@ -80,18 +89,10 @@ impl PySequence<'_> {
|
||||
}
|
||||
|
||||
// PySequence_Check
|
||||
pub fn has_protocol(&self, vm: &VirtualMachine) -> bool {
|
||||
pub fn check(&self, vm: &VirtualMachine) -> bool {
|
||||
self.methods(vm).item.is_some()
|
||||
}
|
||||
|
||||
pub fn try_protocol(&self, vm: &VirtualMachine) -> PyResult<()> {
|
||||
if self.has_protocol(vm) {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(vm.new_type_error(format!("'{}' is not a sequence", self.obj.class().name())))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn methods(&self, vm: &VirtualMachine) -> &PySequenceMethods {
|
||||
self.methods_cow(vm).borrow()
|
||||
}
|
||||
@@ -116,7 +117,7 @@ impl PySequence<'_> {
|
||||
self.length_opt(vm).ok_or_else(|| {
|
||||
vm.new_type_error(format!(
|
||||
"'{}' is not a sequence or has no len()",
|
||||
self.obj.class().name()
|
||||
self.obj.class()
|
||||
))
|
||||
})?
|
||||
}
|
||||
@@ -127,7 +128,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
|
||||
// if both arguments apear to be sequences, try fallback to __add__
|
||||
if self.has_protocol(vm) && PySequence::from(other).has_protocol(vm) {
|
||||
if self.check(vm) && PySequence::from(other).check(vm) {
|
||||
let ret = vm._add(self.obj, other)?;
|
||||
if let PyArithmeticValue::Implemented(ret) = PyArithmeticValue::from_object(vm, ret) {
|
||||
return Ok(ret);
|
||||
@@ -135,7 +136,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' object can't be concatenated",
|
||||
self.obj.class().name()
|
||||
self.obj.class()
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -145,7 +146,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
|
||||
// try fallback to __mul__
|
||||
if self.has_protocol(vm) {
|
||||
if self.check(vm) {
|
||||
let ret = vm._mul(self.obj, &n.into_pyobject(vm))?;
|
||||
if let PyArithmeticValue::Implemented(ret) = PyArithmeticValue::from_object(vm, ret) {
|
||||
return Ok(ret);
|
||||
@@ -153,7 +154,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' object can't be repeated",
|
||||
self.obj.class().name()
|
||||
self.obj.class()
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -166,7 +167,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
|
||||
// if both arguments apear to be sequences, try fallback to __iadd__
|
||||
if self.has_protocol(vm) && PySequence::from(other).has_protocol(vm) {
|
||||
if self.check(vm) && PySequence::from(other).check(vm) {
|
||||
let ret = vm._iadd(self.obj, other)?;
|
||||
if let PyArithmeticValue::Implemented(ret) = PyArithmeticValue::from_object(vm, ret) {
|
||||
return Ok(ret);
|
||||
@@ -174,7 +175,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' object can't be concatenated",
|
||||
self.obj.class().name()
|
||||
self.obj.class()
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -186,7 +187,7 @@ impl PySequence<'_> {
|
||||
return f(self, n, vm);
|
||||
}
|
||||
|
||||
if self.has_protocol(vm) {
|
||||
if self.check(vm) {
|
||||
let ret = vm._imul(self.obj, &n.into_pyobject(vm))?;
|
||||
if let PyArithmeticValue::Implemented(ret) = PyArithmeticValue::from_object(vm, ret) {
|
||||
return Ok(ret);
|
||||
@@ -194,7 +195,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' object can't be repeated",
|
||||
self.obj.class().name()
|
||||
self.obj.class()
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -204,7 +205,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' is not a sequence or does not support indexing",
|
||||
self.obj.class().name()
|
||||
self.obj.class()
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -214,7 +215,7 @@ impl PySequence<'_> {
|
||||
}
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' is not a sequence or doesn't support item {}",
|
||||
self.obj.class().name(),
|
||||
self.obj.class(),
|
||||
if value.is_some() {
|
||||
"assignment"
|
||||
} else {
|
||||
@@ -242,7 +243,7 @@ impl PySequence<'_> {
|
||||
} else {
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' object is unsliceable",
|
||||
self.obj.class().name()
|
||||
self.obj.class()
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -265,7 +266,7 @@ impl PySequence<'_> {
|
||||
} else {
|
||||
Err(vm.new_type_error(format!(
|
||||
"'{}' object doesn't support slice {}",
|
||||
self.obj.class().name(),
|
||||
self.obj.class(),
|
||||
if value.is_some() {
|
||||
"assignment"
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user