Skip to content
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
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pyfronius = { workspace = true }

[dependency-groups]
dev = [
"aiounittest>=1.5.0",
"coverage>=7.6.1",
"pre-commit>=3.5.0",
"pyfronius",
Expand Down
8 changes: 4 additions & 4 deletions tests/test_web_v0.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NoFroniusWebTest(AsyncTestCaseSetup):
session = None
fronius = None

async def setUp(self):
async def asyncSetUp(self):
# Pick an unused port to ensure the connection attempt fails deterministically
self.port = _get_unused_port()
self.url = "http://{}:{}".format(ADDRESS, self.port)
Expand Down Expand Up @@ -92,7 +92,7 @@ class FroniusWebDetectVersionV0(AsyncTestCaseSetup):
session = None
fronius = None

async def setUp(self):
async def asyncSetUp(self):
# Create an arbitrary subclass of TCP Server as the server to be
# started
# Here, it is an Simple HTTP file serving server
Expand Down Expand Up @@ -138,7 +138,7 @@ class FroniusWebTestV0(AsyncTestCaseSetup):
session = None
fronius = None

async def setUp(self):
async def asyncSetUp(self):
# Create an arbitrary subclass of TCP Server as the server to be
# started
# Here, it is an Simple HTTP file serving server
Expand Down Expand Up @@ -210,7 +210,7 @@ async def test_fronius_get_no_data(self):
with self.assertRaises(pyfronius.NotSupportedError):
await self.fronius.current_storage_data()

async def tearDown(self):
async def asyncTearDown(self):
await self.session.close()
self.server_control.stop_server()
pass
Expand Down
8 changes: 4 additions & 4 deletions tests/test_web_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class NoFroniusWebTest(AsyncTestCaseSetup):
session = None
fronius = None

async def setUp(self):
async def asyncSetUp(self):
# Pick an unused port to ensure the connection attempt fails deterministically
self.port = _get_unused_port()
self.url = "http://{}:{}".format(ADDRESS, self.port)
Expand Down Expand Up @@ -104,7 +104,7 @@ class FroniusWebDetectVersionV1(AsyncTestCaseSetup):
session = None
fronius = None

async def setUp(self):
async def asyncSetUp(self):
# Create an arbitrary subclass of TCP Server as the server to be
# started
# Here, it is an Simple HTTP file serving server
Expand Down Expand Up @@ -150,7 +150,7 @@ class FroniusWebTestV1(AsyncTestCaseSetup):
session = None
fronius = None

async def setUp(self):
async def asyncSetUp(self):
# Create an arbitrary subclass of TCP Server as the server to be
# started
# Here, it is an Simple HTTP file serving server
Expand Down Expand Up @@ -259,7 +259,7 @@ async def test_fronius_fetch(self):
],
)

async def tearDown(self):
async def asyncTearDown(self):
await self.session.close()
self.server_control.stop_server()
pass
Expand Down
25 changes: 4 additions & 21 deletions tests/util.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,17 @@
import asyncio
import contextlib
import socket

import aiounittest
from aiounittest import async_test
import unittest

ADDRESS = "localhost"


class AsyncTestCaseSetup(aiounittest.AsyncTestCase):
async def setUp(self):
class AsyncTestCaseSetup(unittest.IsolatedAsyncioTestCase):
async def asyncSetUp(self):
pass

async def tearDown(self):
async def asyncTearDown(self):
pass

def __getattribute__(self, name):
attr = object.__getattribute__(self, name)
if name.startswith("test_") and asyncio.iscoroutinefunction(attr):

async def wrapped_attr():
await self.setUp()
await attr()
await self.tearDown()

res = async_test(wrapped_attr, loop=self.get_event_loop())
return res
else:
return attr


def _get_unused_port() -> int:
"""Return an unused localhost port for negative connection tests."""
Expand Down
13 changes: 0 additions & 13 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading