Takayuki Shimizukawa committed c055abb

test refactoring: use with_setup for all's tests

Comments (0)

Files changed (1)


 def setup_module():
-    global app, lid, options, directive
+    global app
     app = TestApp() = 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
 def test_parse_name():
     def verify(objtype, name, result):
         inst = AutoDirective._registry[objtype](directive, name)
     del directive.env.temp_data['autodoc:class']
 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)'
 def test_get_doc():
     def getdocl(objtype, obj, encoding=None):
         inst = AutoDirective._registry[objtype](directive, 'tmp')
                                    '', 'Other', ' lines']
 def test_docstring_processing():
     def process(objtype, name, obj):
         inst = AutoDirective._registry[objtype](directive, name)
     assert process('function', 'h', h) == ['first line', 'third line', '']
 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'])
 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
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.