From 495b10c1218773f13d64643f018dc3a2497f22cd Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 3 Apr 2017 11:49:30 +0100 Subject: Add get_descendants_of_type to transforms module --- tests/transforms_tests.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/transforms_tests.py b/tests/transforms_tests.py index 128b9cb..e4f5360 100644 --- a/tests/transforms_tests.py +++ b/tests/transforms_tests.py @@ -1,7 +1,7 @@ from nose.tools import assert_equal, istest from mammoth import documents -from mammoth.transforms import get_descendants +from mammoth.transforms import get_descendants, get_descendants_of_type @istest @@ -26,3 +26,13 @@ class GetDescendantsTests(object): child = documents.run(children=[grandchild]) element = documents.paragraph(children=[child]) assert_equal([grandchild, child], get_descendants(element)) + + +@istest +class GetDescendantsOfTypeTests(object): + @istest + def filters_descendants_to_type(self): + tab = documents.tab() + run = documents.run(children=[]) + element = documents.paragraph(children=[tab, run]) + assert_equal([run], get_descendants_of_type(element, documents.Run)) -- cgit v1.2.3