Skip to content

Instantly share code, notes, and snippets.

@curtisforrester
Created September 25, 2015 13:48
Show Gist options
  • Save curtisforrester/589405ead3627db1b267 to your computer and use it in GitHub Desktop.
Save curtisforrester/589405ead3627db1b267 to your computer and use it in GitHub Desktop.
A example of Python code tagged for doc_tags.
class CompileTags(object):
"""
Compiles a source module and extracts our tags from docstrings.
:unit_test_class: CompileTagsTests
"""
re_keyword_line = r':(unit_test[_a-z]*): *([a-zA-Z_]*)'
def __init__(self, module_name, verbose=False):
"""
:unit_test: create_instance
:unit_test: create_invalid_module
"""
m = re.search(r'([a-zA-Z_]+)[.py]?', module_name)
if not m:
raise Exception('Invalid module name')
self.module_name = m.group(1)
self.unit_test_module = []
self.unit_test_class = []
self.verbose = verbose
self.unit_test_module.append(self.module_name) # Push default module and class unittest names
# TODO: Might want to camel case the module name for the default test name
self.unit_test_class.append('%sTests' % self.module_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment