Commits

Takayuki Shimizukawa committed c055abb

test refactoring: use with_setup for all test_autodoc.py's tests

Comments (0)

Files changed (1)

tests/test_autodoc.py

 
 
 def setup_module():
-    global app, lid, options, directive
-
+    global app
     app = TestApp()
     app.builder.env.app = app
     app.builder.env.temp_data['docname'] = 'dummy'
     app.connect('autodoc-process-signature', process_signature)
     app.connect('autodoc-skip-member', skip_member)
 
+
+def teardown_module():
+    app.cleanup()
+
+
+def setup_test():
+    global options, directive
+    global processed_docstrings, processed_signatures, _warnings
+
     options = Struct(
         inherited_members = False,
         undoc_members = False,
         filename_set = set(),
     )
 
-def teardown_module():
-    app.cleanup()
+    processed_docstrings = []
+    processed_signatures = []
+    _warnings = []
 
 
 _warnings = []
         return True
 
 
+@with_setup(setup_test)
 def test_parse_name():
     def verify(objtype, name, result):
         inst = AutoDirective._registry[objtype](directive, name)
     del directive.env.temp_data['autodoc:class']
 
 
+@with_setup(setup_test)
 def test_format_signature():
     def formatsig(objtype, name, obj, args, retann):
         inst = AutoDirective._registry[objtype](directive, name)
     assert formatsig('function', 'curried4', curried4, None, None) == \
         '(b, c=42, *d, **e)'
 
+
+@with_setup(setup_test)
 def test_get_doc():
     def getdocl(objtype, obj, encoding=None):
         inst = AutoDirective._registry[objtype](directive, 'tmp')
                                    '', 'Other', ' lines']
 
 
+@with_setup(setup_test)
 def test_docstring_processing():
     def process(objtype, name, obj):
         inst = AutoDirective._registry[objtype](directive, name)
     assert process('function', 'h', h) == ['first line', 'third line', '']
     app.disconnect(lid)
 
+
+@with_setup(setup_test)
 def test_new_documenter():
     class MyDocumenter(ModuleLevelDocumenter):
         objtype = 'integer'
     assert_result_contains('.. py:data:: integer', 'module', 'test_autodoc')
 
 
-def cleanup_test_attrgetter_using():
-    del processed_docstrings[:]
-    del processed_signatures[:]
-    del directive.result[:]
-    del _warnings[:]
-    AutoDirective._special_attrgetters.clear()
-    setup_module()
-
-@with_setup(None, cleanup_test_attrgetter_using)
+@with_setup(setup_test, AutoDirective._special_attrgetters.clear)
 def test_attrgetter_using():
     def assert_getter_works(objtype, name, obj, attrs=[], **kw):
         getattr_spy = []
                        ['meth', 'inheritedmeth'])
 
 
+@with_setup(setup_test)
 def test_generate():
     def assert_warns(warn_str, objtype, name, **kw):
         inst = AutoDirective._registry[objtype](directive, name)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.