Browse Source

Switch from unittest2 compat methods to Python 3.x methods

With the removal of Python 2.x we can remove the unittest2 compat
wrappers and switch to assertCountEqual instead of assertItemsEqual

We have been able to use them since then, because
testtools required unittest2, which still included it. With testtools
removing Python 2.7 support [3][4], we will lose support for
assertItemsEqual, so we should switch to use assertCountEqual.

[1] - https://bugs.python.org/issue17866
[2] - https://hg.python.org/cpython/rev/d9921cb6e3cd
[3] - testing-cabal/testtools#286
[4] - testing-cabal/testtools#277

Change-Id: I3e8725eb77ea947e71d85ea406a60ed94c7bf971
changes/38/739638/1
melissaml 2 years ago
parent
commit
103653503c
  1. 2
      octavia/tests/functional/api/v2/test_amphora.py
  2. 2
      octavia/tests/functional/api/v2/test_health_monitor.py
  3. 2
      octavia/tests/functional/api/v2/test_l7policy.py
  4. 2
      octavia/tests/functional/api/v2/test_l7rule.py
  5. 4
      octavia/tests/functional/api/v2/test_listener.py
  6. 2
      octavia/tests/functional/api/v2/test_load_balancer.py
  7. 2
      octavia/tests/functional/api/v2/test_member.py
  8. 2
      octavia/tests/functional/api/v2/test_pool.py
  9. 2
      octavia/tests/functional/api/v2/test_quotas.py

2
octavia/tests/functional/api/v2/test_amphora.py

@ -396,7 +396,7 @@ class TestAmphora(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):

2
octavia/tests/functional/api/v2/test_health_monitor.py

@ -513,7 +513,7 @@ class TestHealthMonitor(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):

2
octavia/tests/functional/api/v2/test_l7policy.py

@ -442,7 +442,7 @@ class TestL7Policy(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):

2
octavia/tests/functional/api/v2/test_l7rule.py

@ -291,7 +291,7 @@ class TestL7Rule(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):

4
octavia/tests/functional/api/v2/test_listener.py

@ -317,7 +317,7 @@ class TestListener(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):
@ -2244,7 +2244,7 @@ class TestListener(base.BaseAPITest):
listener_path = self.LISTENER_PATH.format(
listener_id=listener['listener']['id'])
get_listener = self.get(listener_path).json['listener']
self.assertItemsEqual([sni_id1, sni_id2],
self.assertCountEqual([sni_id1, sni_id2],
get_listener['sni_container_refs'])
# TODO(johnsom) Fix this when there is a noop certificate manager

2
octavia/tests/functional/api/v2/test_load_balancer.py

@ -1347,7 +1347,7 @@ class TestLoadBalancer(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):

2
octavia/tests/functional/api/v2/test_member.py

@ -294,7 +294,7 @@ class TestMember(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):

2
octavia/tests/functional/api/v2/test_pool.py

@ -476,7 +476,7 @@ class TestPool(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_all_fields_filter(self):

2
octavia/tests/functional/api/v2/test_quotas.py

@ -650,7 +650,7 @@ class TestQuotas(base.BaseAPITest):
links = middle[self.root_tag_links]
self.assertEqual(1, len(objs))
self.assertEqual(2, len(links))
self.assertItemsEqual(['previous', 'next'],
self.assertCountEqual(['previous', 'next'],
[link['rel'] for link in links])
def test_get_default_quotas(self):

Loading…
Cancel
Save