How to use string_safe_encode method in avocado

Best Python code snippet using avocado_python Github


Full Screen

...54 pass55 _open_log_files[base_file] = open(log_file, "w")56 timestr = time.strftime("%Y-%m-%d %H:%M:%S")57 try:58 line = string_safe_encode(line)59 except UnicodeDecodeError:60 line = line.decode("utf-8", "ignore").encode("utf-8")61 _open_log_files[base_file].write("%s: %s\n" % (timestr, line))62 _open_log_files[base_file].flush()63 finally:64 _log_lock.release()65def set_log_file_dir(directory):66 """67 Set the base directory for log files created by log_line()68 :param directory: Directory for log files69 """70 global _log_file_dir71 _log_file_dir = directory72def get_log_file_dir():...

Full Screen

Full Screen Github


Full Screen

1import unittest2from avocado.utils import astring3class AstringTest(unittest.TestCase):4 def testTabularOutput(self):5 matrix = [('foo', 'bar'), ('/bin/bar/sbrubles',6 '/home/myuser/sbrubles')]7 self.assertEqual(astring.tabular_output(matrix),8 ('foo bar\n'9 '/bin/bar/sbrubles /home/myuser/sbrubles'))10 header = ['id', 'path']11 self.assertEqual(astring.tabular_output(matrix, header),12 ('id path\n'13 'foo bar\n'14 '/bin/bar/sbrubles /home/myuser/sbrubles'))15 def testUnicodeTabular(self):16 """17 Verifies tabular can handle utf-8 chars properly18 It tries valid encoded utf-8 string as well as unicode ones of19 various lengths and verifies calculates the right length and reports20 the correct results. (the string_safe_encode function is in use here)21 """22 matrix = [("\xd0\xb0\xd0\xb2\xd0\xbe\xd0\xba\xd0\xb0\xd0\xb4\xd0\xbe",23 123),24 (u'\u0430\u0432\u043e\u043a\u0430\u0434\u043e', 123),25 ("avok\xc3\xa1do", 123),26 ("avocado", 123)]27 str_matrix = ("\xd0\xb0\xd0\xb2\xd0\xbe\xd0\xba\xd0\xb0\xd0\xb4"28 "\xd0\xbe 123\n"29 "\xd0\xb0\xd0\xb2\xd0\xbe\xd0\xba\xd0\xb0\xd0\xb4"30 "\xd0\xbe 123\n"31 "avok\xc3\xa1do 123\n"32 "avocado 123")33 self.assertEqual(astring.tabular_output(matrix), str_matrix)34if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?