ceph/qa/tasks/mgr
Kefu Chai d7258ea7fd qa/tasks: use next(iter(..)) for accessing first element in a view
in python2, dict.values() and dict.keys() return lists. but in python3,
they return views, which cannot be indexed directly using an integer index.

there are three use cases when we access these views in python3:

1. get the first element
2. get all the elements and then *might* want to access them by index
3. get the first element assuming there is only a single element in
   the view
4. iterate thru the view

in the 1st case, we cannot assume the number of elements, so to be
python3 compatible, we should use `next(iter(a_dict))` instead.

in the 2nd case, in this change, the view is materialized using
`list(a_dict)`.

in the 3rd case, we can just continue using the short hand of
```py
(first_element,) = a_dict.keys()
```
to unpack the view. this works in both python2 and python3.

in the 4th case, the existing code works in both python2 and python3, as
both list and view can be iterated using `iter`, and `len` works as
well.

Signed-off-by: Kefu Chai <kchai@redhat.com>
2020-04-07 20:33:47 +08:00
..
dashboard qa/tasks/mgr/dashboard/test_rbd: wait longer when purging 2020-03-31 19:48:58 +08:00
__init__.py
mgr_test_case.py
test_crash.py qa/tasks: use next(iter(..)) for accessing first element in a view 2020-04-07 20:33:47 +08:00
test_dashboard.py qa/tasks/mgr: use relative import 2020-03-27 14:51:24 +08:00
test_failover.py qa/tasks/mgr: use relative import 2020-03-27 14:51:24 +08:00
test_insights.py qa/tasks/mgr: use relative import 2020-03-27 14:51:24 +08:00
test_module_selftest.py qa/tasks/mgr: use relative import 2020-03-27 14:51:24 +08:00
test_orchestrator_cli.py qa/tasks/mgr: use relative import 2020-03-27 14:51:24 +08:00
test_progress.py qa/tasks/mgr: use relative import 2020-03-27 14:51:24 +08:00
test_prometheus.py qa/tasks/mgr: use relative import 2020-03-27 14:51:24 +08:00