From 38302fd81afb5e6cb93aa75c0354889d3c011245 Mon Sep 17 00:00:00 2001 From: Dan Bungert Date: Fri, 15 Oct 2021 16:20:29 -0600 Subject: [PATCH] c/api/tests: don't prefix class with Test Fix warning: subiquity/common/api/tests/test_server.py:45 PytestCollectionWarning: cannot collect test class 'TestControllerBase' because it has a __init__ constructor --- subiquity/common/api/tests/test_endtoend.py | 20 +++++++++---------- subiquity/common/api/tests/test_server.py | 22 ++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/subiquity/common/api/tests/test_endtoend.py b/subiquity/common/api/tests/test_endtoend.py index e8e54dba..593a76e2 100644 --- a/subiquity/common/api/tests/test_endtoend.py +++ b/subiquity/common/api/tests/test_endtoend.py @@ -28,7 +28,7 @@ from subiquity.common.api.defs import api, Payload from .test_server import ( makeTestClient, - TestControllerBase, + ControllerBase, ) @@ -53,7 +53,7 @@ class TestEndToEnd(unittest.TestCase): class API: def GET() -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self) -> str: return 'value' @@ -70,7 +70,7 @@ class TestEndToEnd(unittest.TestCase): class nested: def GET() -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def endpoint_nested_GET(self) -> str: return 'value' @@ -85,7 +85,7 @@ class TestEndToEnd(unittest.TestCase): class API: def GET(arg1: str, arg2: str) -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self, arg1: str, arg2: str) -> str: return '{}+{}'.format(arg1, arg2) @@ -101,7 +101,7 @@ class TestEndToEnd(unittest.TestCase): class API: def GET(arg1: str, arg2: str = "arg2") -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self, arg1: str, arg2: str = "arg2") -> str: return '{}+{}'.format(arg1, arg2) @@ -119,7 +119,7 @@ class TestEndToEnd(unittest.TestCase): class API: def POST(data: Payload[dict]) -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def POST(self, data: dict) -> str: return data['key'] @@ -145,7 +145,7 @@ class TestEndToEnd(unittest.TestCase): class doubler: def POST(data: In) -> Out: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def doubler_POST(self, data: In) -> Out: return Out(doubled=data.val*2) @@ -161,7 +161,7 @@ class TestEndToEnd(unittest.TestCase): class API: def GET() -> int: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self) -> int: return 1/0 @@ -201,7 +201,7 @@ class TestEndToEnd(unittest.TestCase): class bad: def GET(x: int) -> int: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def good_GET(self, x: int) -> int: return x + 1 @@ -226,7 +226,7 @@ class TestEndToEnd(unittest.TestCase): class bad: def GET(x: int) -> int: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def good_GET(self, x: int) -> int: return x + 1 diff --git a/subiquity/common/api/tests/test_server.py b/subiquity/common/api/tests/test_server.py index 63aa2a6b..89d75413 100644 --- a/subiquity/common/api/tests/test_server.py +++ b/subiquity/common/api/tests/test_server.py @@ -42,7 +42,7 @@ class TestApp: project = 'test' -class TestControllerBase: +class ControllerBase: def __init__(self): self.context = Context.new(TestApp()) @@ -72,7 +72,7 @@ class TestBind(unittest.TestCase): class API: def GET() -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self) -> str: return 'value' @@ -90,7 +90,7 @@ class TestBind(unittest.TestCase): class nested: def get(): ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def nested_get(self, request, context): return 'nested' @@ -106,7 +106,7 @@ class TestBind(unittest.TestCase): class API: def GET(arg: str): ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self, arg: str): return arg @@ -122,7 +122,7 @@ class TestBind(unittest.TestCase): class API: def GET(arg: str): ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self, arg: str): return arg @@ -143,7 +143,7 @@ class TestBind(unittest.TestCase): class API: def GET(): ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self): return 1/0 @@ -162,7 +162,7 @@ class TestBind(unittest.TestCase): class API: def POST(data: Payload[str]) -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def POST(self, data: str) -> str: return data @@ -179,7 +179,7 @@ class TestBind(unittest.TestCase): class API: def GET(arg: str): ... - class Impl(TestControllerBase): + class Impl(ControllerBase): pass app = web.Application() @@ -192,7 +192,7 @@ class TestBind(unittest.TestCase): class API: def GET(arg: str): ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self, arg: int): return arg @@ -215,7 +215,7 @@ class TestBind(unittest.TestCase): class API: def GET() -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self) -> str: return 1/0 @@ -243,7 +243,7 @@ class TestBind(unittest.TestCase): class meth: def GET() -> str: ... - class Impl(TestControllerBase): + class Impl(ControllerBase): async def GET(self) -> str: return ''