tests: Kill off find_one() helper.

This was only recently added.  Using tuple
assignment raises the same errors, so the
indirection probably isn't worth it.
This commit is contained in:
Steve Howell
2020-03-19 22:34:50 +00:00
committed by Tim Abbott
parent b5cba4aafe
commit 8c1244d0b4
2 changed files with 5 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
from contextlib import contextmanager
from email.utils import parseaddr
from fakeldap import MockLDAP
from typing import (cast, Any, Callable, Dict, Iterable,
from typing import (cast, Any, Dict, Iterable,
Iterator, List, Optional,
Tuple, Union, Set)
@@ -821,40 +821,6 @@ class ZulipTestCase(TestCase):
r for r in data
if r['id'] == db_id][0]
def find_one(self,
lst: List[Any],
predicate: Callable[[Any], bool],
member_name: str) -> Any:
matches = [
item for item in lst
if predicate(item)
]
if len(matches) == 1:
# Happy path!
return matches[0]
if True: # nocoverage
print('\nERROR: findOne fails on this list:\n')
print('[')
for item in lst:
print(' ', item, ',')
print(']')
if len(matches) == 0:
raise ValueError(
'No matches: {}'.format(member_name)
)
raise ValueError(
'Too many matches ({}): {}'.format(
len(matches),
member_name
)
)
def init_default_ldap_database(self) -> None:
"""
Takes care of the mock_ldap setup, loads