Esempio n. 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"
        )
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 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")
 def _multiple_suites(func):
     for suite in suites:
         func = T.suite(suite)(func)
     return func
 def _multiple_suites(func):
     for suite in suites:
         func = T.suite(suite)(func)
     return func