def test_termchar_set_handle_error(self): """Test handling an error in setting the termchars.""" shell = VisaShell() shell.current = True temp_stdout = StringIO() with redirect_stdout(temp_stdout): shell.do_termchar("CR") output = temp_stdout.getvalue() assert "no attribute" in output
def test_getting_termchar_absent_mapping(self): """Test getting a termchar that does not map to something with a representation.""" shell = VisaShell() shell.do_open(list(RESOURCE_ADDRESSES.values())[0]) shell.current.read_termination = "X" shell.current.write_termination = "Z" temp_stdout = StringIO() with redirect_stdout(temp_stdout): shell.do_termchar("") output = temp_stdout.getvalue() assert "Termchar read: X write: Z" == output.split("\n")[0]
def test_termchar_get_handle_error(self): """Test handling error when getting the termchars. """ shell = VisaShell() shell.current = True temp_stdout = StringIO() with redirect_stdout(temp_stdout): shell.do_termchar("") output = temp_stdout.getvalue() self.assertIn('no attribute', output)