コード例 #1
0
    def test_suite_pollution_with_suites_attribute(self):
        """Test if suite decorator modifies the object's attribute
        objects instead of assigning a new object. Modifying _suite
        attribute objects causes suite pollution in TestCases.

        Here we test if the _suites attribute's id() remains the same
        to verify suite decorator does not modify the object's
        attribute object.
        """

        def function_to_decorate():
            pass

        function_to_decorate._suites = set(['fake_suite_1'])

        suites_before_decoration = function_to_decorate._suites

        function_to_decorate = suite('fake_suite_2')(function_to_decorate)

        suites_after_decoration =  function_to_decorate._suites

        assert_not_equal(
            id(suites_before_decoration),
            id(suites_after_decoration),
            "suites decorator modifies the object's _suite attribute"
        )
コード例 #2
0
ファイル: unittest_annotate.py プロジェクト: whoislp/Testify
def add_testcase_info(test_case, runner):
    """Uses the runner's data structure to add information about tests"""
    test_case.unittests = []

    if not hasattr(runner, 'unittests'):
        # If no db, we'll have to return
        return

    for test_method in test_case.runnable_test_methods():
        # Check if method is runnable
        test_name = runner.get_test_method_name(test_method)

        try:
            if runner.unittests[test_name]:
                test_method = suite('unittest')(test_method.__func__)
        except KeyError:
            # This test has never been in nightly - don't know if unit
            pass
コード例 #3
0
ファイル: unittest_annotate.py プロジェクト: r2k0/Testify
def add_testcase_info(test_case, runner):
    """Uses the runner's data structure to add information about tests"""
    test_case.unittests = []

    if not hasattr(runner, 'unittests'):
        # If no db, we'll have to return
        return

    for test_method in test_case.runnable_test_methods():
        # Check if method is runnable
        test_name = runner.get_test_method_name(test_method)

        try:
            if runner.unittests[test_name]:
                test_method = suite('unittest')(test_method.__func__)
        except KeyError:
            # This test has never been in nightly - don't know if unit
            pass
コード例 #4
0
    def test_suite_pollution_with_suites_attribute(self):
        """Test if suite decorator modifies the object's attribute
        objects instead of assigning a new object. Modifying _suite
        attribute objects causes suite pollution in TestCases.

        Here we test if the _suites attribute's id() remains the same
        to verify suite decorator does not modify the object's
        attribute object.
        """
        def function_to_decorate():
            pass

        function_to_decorate._suites = set(['fake_suite_1'])

        suites_before_decoration = function_to_decorate._suites

        function_to_decorate = suite('fake_suite_2')(function_to_decorate)

        suites_after_decoration = function_to_decorate._suites

        assert_not_equal(
            id(suites_before_decoration), id(suites_after_decoration),
            "suites decorator modifies the object's _suite attribute")
コード例 #5
0
 def _multiple_suites(func):
     for suite in suites:
         func = T.suite(suite)(func)
     return func
コード例 #6
0
 def _multiple_suites(func):
     for suite in suites:
         func = T.suite(suite)(func)
     return func