Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put test extension creation in setUpClass, not setUp #557

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions tests/test_postgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# limitations under the License.
#

import unittest
from collections import namedtuple

from gel import _testbase as tb
Expand All @@ -34,27 +35,29 @@ class TestPostgis(tb.SyncQueryTestCase):
Raw bytes used as sample GEOS data in (E)WKB format.
'''

def setUp(self):
super().setUp()
@classmethod
def setUpClass(cls):
super().setUpClass()

if not self.client.query_required_single('''
if not cls.client.query_required_single('''
select exists (
select sys::ExtensionPackage filter .name = 'postgis'
)
'''):
self.skipTest("feature not implemented")
raise unittest.SkipTest("feature not implemented")

self.client.execute('''
cls.client.execute('''
create extension postgis;
''')

def tearDown(self):
@classmethod
def tearDownClass(cls):
try:
self.client.execute('''
cls.client.execute('''
drop extension postgis;
''')
finally:
super().tearDown()
super().tearDownClass()

async def _test_postgis_geometry(self, wkt, wkb):
val = self.client.query_single(f'''
Expand Down
21 changes: 12 additions & 9 deletions tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import array
import math
import unittest


# An array.array subtype where indexing doesn't work.
Expand All @@ -35,29 +36,31 @@ class TestVector(tb.SyncQueryTestCase):

PGVECTOR_VER = None

def setUp(self):
super().setUp()
@classmethod
def setUpClass(cls):
super().setUpClass()

self.PGVECTOR_VER = self.client.query_single('''
cls.PGVECTOR_VER = cls.client.query_single('''
select assert_single((
select sys::ExtensionPackage filter .name = 'pgvector'
)).version
''')

if self.PGVECTOR_VER is None:
self.skipTest("feature not implemented")
if cls.PGVECTOR_VER is None:
raise unittest.SkipTest("feature not implemented")

self.client.execute('''
cls.client.execute('''
create extension pgvector;
''')

def tearDown(self):
@classmethod
def tearDownClass(cls):
try:
self.client.execute('''
cls.client.execute('''
drop extension pgvector;
''')
finally:
super().tearDown()
super().tearDownClass()

async def test_vector_01(self):
val = self.client.query_single('''
Expand Down
Loading