def child(kind): import warnings warnings.filterwarnings("error", category=RuntimeWarning) warnings.filterwarnings("error", category=UserWarning) try: TestTerminal(kind=kind, force_styling=True) except UserWarning: err = sys.exc_info()[1] assert (err.args[0] == _BINTERM_UNSUPPORTED_MSG.format(kind) or err.args[0].startswith('Unknown parameter in ') or err.args[0].startswith('Failed to setupterm(')), err else: assert 'warnings should have been emitted.' warnings.resetwarnings()
def child(kind): import warnings warnings.filterwarnings("error", category=RuntimeWarning) warnings.filterwarnings("error", category=UserWarning) try: TestTerminal(kind=kind, force_styling=True) except UserWarning: err = sys.exc_info()[1] assert (err.args[0] == _BINTERM_UNSUPPORTED_MSG.format(kind) or err.args[0].startswith('Unknown parameter in ') or err.args[0].startswith('Failed to setupterm(') ), err else: assert 'warnings should have been emitted.' warnings.resetwarnings()
def test_unit_binpacked_unittest(): """Unit Test known binary-packed terminals emit a warning (travis-safe).""" import warnings from blessed._binterms import binary_terminals from blessed.sequences import (_BINTERM_UNSUPPORTED_MSG, init_sequence_patterns) warnings.filterwarnings("error", category=UserWarning) term = mock.Mock() term.kind = binary_terminals[random.randrange(len(binary_terminals))] try: init_sequence_patterns(term) except UserWarning: err = sys.exc_info()[1] assert err.args[0] == _BINTERM_UNSUPPORTED_MSG.format(term.kind) else: assert False, 'Previous stmt should have raised exception.' warnings.resetwarnings()