class_docstr: Helper class for Markdown tests.
class_docstr_tok: ["Helper","class","for","Markdown","tests","."]
docstr: Add test methods to this class for each test file in
  `cls.cases_dir'.
docstr_tok: ["Add","test","methods","to","this","class","for","each","test","file","in","`","cls.cases_dir","'","."]
code: def generate_tests(cls):
      """Add test methods to this class for each test file in
      `cls.cases_dir'.
      """
      cases_pat = join(dirname(__file__), cls.cases_dir, "*.text")
      for text_path in glob(cases_pat):
          # Load an options (`*.opts` file, if any).
          # It must be a Python dictionary. It will be passed as
          # kwargs to the markdown function.
          opts = {}
          opts_path = splitext(text_path)[0] + ".opts"
          if exists(opts_path):
              try:
                  opts = eval(open(opts_path, "r").read())
              except Exception:
                  _, ex, _ = sys.exc_info()
                  print(
                      "WARNING: couldn't load `%s' opts file: %s"
                      % (opts_path, ex)
                  )
  
          toc_html_path = splitext(text_path)[0] + ".toc_html"
          if not exists(toc_html_path):
              toc_html_path = None
          metadata_path = splitext(text_path)[0] + ".metadata"
          if not exists(metadata_path):
              metadata_path = None
  
          test_func = lambda self, t=text_path, o=opts, c=toc_html_path, m=metadata_path: self._assertMarkdownPath(
              t, opts=o, toc_html_path=c, metadata_path=m
          )
  
          tags_path = splitext(text_path)[0] + ".tags"
          if exists(tags_path):
              tags = []
              for line in open(tags_path):
                  if "#" in line:  # allow comments in .tags files
                      line = line[: line.index("#")]
                  tags += line.split()
              test_func.tags = tags
  
          name = splitext(basename(text_path))[0]
          name = name.replace(" - ", "_")
          name = name.replace(" ", "_")
          name = re.sub("[(),]", "", name)
          test_name = "test_%s" % name
          setattr(cls, test_name, test_func)
  
imports: import os
  import sys
  from os.path import join, dirname, abspath, exists, splitext, basename
  import re
  from glob import glob
  import unittest
  import codecs
  import difflib
  import doctest
  from json import loads
label_desc: Use image node_id 4 for calling the _MarkdownTestCase obj's underlying member method code with example usage: obj.generate_tests(cls) without return types