TNL-3014 Add tests for search Add text_search to TeamsListView Add reindex command line tool for course teams Add Search Pagination and update comments Move paginate_search_results to common library
27 lines
543 B
Python
27 lines
543 B
Python
"""
|
|
General testing utilities.
|
|
"""
|
|
import sys
|
|
from contextlib import contextmanager
|
|
|
|
|
|
@contextmanager
|
|
def nostderr():
|
|
"""
|
|
ContextManager to suppress stderr messages
|
|
http://stackoverflow.com/a/1810086/882918
|
|
"""
|
|
savestderr = sys.stderr
|
|
|
|
class Devnull(object):
|
|
""" /dev/null incarnation as output-stream-like object """
|
|
def write(self, _):
|
|
""" Write method - just does nothing"""
|
|
pass
|
|
|
|
sys.stderr = Devnull()
|
|
try:
|
|
yield
|
|
finally:
|
|
sys.stderr = savestderr
|