<commit_before>import doctest
import unittest
import glob
import os

#from zope.testing import doctest
from rtree.index import major_version, minor_version

from .data import boxes15, boxes3, points

optionflags = (doctest.REPORT_ONLY_FIRST_FAILURE |
               doctest.NORMALIZE_WHITESPACE |
               doctest.ELLIPSIS)

def list_doctests():
    # Skip the custom storage test unless we have libspatialindex 1.8+.
    return [filename
            for filename
            in glob.glob(os.path.join(os.path.dirname(__file__), '*.txt'))
            if not (
                filename.endswith('customStorage.txt') 
                and major_version < 2 and minor_version < 8)]

def open_file(filename, mode='r'):
    """Helper function to open files from within the tests package."""
    return open(os.path.join(os.path.dirname(__file__), filename), mode)

def setUp(test):
    test.globs.update(dict(
            open_file = open_file,
            boxes15=boxes15,
            boxes3=boxes3,
            points=points
            ))

def test_suite():
    return unittest.TestSuite(
        [doctest.DocFileSuite(os.path.basename(filename),
                              optionflags=optionflags,
                              setUp=setUp)
         for filename
         in sorted(list_doctests())])

print(list_doctests())

if __name__ == "__main__":
    runner = unittest.TextTestRunner()
    runner.run(test_suite())<commit_msg>print libspatialindex version as part of test run<commit_after>import doctest
import unittest
import glob
import os

#from zope.testing import doctest
from rtree.index import major_version, minor_version, patch_version

from .data import boxes15, boxes3, points

optionflags = (doctest.REPORT_ONLY_FIRST_FAILURE |
               doctest.NORMALIZE_WHITESPACE |
               doctest.ELLIPSIS)

def list_doctests():
    # Skip the custom storage test unless we have libspatialindex 1.8+.
    return [filename
            for filename
            in glob.glob(os.path.join(os.path.dirname(__file__), '*.txt'))
            if not (
                filename.endswith('customStorage.txt') 
                and major_version < 2 and minor_version < 8)]

def open_file(filename, mode='r'):
    """Helper function to open files from within the tests package."""
    return open(os.path.join(os.path.dirname(__file__), filename), mode)

def setUp(test):
    test.globs.update(dict(
            open_file = open_file,
            boxes15=boxes15,
            boxes3=boxes3,
            points=points
            ))

def test_suite():
    return unittest.TestSuite(
        [doctest.DocFileSuite(os.path.basename(filename),
                              optionflags=optionflags,
                              setUp=setUp)
         for filename
         in sorted(list_doctests())])

version = 'libspatialindex version {0}.{1}.{2}'.format(major_version, minor_version, patch_version)
print(version)
print(list_doctests())

if __name__ == "__main__":
    runner = unittest.TextTestRunner()
    runner.run(test_suite())
{'fraction_non_alphanumeric': 0.09559789750328515, 'fraction_numerical': 0.009526938239159002, 'mean_word_length': 2.516166281755196, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '4403533', 'n_tokens_mistral': 915, 'n_tokens_neox': 886, 'n_words': 210}