Skip to content

Commit

Permalink
Fix more super calls
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 26, 2023
1 parent 8d62757 commit 5792990
Show file tree
Hide file tree
Showing 62 changed files with 92 additions and 70 deletions.
1 change: 0 additions & 1 deletion tests/src/python/qgslayermetadataprovidertestbase.py
Expand Up @@ -43,7 +43,6 @@ class LayerMetadataProviderTestBase():
@classmethod
def setUpClass(cls):
"""Run before all tests"""

QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain(cls.__name__)
QCoreApplication.setApplicationName(cls.__name__)
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/stylestoragebase.py
Expand Up @@ -31,6 +31,7 @@ class StyleStorageTestCaseBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()

QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain("%s.com" % __name__)
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_db_manager_gpkg.py
Expand Up @@ -58,6 +58,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
"""Run after all tests"""
super().tearDownClass()

QgsSettings().clear()
shutil.rmtree(cls.basetestpath, True)
Expand Down
2 changes: 2 additions & 0 deletions tests/src/python/test_disabled_tests.py
Expand Up @@ -63,6 +63,7 @@ class TestQgsDisabledTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests."""
super().setUpClass()
testPath = TEST_DATA_DIR + '/' + 'bug_17878.gpkg'
# Copy it
tempdir = tempfile.mkdtemp()
Expand All @@ -75,6 +76,7 @@ def setUpClass(cls):
def tearDownClass(cls):
"""Run after all tests."""
cls.vl = None
super().tearDownClass()

@unittest.skipIf(QT_VERSION >= 0x050d00, 'Crashes on newer Qt/PyQt versions')
def testPythonCreateChildrenCalledFromCplusplus(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_offline_editing_wfs.py
Expand Up @@ -52,7 +52,7 @@ class TestWFST(unittest.TestCase, OfflineTestBase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
cls.port = QGIS_SERVER_OFFLINE_PORT
# Create tmp folder
cls.temp_path = tempfile.mkdtemp()
Expand Down Expand Up @@ -80,7 +80,7 @@ def setUpClass(cls):
def tearDownClass(cls):
"""Run after all tests"""
rmtree(cls.temp_path)
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def setUp(self):
"""Run before each test."""
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_project_storage_oracle.py
Expand Up @@ -35,7 +35,7 @@ class TestPyQgsProjectStorageOracle(TestPyQgsProjectStorageBase, unittest.TestCa
def setUpClass(cls):
"""Run before all tests"""

super().setUpClass()
super(unittest.TestCase, cls).setUpClass()

cls.dbconn = "host=localhost dbname=XEPDB1 port=1521 user='QGIS' password='qgis'"
if 'QGIS_ORACLETEST_DB' in os.environ:
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_project_storage_postgres.py
Expand Up @@ -38,7 +38,7 @@ class TestPyQgsProjectStoragePostgres(TestPyQgsProjectStorageBase, unittest.Test
def setUpClass(cls):
"""Run before all tests"""

super().setUpClass()
super(unittest.TestCase, cls).setUpClass()

cls.dbconn = 'service=qgis_test'
if 'QGIS_PGTEST_DB' in os.environ:
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_afs.py
Expand Up @@ -93,7 +93,7 @@ def treat_time_as_string(self):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()

QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain("TestPyQgsAFSProvider.com")
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_gpx.py
Expand Up @@ -41,7 +41,7 @@ def createLayer(cls):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create test layer
cls.vl = cls.createLayer()
assert (cls.vl.isValid())
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_hana.py
Expand Up @@ -56,7 +56,7 @@ class TestPyQgsHanaProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
cls.uri = 'driver=\'/usr/sap/hdbclient/libodbcHDB.so\' host=localhost port=30015 user=SYSTEM ' \
'password=mypassword sslEnabled=true sslValidateCertificate=False'
if 'QGIS_HANA_TEST_DB' in os.environ:
Expand All @@ -81,7 +81,7 @@ def tearDownClass(cls):

QgsHanaProviderUtils.cleanUp(cls.conn, cls.schemaName)
cls.conn.close()
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def createVectorLayer(self, conn_parameters, layer_name):
layer = QgsHanaProviderUtils.createVectorLayer(self.uri + ' ' + conn_parameters, layer_name)
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_memory.py
Expand Up @@ -82,7 +82,7 @@ def createLayer(cls):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create test layer
cls.vl = cls.createLayer()
assert (cls.vl.isValid())
Expand Down Expand Up @@ -1017,7 +1017,7 @@ class TestPyQgsMemoryProviderIndexed(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create test layer

cls.vl = QgsVectorLayer(
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_mssql.py
Expand Up @@ -45,7 +45,7 @@ class TestPyQgsMssqlProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# These are the connection details for the SQL Server instance running on Travis
cls.dbconn = "service='testsqlserver' user=sa password='<YourStrong!Passw0rd>' "
if 'QGIS_MSSQLTEST_DB' in os.environ:
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_oapif.py
Expand Up @@ -158,7 +158,7 @@ class TestPyQgsOapifProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()

QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain("TestPyQgsOapifProvider.com")
Expand Down Expand Up @@ -218,7 +218,7 @@ def tearDownClass(cls):
QgsSettings().clear()
shutil.rmtree(cls.basetestpath, True)
cls.vl = None # so as to properly close the provider and remove any temporary file
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def testCrs(self):
self.assertEqual(self.source.sourceCrs().authid(), 'OGC:CRS84')
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_ogr_gpkg.py
Expand Up @@ -79,7 +79,7 @@ class TestPyQgsOGRProviderGpkgConformance(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create test layer
cls.basetestpath = tempfile.mkdtemp()
cls.repackfilepath = tempfile.mkdtemp()
Expand Down Expand Up @@ -120,7 +120,7 @@ def tearDownClass(cls):
del cls.unique_not_null_constraints
for dirname in cls.dirs_to_cleanup:
shutil.rmtree(dirname, True)
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def getSource(self):
tmpdir = tempfile.mkdtemp()
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_oracle.py
Expand Up @@ -47,7 +47,7 @@ class TestPyQgsOracleProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
cls.dbconn = "host=localhost dbname=XEPDB1 port=1521 user='QGIS' password='qgis'"
if 'QGIS_ORACLETEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_ORACLETEST_DB']
Expand Down
5 changes: 3 additions & 2 deletions tests/src/python/test_provider_postgres.py
Expand Up @@ -82,7 +82,7 @@ class TestPyQgsPostgresProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
cls.dbconn = 'service=qgis_test'
if 'QGIS_PGTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_PGTEST_DB']
Expand Down Expand Up @@ -3236,6 +3236,7 @@ class TestPyQgsPostgresProviderCompoundKey(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super(unittest.TestCase, cls).setUpClass()
cls.dbconn = 'service=qgis_test'
if 'QGIS_PGTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_PGTEST_DB']
Expand Down Expand Up @@ -3336,7 +3337,7 @@ class TestPyQgsPostgresProviderBigintSinglePk(unittest.TestCase, ProviderTestCas
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
cls.dbconn = 'service=qgis_test'
if 'QGIS_PGTEST_DB' in os.environ:
cls.dbconn = os.environ['QGIS_PGTEST_DB']
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_provider_python.py
Expand Up @@ -84,7 +84,7 @@ def createLayer(cls):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Register the provider
r = QgsProviderRegistry.instance()
metadata = QgsProviderMetadata(PyProvider.providerKey(), PyProvider.description(), PyProvider.createProvider)
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_shapefile.py
Expand Up @@ -63,7 +63,7 @@ class TestPyQgsShapefileProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create test layer
cls.basetestpath = tempfile.mkdtemp()
cls.repackfilepath = tempfile.mkdtemp()
Expand Down Expand Up @@ -93,7 +93,7 @@ def tearDownClass(cls):
del cls.vl_poly
for dirname in cls.dirs_to_cleanup:
shutil.rmtree(dirname, True)
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def treat_time_as_string(self):
return True
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_spatialite.py
Expand Up @@ -71,7 +71,7 @@ class TestQgsSpatialiteProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
print(' ### Setup Spatialite Provider Test Class')
# setup provider for base tests
cls.vl = QgsVectorLayer(
Expand Down Expand Up @@ -308,7 +308,7 @@ def tearDownClass(cls):
# os.remove(cls.dbname)
for dirname in cls.dirs_to_cleanup:
shutil.rmtree(dirname, True)
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def getSource(self):
tmpdir = tempfile.mkdtemp()
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_virtual.py
Expand Up @@ -52,7 +52,7 @@ class TestQgsVirtualLayerProvider(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create the layer for the common provider tests
shp = os.path.join(TEST_DATA_DIR, 'provider/shapefile.shp')
d = QgsVirtualLayerDefinition()
Expand All @@ -75,7 +75,7 @@ def tearDownClass(cls):
"""Run after all tests"""
del cls.vl
del cls.poly_vl
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def treat_datetime_as_string(self):
return True
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_wfs.py
Expand Up @@ -100,7 +100,7 @@ def treat_time_as_string(self):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()

QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain("TestPyQgsWFSProvider.com")
Expand Down Expand Up @@ -460,7 +460,7 @@ def tearDownClass(cls):
QgsSettings().clear()
shutil.rmtree(cls.basetestpath, True)
cls.vl = None # so as to properly close the provider and remove any temporary file
super().tearDownClass()
super(unittest.TestCase, cls).tearDownClass()

def tearDown(self):
"""Run after each test"""
Expand Down
2 changes: 2 additions & 0 deletions tests/src/python/test_qgsannotationlinetextitem.py
Expand Up @@ -50,13 +50,15 @@ class TestQgsAnnotationLineTextItem(unittest.TestCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.report = "<h1>Python QgsAnnotationLineTextItem Tests</h1>\n"

@classmethod
def tearDownClass(cls):
report_file_path = f"{QDir.tempPath()}/qgistest.html"
with open(report_file_path, 'a') as report_file:
report_file.write(cls.report)
super().tearDownClass()

def testBasic(self):
item = QgsAnnotationLineTextItem('my text', QgsLineString(((12, 13), (13, 13.1), (14, 13))))
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgscodeeditorpython.py
Expand Up @@ -33,6 +33,7 @@ class TestQgsCodeEditorPython(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain("QGIS_TestQgsCodeEditorPython.com")
QCoreApplication.setApplicationName("QGIS_TestQgsCodeEditorPython")
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgsdelimitedtextprovider.py
Expand Up @@ -144,7 +144,7 @@ class TestQgsDelimitedTextProviderXY(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create test layer
srcpath = os.path.join(TEST_DATA_DIR, 'provider')
cls.basetestfile = os.path.join(srcpath, 'delimited_xy.csv')
Expand Down Expand Up @@ -177,7 +177,7 @@ class TestQgsDelimitedTextProviderWKT(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
# Create test layer
srcpath = os.path.join(TEST_DATA_DIR, 'provider')
cls.basetestfile = os.path.join(srcpath, 'delimited_wkt.csv')
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsexternalstorage_awss3.py
Expand Up @@ -31,7 +31,7 @@ class TestPyQgsExternalStorageAwsS3(TestPyQgsExternalStorageBase, unittest.TestC
def setUpClass(cls):
"""Run before all tests:"""

super().setUpClass()
super(unittest.TestCase, cls).setUpClass()

bucket_name = "test_bucket"

Expand Down
2 changes: 0 additions & 2 deletions tests/src/python/test_qgsexternalstorage_base.py
Expand Up @@ -34,7 +34,6 @@ class TestPyQgsExternalStorageBase:
@classmethod
def setUpClass(cls):
"""Run before all tests:"""
super().setUpClass()
QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain(cls.__name__)
QCoreApplication.setApplicationName(cls.__name__)
Expand Down Expand Up @@ -62,7 +61,6 @@ def tearDownClass(cls):
"""Run after all tests"""
cls.registry.unregisterExternalStorage(cls.storage)
assert cls.storageType not in cls.registry.externalStorages()
super().tearDownClass()

def setUp(self):
"""Run before each test."""
Expand Down
6 changes: 4 additions & 2 deletions tests/src/python/test_qgsexternalstorage_simplecopy.py
Expand Up @@ -24,16 +24,18 @@ class TestPyQgsExternalStorageSimpleCopy(TestPyQgsExternalStorageBase, unittest.
@classmethod
def setUpClass(cls):
"""Run before all tests:"""
super().setUpClass()
super(unittest.TestCase, cls).setUpClass()
super(TestPyQgsExternalStorageBase).setUpClass()

cls.temp_dir = QTemporaryDir()
cls.url = cls.temp_dir.path()

@classmethod
def tearDownClass(cls):
"""Run after all tests"""
super().tearDownClass()
cls.temp_dir = None
super(unittest.TestCase, cls).tearDownClass()
super(TestPyQgsExternalStorageBase).tearDownClass()

def testStoreMissingAuth(self):
"""Override this one because there is authentication for SimpleCopy external storage"""
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgsexternalstorage_webdav.py
Expand Up @@ -28,7 +28,7 @@ class TestPyQgsExternalStorageWebDav(TestPyQgsExternalStorageBase, unittest.Test
def setUpClass(cls):
"""Run before all tests:"""

super().setUpClass()
super(unittest.TestCase, cls).setUpClass()

cls.url = "http://{}:{}/webdav_tests".format(
os.environ.get('QGIS_WEBDAV_HOST', 'localhost'), os.environ.get('QGIS_WEBDAV_PORT', '80'))
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/test_qgslayermetadataresultsmodel.py
Expand Up @@ -49,6 +49,7 @@ class TestQgsLayerMetadataResultModels(TestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super().setUpClass()

QCoreApplication.setOrganizationName("QGIS_Test")
QCoreApplication.setOrganizationDomain(cls.__name__)
Expand Down

0 comments on commit 5792990

Please sign in to comment.