Skip to content

Commit

Permalink
Fix tests to support repeating
Browse files Browse the repository at this point in the history
* test_proto_parse_cardinality()
* test_edgeql_insert_default_05()
* test_edgeql_dt_sequence_01()
  • Loading branch information
fantix committed Jul 10, 2024
1 parent 3a5be70 commit 3164b5a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 2 additions & 0 deletions edb/testbase/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def wrapper(self, *args, __meth__=meth, **kwargs):
if is_repeat and not getattr(self, 'TRANSACTION_ISOLATION', False):
raise unittest.SkipTest()

self.is_repeat = is_repeat
while True:
try:
# There might be unobvious serializability
Expand Down Expand Up @@ -249,6 +250,7 @@ def __new__(mcls, name, bases, ns):


class TestCase(unittest.TestCase, metaclass=TestCaseMeta):
is_repeat: bool = False

@classmethod
def setUpClass(cls):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_edgeql_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,13 +994,15 @@ async def test_edgeql_dt_sequence_01(self):
r'''SELECT Obj { seq_prop } ORDER BY Obj.seq_prop;''',
[
{'seq_prop': 1}, {'seq_prop': 2}
] if not self.is_repeat else [
{'seq_prop': 3}, {'seq_prop': 4}
],
)

await self.assert_query_result(
r'''SELECT Obj2 { seq_prop };''',
[
{'seq_prop': 1}
{'seq_prop': 1 if not self.is_repeat else 2},
],
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_edgeql_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1951,7 +1951,7 @@ async def test_edgeql_insert_default_05(self):
r'''
SELECT DefaultTest8.number;
''',
{1, 2, 3}
{1, 2, 3} if not self.is_repeat else {4, 5, 6}
)

async def test_edgeql_insert_default_06(self):
Expand Down
13 changes: 9 additions & 4 deletions tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import asyncio
import contextlib
import os
import struct

import edgedb
Expand Down Expand Up @@ -436,10 +437,14 @@ async def test_proto_parse_cardinality(self):
)

await self._execute('CREATE TYPE ParseCardTest')
await self.con.recv_match(
protocol.CommandComplete,
status='CREATE TYPE'
)
try:
await self.con.recv_match(
protocol.CommandComplete,
status='CREATE TYPE'
)
except AssertionError:
if not self.is_repeat:
raise
await self.con.recv_match(protocol.ReadyForCommand)

await self._parse("SELECT ParseCardTest")
Expand Down

0 comments on commit 3164b5a

Please sign in to comment.