Skip to content

Commit

Permalink
Allow having different default modules for tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetrovykh committed Nov 14, 2024
1 parent e68f4d2 commit 96161a2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions edgedb/_testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ class DatabaseTestCase(ClusterTestCase, ConnectedTestCaseMixin):
SETUP = None
TEARDOWN = None
SCHEMA = None
DEFAULT_MODULE = 'test'

SETUP_METHOD = None
TEARDOWN_METHOD = None
Expand Down Expand Up @@ -492,15 +493,18 @@ def get_database_name(cls):
@classmethod
def get_setup_script(cls):
script = ''
schema = []

# Look at all SCHEMA entries and potentially create multiple
# modules, but always create the 'test' module.
schema = ['\nmodule test {}']
# modules, but always create the test module, if not `default`.
if cls.DEFAULT_MODULE != 'default':
schema.append(f'\nmodule {cls.DEFAULT_MODULE} {{}}')
for name, val in cls.__dict__.items():
m = re.match(r'^SCHEMA(?:_(\w+))?', name)
if m:
module_name = (m.group(1) or 'test').lower().replace(
'__', '.')
module_name = (
m.group(1) or cls.DEFAULT_MODULE
).lower().replace('_', '::')

with open(val, 'r') as sf:
module = sf.read()
Expand Down

0 comments on commit 96161a2

Please sign in to comment.