From 1b0ba0e96666e66d16ee5c83062a118605aaeadc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 24 Apr 2017 12:47:35 +0200 Subject: QtCore: Add some missing classes for I/O Add QStorageInfo, QSaveFile and QTemporaryDir. Change-Id: Ice72ed52c86f9d51ca5e60ac988abc3320a51f13 Reviewed-by: Christian Tismer --- PySide2/QtCore/CMakeLists.txt | 3 +++ PySide2/QtCore/typesystem_core_common.xml | 3 +++ tests/QtCore/CMakeLists.txt | 1 + tests/QtCore/qfile_test.py | 11 +++++++- tests/QtCore/qstorageinfo_test.py | 43 +++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/QtCore/qstorageinfo_test.py diff --git a/PySide2/QtCore/CMakeLists.txt b/PySide2/QtCore/CMakeLists.txt index 77e304c3..74f486f2 100644 --- a/PySide2/QtCore/CMakeLists.txt +++ b/PySide2/QtCore/CMakeLists.txt @@ -101,6 +101,7 @@ ${QtCore_GEN_DIR}/qrectf_wrapper.cpp ${QtCore_GEN_DIR}/qregexp_wrapper.cpp ${QtCore_GEN_DIR}/qresource_wrapper.cpp ${QtCore_GEN_DIR}/qrunnable_wrapper.cpp +${QtCore_GEN_DIR}/qsavefile_wrapper.cpp ${QtCore_GEN_DIR}/qsemaphore_wrapper.cpp ${QtCore_GEN_DIR}/qsequentialanimationgroup_wrapper.cpp ${QtCore_GEN_DIR}/qsettings_wrapper.cpp @@ -115,9 +116,11 @@ ${QtCore_GEN_DIR}/qstandardpaths_wrapper.cpp ${QtCore_GEN_DIR}/qstatemachine_signalevent_wrapper.cpp ${QtCore_GEN_DIR}/qstatemachine_wrappedevent_wrapper.cpp ${QtCore_GEN_DIR}/qstatemachine_wrapper.cpp +${QtCore_GEN_DIR}/qstorageinfo_wrapper.cpp ${QtCore_GEN_DIR}/qsysinfo_wrapper.cpp ${QtCore_GEN_DIR}/qsystemsemaphore_wrapper.cpp ${QtCore_GEN_DIR}/qt_wrapper.cpp +${QtCore_GEN_DIR}/qtemporarydir_wrapper.cpp ${QtCore_GEN_DIR}/qtemporaryfile_wrapper.cpp ${QtCore_GEN_DIR}/qtextboundaryfinder_wrapper.cpp ${QtCore_GEN_DIR}/qtextcodec_converterstate_wrapper.cpp diff --git a/PySide2/QtCore/typesystem_core_common.xml b/PySide2/QtCore/typesystem_core_common.xml index c0477cc5..f7960647 100644 --- a/PySide2/QtCore/typesystem_core_common.xml +++ b/PySide2/QtCore/typesystem_core_common.xml @@ -1939,6 +1939,7 @@ + @@ -2826,6 +2827,7 @@ + @@ -2986,6 +2988,7 @@ + diff --git a/tests/QtCore/CMakeLists.txt b/tests/QtCore/CMakeLists.txt index 5771e10f..436af3da 100644 --- a/tests/QtCore/CMakeLists.txt +++ b/tests/QtCore/CMakeLists.txt @@ -92,6 +92,7 @@ PYSIDE_TEST(qsrand_test.py) PYSIDE_TEST(qstandardpaths_test.py) PYSIDE_TEST(qstatemachine_test.py) PYSIDE_TEST(qstate_test.py) +PYSIDE_TEST(qstorageinfo_test.py) PYSIDE_TEST(qstring_test.py) PYSIDE_TEST(qsysinfo_test.py) PYSIDE_TEST(qtext_codec_test.py) diff --git a/tests/QtCore/qfile_test.py b/tests/QtCore/qfile_test.py index 954f649c..b58e9b6a 100644 --- a/tests/QtCore/qfile_test.py +++ b/tests/QtCore/qfile_test.py @@ -33,7 +33,7 @@ import tempfile import sys import py3kcompat as py3k -from PySide2.QtCore import QFile, QIODevice +from PySide2.QtCore import QDir, QFile, QIODevice, QSaveFile, QTemporaryDir class GetCharTest(unittest.TestCase): '''Test case for QIODevice.getChar in QFile''' @@ -75,5 +75,14 @@ class GetCharTest(unittest.TestCase): obj.unmap(memory) obj.close() + def testQSaveFile(self): + dir = QTemporaryDir(QDir.tempPath() + "/XXXXXX.dir") + self.assertTrue(dir.isValid()) + saveFile = QSaveFile(dir.path() + "/test.dat") + self.assertTrue(saveFile.open(QIODevice.WriteOnly)) + saveFile.write("Test") + self.assertTrue(saveFile.commit()) + self.assertTrue(os.path.exists(QDir.toNativeSeparators(saveFile.fileName()))) + if __name__ == '__main__': unittest.main() diff --git a/tests/QtCore/qstorageinfo_test.py b/tests/QtCore/qstorageinfo_test.py new file mode 100644 index 00000000..f1b90bb6 --- /dev/null +++ b/tests/QtCore/qstorageinfo_test.py @@ -0,0 +1,43 @@ +#!/usr/bin/python + +############################################################################# +## +## Copyright (C) 2017 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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$ +## +############################################################################# + +'''Unit tests for QStorageInfo''' + +import unittest + +from PySide2.QtCore import QStorageInfo + +class QandardPathsTest(unittest.TestCase): + def testQStorageInfo(self): + for v in QStorageInfo.mountedVolumes(): + print(v.name(), v.rootPath(), v.device()) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3