Skip to content

Commit

Permalink
More setup/teardown fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 26, 2023
1 parent 5792990 commit ac533e3
Show file tree
Hide file tree
Showing 44 changed files with 74 additions and 73 deletions.
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(unittest.TestCase, cls).setUpClass()
super(TestWFST, 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(unittest.TestCase, cls).tearDownClass()
super(TestWFST, cls).tearDownClass()

def setUp(self):
"""Run before each test."""
Expand Down
5 changes: 2 additions & 3 deletions tests/src/python/test_project_storage_oracle.py
Expand Up @@ -29,13 +29,12 @@
TEST_DATA_DIR = unitTestDataPath()


class TestPyQgsProjectStorageOracle(TestPyQgsProjectStorageBase, unittest.TestCase):
class TestPyQgsProjectStorageOracle(unittest.TestCase, TestPyQgsProjectStorageBase):

@classmethod
def setUpClass(cls):
"""Run before all tests"""

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

cls.dbconn = "host=localhost dbname=XEPDB1 port=1521 user='QGIS' password='qgis'"
if 'QGIS_ORACLETEST_DB' in os.environ:
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_project_storage_postgres.py
Expand Up @@ -32,13 +32,13 @@
TEST_DATA_DIR = unitTestDataPath()


class TestPyQgsProjectStoragePostgres(TestPyQgsProjectStorageBase, unittest.TestCase):
class TestPyQgsProjectStoragePostgres(unittest.TestCase, TestPyQgsProjectStorageBase):

@classmethod
def setUpClass(cls):
"""Run before all tests"""

super(unittest.TestCase, cls).setUpClass()
super(TestPyQgsProjectStoragePostgres, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsAFSProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsGpxProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsHanaProvider, 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(unittest.TestCase, cls).tearDownClass()
super(TestPyQgsHanaProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsMemoryProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsMemoryProviderIndexed, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsMssqlProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsOapifProvider, 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(unittest.TestCase, cls).tearDownClass()
super(TestPyQgsOapifProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsOGRProviderGpkgConformance, 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(unittest.TestCase, cls).tearDownClass()
super(TestPyQgsOGRProviderGpkgConformance, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsOracleProvider, 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
6 changes: 3 additions & 3 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsPostgresProvider, 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,7 +3236,7 @@ class TestPyQgsPostgresProviderCompoundKey(unittest.TestCase, ProviderTestCase):
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super(unittest.TestCase, cls).setUpClass()
super(TestPyQgsPostgresProviderCompoundKey, 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 @@ -3337,7 +3337,7 @@ class TestPyQgsPostgresProviderBigintSinglePk(unittest.TestCase, ProviderTestCas
@classmethod
def setUpClass(cls):
"""Run before all tests"""
super(unittest.TestCase, cls).setUpClass()
super(TestPyQgsPostgresProviderBigintSinglePk, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsPythonProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsShapefileProvider, 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(unittest.TestCase, cls).tearDownClass()
super(TestPyQgsShapefileProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestQgsSpatialiteProvider, 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(unittest.TestCase, cls).tearDownClass()
super(TestQgsSpatialiteProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestQgsVirtualLayerProvider, 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(unittest.TestCase, cls).tearDownClass()
super(TestQgsVirtualLayerProvider, 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(unittest.TestCase, cls).setUpClass()
super(TestPyQgsWFSProvider, 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(unittest.TestCase, cls).tearDownClass()
super(TestPyQgsWFSProvider, cls).tearDownClass()

def tearDown(self):
"""Run after each test"""
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(unittest.TestCase, cls).setUpClass()
super(TestQgsDelimitedTextProviderXY, 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(unittest.TestCase, cls).setUpClass()
super(TestQgsDelimitedTextProviderWKT, cls).setUpClass()
# Create test layer
srcpath = os.path.join(TEST_DATA_DIR, 'provider')
cls.basetestfile = os.path.join(srcpath, 'delimited_wkt.csv')
Expand Down
3 changes: 2 additions & 1 deletion tests/src/python/test_qgsexternalstorage_awss3.py
Expand Up @@ -31,7 +31,8 @@ class TestPyQgsExternalStorageAwsS3(TestPyQgsExternalStorageBase, unittest.TestC
def setUpClass(cls):
"""Run before all tests:"""

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

bucket_name = "test_bucket"

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

cls.temp_dir = QTemporaryDir()
cls.url = cls.temp_dir.path()
Expand All @@ -34,8 +34,8 @@ def setUpClass(cls):
def tearDownClass(cls):
"""Run after all tests"""
cls.temp_dir = None
super(unittest.TestCase, cls).tearDownClass()
super(TestPyQgsExternalStorageBase).tearDownClass()
super(TestPyQgsExternalStorageSimpleCopy, cls).tearDownClass()
unittest.TestCase.tearDownClass()

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

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

cls.url = "http://{}:{}/webdav_tests".format(
os.environ.get('QGIS_WEBDAV_HOST', 'localhost'), os.environ.get('QGIS_WEBDAV_PORT', '80'))
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgslayoutelevationprofile.py
Expand Up @@ -47,7 +47,7 @@ class TestQgsLayoutItemElevationProfile(unittest.TestCase, LayoutItemTestCase):

@classmethod
def setUpClass(cls):
super(unittest.TestCase, cls).setUpClass()
super(TestQgsLayoutItemElevationProfile, cls).setUpClass()
cls.item_class = QgsLayoutItemElevationProfile
cls.report = "<h1>Python QgsLayoutItemElevationProfile Tests</h1>\n"

Expand All @@ -56,7 +56,7 @@ 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(unittest.TestCase, cls).tearDownClass()
super(TestQgsLayoutItemElevationProfile, cls).tearDownClass()

def test_layers(self):
project = QgsProject()
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutframe.py
Expand Up @@ -22,7 +22,7 @@ class TestQgsLayoutFrame(unittest.TestCase, LayoutItemTestCase):

@classmethod
def setUpClass(cls):
super(unittest.TestCase, cls).setUpClass()
super(TestQgsLayoutFrame, cls).setUpClass()
cls.mf = None

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/src/python/test_qgslayoutlabel.py
Expand Up @@ -32,7 +32,7 @@ class TestQgsLayoutItemLabel(unittest.TestCase, LayoutItemTestCase):

@classmethod
def setUpClass(cls):
super(unittest.TestCase, cls).setUpClass()
super(TestQgsLayoutItemLabel, cls).setUpClass()
cls.item_class = QgsLayoutItemLabel

def testCase(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgslayoutlegend.py
Expand Up @@ -62,7 +62,7 @@ class TestQgsLayoutItemLegend(unittest.TestCase, LayoutItemTestCase):

@classmethod
def setUpClass(cls):
super(unittest.TestCase, cls).setUpClass()
super(TestQgsLayoutItemLegend, cls).setUpClass()
cls.item_class = QgsLayoutItemLegend
cls.report = "<h1>Python QgsLayoutItemLegend Tests</h1>\n"

Expand All @@ -71,7 +71,7 @@ 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(unittest.TestCase, cls).tearDownClass()
super(TestQgsLayoutItemLegend, cls).tearDownClass()

def testInitialSizeSymbolMapUnits(self):
"""Test initial size of legend with a symbol size in map units"""
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_qgslayoutmap.py
Expand Up @@ -66,7 +66,7 @@ class TestQgsLayoutMap(unittest.TestCase, LayoutItemTestCase):

@classmethod
def setUpClass(cls):
super(unittest.TestCase, cls).setUpClass()
super(TestQgsLayoutMap, cls).setUpClass()
cls.item_class = QgsLayoutItemMap
cls.report = "<h1>Python QgsLayoutItemMap Tests</h1>\n"

Expand All @@ -75,7 +75,7 @@ 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(unittest.TestCase, cls).tearDownClass()
super(TestQgsLayoutMap, cls).tearDownClass()

def __init__(self, methodName):
"""Run once on class initialization."""
Expand Down

0 comments on commit ac533e3

Please sign in to comment.