From c7713d00f71e96f33ca25e2152cbec8907dcf80e Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 10 Aug 2011 16:10:10 -0300 Subject: Implemented unit test for deprecated functions. Reviewer: Hugo Parente Luciano Wolf --- tests/libsample/objecttype.h | 3 ++ tests/samplebinding/deprecated_test.py | 49 +++++++++++++++++++++++++++++++ tests/samplebinding/typesystem_sample.xml | 1 + 3 files changed, 53 insertions(+) create mode 100644 tests/samplebinding/deprecated_test.py (limited to 'tests') diff --git a/tests/libsample/objecttype.h b/tests/libsample/objecttype.h index 5cc029e85..f032a09f8 100644 --- a/tests/libsample/objecttype.h +++ b/tests/libsample/objecttype.h @@ -121,6 +121,9 @@ public: m_parent = 0; } + //Deprecated test + bool deprecatedFunction() { return true; } + private: ObjectType(const ObjectType&); ObjectType& operator=(const ObjectType&); diff --git a/tests/samplebinding/deprecated_test.py b/tests/samplebinding/deprecated_test.py new file mode 100644 index 000000000..f9607d0db --- /dev/null +++ b/tests/samplebinding/deprecated_test.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# This file is part of the Shiboken Python Bindings Generator project. +# +# Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +# +# Contact: PySide team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# version 2.1 as published by the Free Software Foundation. Please +# review the following information to ensure the GNU Lesser General +# Public License version 2.1 requirements will be met: +# http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +# # +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +# 02110-1301 USA + +import warnings +import unittest + +from sample import ObjectType + +class TestDeprecatedCall(unittest.TestCase): + """ + def setUp(self): + warnings.simplefilter("default") + + def testCallWithoutError(self): + o = ObjectType() + self.assertTrue(o.deprecatedFunction()) + """ + + def testCallWithError(self): + o = ObjectType() + warnings.simplefilter("error") + self.assertRaises(DeprecationWarning, o.deprecatedFunction) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/samplebinding/typesystem_sample.xml b/tests/samplebinding/typesystem_sample.xml index 4f1d5481b..0209aedd4 100644 --- a/tests/samplebinding/typesystem_sample.xml +++ b/tests/samplebinding/typesystem_sample.xml @@ -205,6 +205,7 @@ + -- cgit v1.2.3