<commit_before>import contextlib
import StringIO
import unittest
from xml.etree import ElementTree

from kiva.tests.drawing_tester import DrawingTester
from kiva.svg import GraphicsContext


class TestSVGDrawing(DrawingTester, unittest.TestCase):

    def create_graphics_context(self, width, height):
        return GraphicsContext((width, height))

    @contextlib.contextmanager
    def draw_and_check(self):
        yield
        filename = "{0}.svg".format(self.filename)
        self.gc.save(filename)
        tree = ElementTree.parse(filename)
        elements = [element for element in tree.iter()]
        if not len(elements) in [4, 7]:
            self.fail('The expected number of elements was not found')


if __name__ == "__main__":
    unittest.main()<commit_msg>use getiterator instead of iter<commit_after>import contextlib
import StringIO
import unittest
from xml.etree import ElementTree

from kiva.tests.drawing_tester import DrawingTester
from kiva.svg import GraphicsContext


class TestSVGDrawing(DrawingTester, unittest.TestCase):

    def create_graphics_context(self, width, height):
        return GraphicsContext((width, height))

    @contextlib.contextmanager
    def draw_and_check(self):
        yield
        filename = "{0}.svg".format(self.filename)
        self.gc.save(filename)
        tree = ElementTree.parse(filename)
        elements = [element for element in tree.getiterator()]
        if not len(elements) in [4, 7]:
            self.fail('The expected number of elements was not found')


if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.08855154965211891, 'fraction_numerical': 0.003795066413662239, 'mean_word_length': 3.5855072463768116, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6694301', 'n_tokens_mistral': 451, 'n_tokens_neox': 440, 'n_words': 125}