1#!/usr/bin/python 2 3############################################################################# 4## 5## Copyright (C) 2016 The Qt Company Ltd. 6## Contact: https://www.qt.io/licensing/ 7## 8## This file is part of the test suite of Qt for Python. 9## 10## $QT_BEGIN_LICENSE:GPL-EXCEPT$ 11## Commercial License Usage 12## Licensees holding valid commercial Qt licenses may use this file in 13## accordance with the commercial license agreement provided with the 14## Software or, alternatively, in accordance with the terms contained in 15## a written agreement between you and The Qt Company. For licensing terms 16## and conditions see https://www.qt.io/terms-conditions. For further 17## information use the contact form at https://www.qt.io/contact-us. 18## 19## GNU General Public License Usage 20## Alternatively, this file may be used under the terms of the GNU 21## General Public License version 3 as published by the Free Software 22## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 23## included in the packaging of this file. Please review the following 24## information to ensure the GNU General Public License requirements will 25## be met: https://www.gnu.org/licenses/gpl-3.0.html. 26## 27## $QT_END_LICENSE$ 28## 29############################################################################# 30 31'''Test cases for QDate''' 32 33import os 34import sys 35import unittest 36 37sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 38from init_paths import init_test_paths 39init_test_paths(False) 40 41from PySide2.QtCore import * 42 43class TestQDate (unittest.TestCase): 44 def testGetDate(self): 45 date = QDate(2009, 22, 9) 46 tuple_ = date.getDate() 47 self.assertEqual(tuple, tuple_.__class__) 48 (y, m, d) = tuple_ 49 self.assertEqual(date.year(), y) 50 self.assertEqual(date.month(), m) 51 self.assertEqual(date.day(), d) 52 53 def testGetWeekNumber(self): 54 date = QDate(2000, 1, 1) 55 tuple_ = date.weekNumber() 56 self.assertEqual(tuple, tuple_.__class__) 57 (week, yearNumber) = tuple_ 58 self.assertEqual(week, 52) 59 self.assertEqual(yearNumber, 1999) 60 61 def testBooleanCast(self): 62 today = QDate.currentDate() 63 self.assertTrue(today) 64 nodate = QDate() 65 self.assertFalse(nodate) 66 67if __name__ == '__main__': 68 unittest.main() 69