buildframework/helium/tools/common/python/lib/test/test_unittestadditions.py
author wbernard
Wed, 23 Dec 2009 19:29:07 +0200
changeset 179 d8ac696cc51f
permissions -rw-r--r--
helium_7.0-r14027
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
179
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     1
#============================================================================ 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     2
#Name        : test_unittestadditions.py 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     3
#Part of     : Helium 
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     4
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     5
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     6
#All rights reserved.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     7
#This component and the accompanying materials are made available
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     8
#under the terms of the License "Eclipse Public License v1.0"
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
     9
#which accompanies this distribution, and is available
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    10
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    11
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    12
#Initial Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    13
#Nokia Corporation - initial contribution.
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    14
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    15
#Contributors:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    16
#
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    17
#Description:
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    18
#===============================================================================
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    19
import unittest
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    20
from unittestadditions import skip
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    21
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    22
class TestSkipDecorator(unittest.TestCase):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    23
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    24
    def test_skip_false(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    25
        """ A skip(False) decorated function is executed properly """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    26
        @skip(False)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    27
        def func(data):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    28
            return data
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    29
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    30
        assert func("test") == "test"
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    31
    
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    32
    def test_skip_true(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    33
        """ A skip(True) decorated function is executed properly """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    34
        @skip(True)
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    35
        def func(data):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    36
            return data
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    37
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    38
        assert func("test") == None
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    39
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    40
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    41
    def test_skip_true_default_return(self):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    42
        """ A skip(True, 'some return value') decorated function is executed properly """
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    43
        @skip(True, "stub")
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    44
        def func(data):
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    45
            return data
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    46
        
d8ac696cc51f helium_7.0-r14027
wbernard
parents:
diff changeset
    47
        assert func("test") == "stub"