From 83c2af0e7ecf68d9dbe4730916190bc5819b533e Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Mon, 16 Aug 2021 18:27:42 -0400 Subject: [PATCH] Fix resource subclass abc tests on Python 3.7 --- tests/unit/providers/test_resource_py35.py | 25 ++++++++-------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/tests/unit/providers/test_resource_py35.py b/tests/unit/providers/test_resource_py35.py index 6ab7593c..2a38881e 100644 --- a/tests/unit/providers/test_resource_py35.py +++ b/tests/unit/providers/test_resource_py35.py @@ -165,10 +165,9 @@ class ResourceTests(unittest.TestCase): with self.assertRaises(TypeError) as context: TestResource() - self.assertEqual( - "Can't instantiate abstract class TestResource with abstract methods init, shutdown", - str(context.exception), - ) + self.assertIn("Can't instantiate abstract class TestResource", str(context.exception)) + self.assertIn("init, shutdown", str(context.exception)) + def test_init_class_abc_shutdown_definition_is_required(self): class TestResource(resources.Resource): @@ -178,10 +177,8 @@ class ResourceTests(unittest.TestCase): with self.assertRaises(TypeError) as context: TestResource() - self.assertEqual( - "Can't instantiate abstract class TestResource with abstract method shutdown", - str(context.exception), - ) + self.assertIn("Can't instantiate abstract class TestResource", str(context.exception)) + self.assertIn("shutdown", str(context.exception)) def test_init_not_callable(self): provider = providers.Resource(1) @@ -507,10 +504,8 @@ class AsyncResourceTest(AsyncTestCase): with self.assertRaises(TypeError) as context: TestAsyncResource() - self.assertEqual( - "Can't instantiate abstract class TestAsyncResource with abstract methods init, shutdown", - str(context.exception), - ) + self.assertIn("Can't instantiate abstract class TestAsyncResource", str(context.exception)) + self.assertIn("init, shutdown", str(context.exception)) def test_init_async_class_abc_shutdown_definition_is_required(self): class TestAsyncResource(resources.AsyncResource): @@ -520,10 +515,8 @@ class AsyncResourceTest(AsyncTestCase): with self.assertRaises(TypeError) as context: TestAsyncResource() - self.assertEqual( - "Can't instantiate abstract class TestAsyncResource with abstract method shutdown", - str(context.exception), - ) + self.assertIn("Can't instantiate abstract class TestAsyncResource", str(context.exception)) + self.assertIn("shutdown", str(context.exception)) def test_init_with_error(self): async def _init():