#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Test Module Template
--------------------
"""

import unittest

from bacpypes.debugging import bacpypes_debugging, ModuleLogger

# some debugging
_debug = 0
_log = ModuleLogger(globals())


@bacpypes_debugging
def setup_module():
    if _debug: setup_module._debug("setup_module")


@bacpypes_debugging
def teardown_module():
    if _debug: teardown_module._debug("teardown_module")


@bacpypes_debugging
def setup_function(function):
    if _debug: setup_function._debug("setup_function %r", function)


@bacpypes_debugging
def teardown_function(function):
    if _debug: teardown_function._debug("teardown_function %r", function)


@bacpypes_debugging
class TestCaseTemplate(unittest.TestCase):

    @classmethod
    def setup_class(cls):
        if _debug: TestCaseTemplate._debug("setup_class")

    @classmethod
    def teardown_class(cls):
        if _debug: TestCaseTemplate._debug("teardown_class")

    def setup_method(self, method):
        if _debug: TestCaseTemplate._debug("setup_method %r", method)

    def teardown_method(self, method):
        if _debug: TestCaseTemplate._debug("teardown_method %r", method)

    def test_something(self):
        if _debug: TestCaseTemplate._debug("test_something")

    def test_something_else(self):
        if _debug: TestCaseTemplate._debug("test_something_else")

@@ -266,32 +266,128 @@
 setup_module():%0A
+    %22%22%22This function is called once at the beginning of all of the tests%0A    in this module.%22%22%22%0A
     if _debug: s
@@ -462,24 +462,103 @@
 n_module():%0A
+    %22%22%22This function is called once at the end of the tests in this module.%22%22%22%0A
     if _debu
@@ -646,32 +646,106 @@
 tion(function):%0A
+    %22%22%22This function is called before each module level test function.%22%22%22%0A
     if _debug: s
@@ -847,24 +847,97 @@
 (function):%0A
+    %22%22%22This function is called after each module level test function.%22%22%22%0A
     if _debu
@@ -1024,407 +1024,1083 @@
 ing%0A
-class TestCaseTemplate(unittest.TestCase):%0A%0A    @classmethod%0A    def setup_class(cls):%0A        if _debug: TestCaseTemplate._debug(%22setup_class%22)%0A%0A    @classmethod%0A    def teardown_class(cls):%0A        if _debug: TestCaseTemplate._debug(%22teardown_class%22)%0A%0A    def setup_method(self, method):%0A        if _debug: TestCaseTemplate._debug(%22setup_method %25r%22, method)%0A%0A    def teardown_method(self, method):
+def test_some_function(*args, **kwargs):%0A    %22%22%22This is a module level test function.%22%22%22%0A    if _debug: setup_function._debug(%22test_some_function %25r %25r%22, args, kwargs)%0A%0A%0A@bacpypes_debugging%0Aclass TestCaseTemplate(unittest.TestCase):%0A%0A    @classmethod%0A    def setup_class(cls):%0A        %22%22%22This function is called once before the test case is instantiated%0A        for each of the tests.%22%22%22%0A        if _debug: TestCaseTemplate._debug(%22setup_class%22)%0A%0A    @classmethod%0A    def teardown_class(cls):%0A        %22%22%22This function is called once at the end after the last instance%0A        of the test case has been abandon.%22%22%22%0A        if _debug: TestCaseTemplate._debug(%22teardown_class%22)%0A%0A    def setup_method(self, method):%0A        %22%22%22This function is called before each test method is called as is%0A        given a reference to the test method.%22%22%22%0A        if _debug: TestCaseTemplate._debug(%22setup_method %25r%22, method)%0A%0A    def teardown_method(self, method):%0A        %22%22%22This function is called after each test method has been called and%0A        is given a reference to the test method.%22%22%22
 %0A   
@@ -2192,32 +2192,84 @@
 omething(self):%0A
+        %22%22%22This is a method level test function.%22%22%22%0A
         if _debu
@@ -2341,32 +2341,90 @@
 ing_else(self):%0A
+        %22%22%22This is another method level test function.%22%22%22%0A
         if _debu
@@ -2469,12 +2469,13 @@
 hing_else%22)%0A
+%0A

add doc strings because I keep forgetting the order