#! /usr/bin/env python

from abjad import *
from abjad.tools import iotools
import doctest
import os


def _main():
   total_modules = 0
   for dir_path, dir_names, file_names in os.walk('.'):
      for file_name in file_names:
         if file_name.endswith('.py') and \
            not file_name.startswith('test_') and \
            not file_name == '__init__.py':
            total_modules += 1
            full_file_name = os.path.abspath(os.path.join(dir_path, file_name))
            doctest.testfile(full_file_name, module_relative = False, globs = globals(),
               optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS)
   print 'Total modules: %s' % total_modules
   

if __name__ == '__main__':
   iotools.clear_terminal()
   _main()
