Fix Python 3 compatibility in network policy tests

In Python 3 {}.keys() return a view, not a list, so we cannot index it.
This commit fixes test_update_network_policy to anticipate that.

Change-Id: Idb6adec1d4b4b4a0f3c65b03c157f5fbb1c278de
This commit is contained in:
Michał Dulko 2019-11-13 11:39:54 +01:00
parent ffae68805f
commit 2619af8513
1 changed files with 2 additions and 2 deletions

View File

@ -147,14 +147,14 @@ class TestNetworkPolicyScenario(base.BaseKuryrScenarioTest):
self.assertEqual(crd_pod_selector.get('matchLabels'),
match_labels)
match_labels = {'context': 'demo'}
label_key = 'context'
match_labels = {label_key: 'demo'}
np = self.read_network_policy(np)
np.spec.pod_selector.match_labels = match_labels
np = self.update_network_policy(np)
labels = {}
start = time.time()
label_key = match_labels.keys()[0]
while time.time() - start < TIMEOUT_PERIOD:
try:
time.sleep(1)