forked from Rust-related/RustPython
Merge pull request #4190 from dvermd/takewhile_reduce
add takewhile.__reduce__
This commit is contained in:
2
Lib/test/test_itertools.py
vendored
2
Lib/test/test_itertools.py
vendored
@@ -1349,8 +1349,6 @@ class TestBasicOps(unittest.TestCase):
|
||||
self.assertEqual(list(islice(range(100), IntLike(10), IntLike(50), IntLike(5))),
|
||||
list(range(10,50,5)))
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_takewhile(self):
|
||||
data = [1, 3, 5, 20, 2, 4, 6, 8]
|
||||
self.assertEqual(list(takewhile(underten, data)), [1, 3, 5])
|
||||
|
||||
@@ -467,7 +467,15 @@ mod decl {
|
||||
}
|
||||
|
||||
#[pyclass(with(IterNext, Constructor), flags(BASETYPE))]
|
||||
impl PyItertoolsTakewhile {}
|
||||
impl PyItertoolsTakewhile {
|
||||
#[pymethod(magic)]
|
||||
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyObjectRef, PyIter)) {
|
||||
(
|
||||
zelf.class().clone(),
|
||||
(zelf.predicate.clone(), zelf.iterable.clone()),
|
||||
)
|
||||
}
|
||||
}
|
||||
impl IterNextIterable for PyItertoolsTakewhile {}
|
||||
impl IterNext for PyItertoolsTakewhile {
|
||||
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
|
||||
|
||||
Reference in New Issue
Block a user