diff options
Diffstat (limited to 'sources/pyside6/tests/QtCore/qbitarray_test.py')
-rw-r--r-- | sources/pyside6/tests/QtCore/qbitarray_test.py | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/sources/pyside6/tests/QtCore/qbitarray_test.py b/sources/pyside6/tests/QtCore/qbitarray_test.py index 1fee4f69c..70452eab1 100644 --- a/sources/pyside6/tests/QtCore/qbitarray_test.py +++ b/sources/pyside6/tests/QtCore/qbitarray_test.py @@ -1,35 +1,10 @@ #!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 '''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators''' +import gc import os import sys import unittest @@ -41,6 +16,7 @@ init_test_paths(False) from PySide6.QtCore import QBitArray + def bool_list_from_qbitarray(qbitarray): '''This function is used instead of a list comprehension because the QBitArray is being tested also to check if it is providing @@ -51,11 +27,12 @@ def bool_list_from_qbitarray(qbitarray): qbitarray_values.append(qbitarray.at(i)) return qbitarray_values + class QBitArrayIsIterableTest(unittest.TestCase): '''Tests if QBitArray class is iterable and also '~' (__invert__) and bitwise operators''' def setUp(self): - #Acquire resources + # Acquire resources self.qbitarray = QBitArray(3) self.qbitarray_values = [True, False, False] # WARNING: do not pythonify the following loop @@ -71,15 +48,17 @@ class QBitArrayIsIterableTest(unittest.TestCase): self.other_qbitarray.setBit(i, self.other_qbitarray_values[i]) def tearDown(self): - #Release resources + # Release resources del self.qbitarray del self.other_qbitarray del self.qbitarray_values del self.other_qbitarray_values del self.inverted_qbitarray_values + # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion + gc.collect() def testQBitArrayIsIterable(self): - #Tests if QBitArray class is iterable + # Tests if QBitArray class is iterable qbitarray_is_iterable = True try: bitarray = [bit for bit in self.qbitarray] @@ -88,7 +67,7 @@ class QBitArrayIsIterableTest(unittest.TestCase): self.assertTrue(qbitarray_is_iterable) def testQBitArrayInvertOperator(self): - #Tests QBitArray '~' (__invert__) operator + # Tests QBitArray '~' (__invert__) operator inverted_qbitarray = ~self.qbitarray # WARNING: do not pythonify the following loop, the # iterability of QBitArray class is tested in another place @@ -96,7 +75,7 @@ class QBitArrayIsIterableTest(unittest.TestCase): self.assertEqual(self.inverted_qbitarray_values, inverted_qbitarray_values) def testQBitArrayOrBitwiseOperator(self): - #Tests QBitArray '|' (or) operator + # Tests QBitArray '|' (or) operator has_or_bitwise_operator = True ored_qbitarray, ored_bool_list = None, None try: @@ -108,7 +87,7 @@ class QBitArrayIsIterableTest(unittest.TestCase): self.assertEqual(bool_list_from_qbitarray(ored_qbitarray), ored_bool_list) def testQBitArrayAndBitwiseOperator(self): - #Tests QBitArray '&' (and) operator + # Tests QBitArray '&' (and) operator has_and_bitwise_operator = True anded_qbitarray, anded_bool_list = None, None try: @@ -120,7 +99,7 @@ class QBitArrayIsIterableTest(unittest.TestCase): self.assertEqual(bool_list_from_qbitarray(anded_qbitarray), anded_bool_list) def testQBitArrayXorBitwiseOperator(self): - #Tests QBitArray '^' (xor) operator + # Tests QBitArray '^' (xor) operator has_xor_bitwise_operator = True xored_qbitarray, xored_bool_list = None, None try: |