Skip to content

Commit

Permalink
Fix test and add Python 3.12 in CI (#498)
Browse files Browse the repository at this point in the history
* test: fix teardown order of asyncio server and client
* test: add Python 3.12
* Bump test deps
* Fix flake8 issues
  • Loading branch information
fantix authored May 28, 2024
1 parent 7386cd0 commit 0068b29
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
ignore = B008,B306,E203,E402,E731,D100,D101,D102,D103,D104,D105,W503,W504,E252,F999,F541
ignore = B008,B023,B306,E203,E402,E731,D100,D101,D102,D103,D104,D105,W503,W504,E252,F999,F541
exclude = .git,__pycache__,build,dist,.eggs
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
edgedb-version: [stable , nightly]
os: [ubuntu-latest, macos-latest, windows-2019]
loop: [asyncio, uvloop]
Expand Down
1 change: 1 addition & 0 deletions edgedb/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def _get_query_cache(self) -> QueryCache:
def _get_retry_options(self) -> typing.Optional[options.RetryOptions]:
return None

@abc.abstractmethod
def _get_state(self) -> options.State:
...

Expand Down
7 changes: 3 additions & 4 deletions edgedb/blocking_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ async def connect_addr(self, addr, timeout):
self._addr = addr
self._ping_wait_time = max(
(
getattr(
self.get_settings().get("system_config"),
"session_idle_timeout",
)
self.get_settings()
.get("system_config")
.session_idle_timeout
- DEFAULT_PING_BEFORE_IDLE_TIMEOUT
),
MINIMUM_PING_WAIT_TIME,
Expand Down
3 changes: 2 additions & 1 deletion edgedb/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def get_color() -> Color:
except KeyError:
warnings.warn(
"EDGEDB_COLOR_OUTPUT can only be one of: "
"default, auto, enabled or disabled"
"default, auto, enabled or disabled",
stacklevel=1,
)
USE_COLOR = False
2 changes: 1 addition & 1 deletion edgedb/con_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def _parse_connect_dsn_and_args(
):
# EDGEDB_PORT is set by 'docker --link' so ignore and warn
warnings.warn('EDGEDB_PORT in "tcp://host:port" format, ' +
'so will be ignored')
'so will be ignored', stacklevel=1)
env_port = None

env_dsn = os.getenv('EDGEDB_DSN')
Expand Down
3 changes: 2 additions & 1 deletion edgedb/errors/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ def _unicode_width(text):
]
except KeyError:
warnings.warn(
"EDGEDB_ERROR_HINT can only be one of: default, enabled or disabled"
"EDGEDB_ERROR_HINT can only be one of: default, enabled or disabled",
stacklevel=1,
)
SHOW_HINT = False

Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
# pycodestyle is a dependency of flake8, but it must be frozen because
# their combination breaks too often
# (example breakage: https://gitlab.com/pycqa/flake8/issues/427)
'pycodestyle~=2.6.0',
'pyflakes~=2.2.0',
'flake8-bugbear~=21.4.3',
'flake8~=3.8.1',
'pycodestyle~=2.11.1',
'pyflakes~=3.2.0',
'flake8-bugbear~=24.4.26',
'flake8~=7.0.0',
'uvloop>=0.15.1; platform_system != "Windows"',
]

Expand Down
2 changes: 1 addition & 1 deletion tests/datatypes/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def test_recorddesc_1(self):

private._RecordDescriptor(('a', 'b'))

with self.assertRaisesRegex(ValueError, f'more than {0x4000-1}'):
with self.assertRaisesRegex(ValueError, f'more than {0x4000 - 1}'):
private._RecordDescriptor(('a',) * 20000)

def test_recorddesc_2(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def test_async_parse_error_recover_02(self):
await self.client.execute('select syntax error')

for _ in range(10):
await self.client.execute('select 1; select 2;'),
await self.client.execute('select 1; select 2;')

async def test_async_exec_error_recover_01(self):
for _ in range(2):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,9 @@ async def cb(r: asyncio.StreamReader, w: asyncio.StreamWriter):
try:
await self._test_connection_broken(client, broken)
finally:
await asyncio.wait_for(client.aclose(), 5)
server.close()
await server.wait_closed()
await asyncio.wait_for(client.aclose(), 5)
broken.set()
await done.wait()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_blocking_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ async def cb(r: asyncio.StreamReader, w: asyncio.StreamWriter):
None, self._test_connection_broken, client, broken
)
finally:
await self.loop.run_in_executor(None, client.close, 5)
server.close()
await server.wait_closed()
await self.loop.run_in_executor(None, client.close, 5)
broken.set()
await done.wait()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_sync_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_sync_parse_error_recover_02(self):
self.client.execute('select syntax error')

for _ in range(10):
self.client.execute('select 1; select 2;'),
self.client.execute('select 1; select 2;')

def test_sync_exec_error_recover_01(self):
for _ in range(2):
Expand Down

0 comments on commit 0068b29

Please sign in to comment.