X Tutup
Skip to content

Commit f3e89d4

Browse files
committed
typing: Add class variables to testcases
testtools was recently bumped to a version that is typed, which means we now see type hints for that library. As a result, we now see issues with variables defined in tests via setUpClass. Note that the issue lies with mypy and not testtools, however: mypy doesn't adding class variables via assignment [1]. [1] python/mypy#8723 Change-Id: I8b09846ff8fc6ee51ba03531f5b41039282ee1c0 Signed-off-by: Stephen Finucane <stephenfin@redhat.com> (cherry picked from commit aeb0c68)
1 parent 64cf0c3 commit f3e89d4

File tree

18 files changed

+114
-32
lines changed

18 files changed

+114
-32
lines changed

openstackclient/tests/functional/common/test_extension.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# License for the specific language governing permissions and limitations
1414
# under the License.
1515

16+
from typing import ClassVar
17+
1618
from tempest.lib import exceptions as tempest_exc
1719

1820
from openstackclient.tests.functional import base
@@ -21,6 +23,8 @@
2123
class ExtensionTests(base.TestCase):
2224
"""Functional tests for extension"""
2325

26+
haz_network: ClassVar[bool]
27+
2428
@classmethod
2529
def setUpClass(cls):
2630
super().setUpClass()

openstackclient/tests/functional/common/test_quota.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13+
from typing import ClassVar
1314
import uuid
1415

1516
from tempest.lib.common.utils import data_utils
@@ -25,7 +26,8 @@ class QuotaTests(base.TestCase):
2526
test runs as these may run in parallel and otherwise step on each other.
2627
"""
2728

28-
PROJECT_NAME: str
29+
haz_network: ClassVar[bool]
30+
PROJECT_NAME: ClassVar[str]
2931

3032
@classmethod
3133
def setUpClass(cls):

openstackclient/tests/functional/compute/v2/test_flavor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13+
from typing import ClassVar
1314
import uuid
1415

1516
from openstackclient.tests.functional import base
@@ -19,6 +20,7 @@ class FlavorTests(base.TestCase):
1920
"""Functional tests for flavor."""
2021

2122
PROJECT_NAME = uuid.uuid4().hex
23+
PROJECT_ID: ClassVar[str]
2224

2325
@classmethod
2426
def setUpClass(cls):
@@ -28,7 +30,7 @@ def setUpClass(cls):
2830
"project create --enable " + cls.PROJECT_NAME,
2931
parse_output=True,
3032
)
31-
cls.project_id = cmd_output["id"]
33+
cls.PROJECT_ID = cmd_output["id"]
3234

3335
@classmethod
3436
def tearDownClass(cls):

openstackclient/tests/functional/compute/v2/test_server.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import itertools
1414
import json
1515
import time
16+
from typing import ClassVar
1617
import uuid
1718

1819
from tempest.lib import exceptions
@@ -25,6 +26,8 @@
2526
class ServerTests(common.ComputeTestCase):
2627
"""Functional tests for openstack server commands"""
2728

29+
haz_network: ClassVar[bool]
30+
2831
@classmethod
2932
def setUpClass(cls):
3033
super().setUpClass()

openstackclient/tests/functional/identity/v2/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# under the License.
1212

1313
import os
14+
from typing import ClassVar
1415
import unittest
1516

1617
import fixtures
@@ -57,6 +58,9 @@ class IdentityTests(base.TestCase):
5758
CATALOG_LIST_HEADERS = ['Name', 'Type', 'Endpoints']
5859
ENDPOINT_LIST_HEADERS = ['ID', 'Region', 'Service Name', 'Service Type']
5960

61+
project_name: ClassVar[str]
62+
project_description: ClassVar[str]
63+
6064
@classmethod
6165
def setUpClass(cls):
6266
super().setUpClass()

openstackclient/tests/functional/identity/v3/common.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# under the License.
1212

1313
import os
14+
from typing import ClassVar
1415

1516
import fixtures
1617
from tempest.lib.common.utils import data_utils
@@ -147,6 +148,11 @@ class IdentityTests(base.TestCase):
147148
'Region ID',
148149
]
149150

151+
domain_name: ClassVar[str]
152+
domain_description: ClassVar[str]
153+
project_name: ClassVar[str]
154+
project_description: ClassVar[str]
155+
150156
@classmethod
151157
def setUpClass(cls):
152158
super().setUpClass()

openstackclient/tests/functional/image/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13+
from typing import ClassVar
14+
1315
from openstackclient.tests.functional import base
1416

1517

1618
class BaseImageTests(base.TestCase):
1719
"""Functional tests for Image commands"""
1820

21+
# TODO(stephenfin): Nothing sets this to true any more. We should remove it
22+
# along with any dependent tests.
23+
haz_v1_api: ClassVar[bool]
24+
1925
@classmethod
2026
def setUpClass(cls):
2127
super().setUpClass()

openstackclient/tests/functional/network/v2/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13+
from typing import ClassVar
1314
import uuid
1415

1516
from openstackclient.tests.functional import base
@@ -18,6 +19,8 @@
1819
class NetworkTests(base.TestCase):
1920
"""Functional tests for Network commands"""
2021

22+
haz_network: ClassVar[bool]
23+
2124
@classmethod
2225
def setUpClass(cls):
2326
super().setUpClass()
@@ -33,7 +36,7 @@ def setUp(self):
3336
class NetworkTagTests(NetworkTests):
3437
"""Functional tests with tag operation"""
3538

36-
base_command: str
39+
base_command: ClassVar[str]
3740

3841
def test_tag_operation(self):
3942
# Get project IDs

openstackclient/tests/functional/network/v2/test_floating_ip.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# under the License.
1212

1313
import random
14+
from typing import ClassVar
1415
import uuid
1516

1617
from openstackclient.tests.functional.network.v2 import common
@@ -19,6 +20,11 @@
1920
class FloatingIpTests(common.NetworkTests):
2021
"""Functional tests for floating ip"""
2122

23+
EXTERNAL_NETWORK_NAME: ClassVar[str]
24+
PRIVATE_NETWORK_NAME: ClassVar[str]
25+
external_network_id: ClassVar[str]
26+
private_network_id: ClassVar[str]
27+
2228
@classmethod
2329
def setUpClass(cls):
2430
super().setUpClass()

openstackclient/tests/functional/network/v2/test_ip_availability.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13+
from typing import ClassVar
1314
import uuid
1415

1516
from openstackclient.tests.functional.network.v2 import common
@@ -18,6 +19,9 @@
1819
class IPAvailabilityTests(common.NetworkTests):
1920
"""Functional tests for IP availability"""
2021

22+
NAME: ClassVar[str]
23+
NETWORK_NAME: ClassVar[str]
24+
2125
@classmethod
2226
def setUpClass(cls):
2327
super().setUpClass()

0 commit comments

Comments
 (0)
X Tutup