Best Python code snippet using autotest_python
topic_common_unittest.py
Source:topic_common_unittest.py
...26 test_parse_info = parse_info(attribute_name='testing',27 filename_option='flist')28 self.assertRaises(topic_common.CliError,29 test_parse_info.get_values, options, [])30 def __test_parsing_flist_good(self, options, expected):31 parse_info = topic_common.item_parse_info32 test_parse_info = parse_info(attribute_name='testing',33 filename_option='flist')34 result, leftover = test_parse_info.get_values(options, [])35 self.assertEqualNoOrder(expected, result)36 os.unlink(options.flist)37 def __test_parsing_inline_good(self, options, expected):38 parse_info = topic_common.item_parse_info39 test_parse_info = parse_info(attribute_name='testing',40 inline_option='inline')41 result, leftover = test_parse_info.get_values(options, [])42 self.assertEqualNoOrder(expected, result)43 def __test_parsing_leftover_good(self, leftover, expected):44 class opt(object):45 pass46 parse_info = topic_common.item_parse_info47 test_parse_info = parse_info(attribute_name='testing',48 inline_option='inline',49 use_leftover=True)50 result, leftover = test_parse_info.get_values(opt(), leftover)51 self.assertEqualNoOrder(expected, result)52 def __test_parsing_all_good(self, options, leftover, expected):53 parse_info = topic_common.item_parse_info54 test_parse_info = parse_info(attribute_name='testing',55 inline_option='inline',56 filename_option='flist',57 use_leftover=True)58 result, leftover = test_parse_info.get_values(options, leftover)59 self.assertEqualNoOrder(expected, result)60 os.unlink(options.flist)61 def __test_parsing_all_bad(self, options, leftover):62 parse_info = topic_common.item_parse_info63 test_parse_info = parse_info(attribute_name='testing',64 inline_option='inline',65 filename_option='flist',66 use_leftover=True)67 self.assertRaises(topic_common.CliError,68 test_parse_info.get_values, options, leftover)69 def test_file_list_wrong_file(self):70 class opt(object):71 flist = './does_not_exist'72 self.__test_parsing_flist_bad(opt())73 def test_file_list_empty_file(self):74 class opt(object):75 flist_obj = cli_mock.create_file('')76 flist = flist_obj.name77 self.__test_parsing_flist_bad(opt())78 def test_file_list_ok(self):79 class opt(object):80 flist_obj = cli_mock.create_file('a\nb\nc\n')81 flist = flist_obj.name82 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c'])83 def test_file_list_one_line_space(self):84 class opt(object):85 flist_obj = cli_mock.create_file('a b c\nd e\nf\n')86 flist = flist_obj.name87 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e', 'f'])88 def test_file_list_one_line_comma(self):89 class opt(object):90 flist_obj = cli_mock.create_file('a,b,c\nd,e\nf\n')91 flist = flist_obj.name92 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e', 'f'])93 def test_file_list_one_line_mix(self):94 class opt(object):95 flist_obj = cli_mock.create_file('a,b c\nd,e\nf\ng h,i')96 flist = flist_obj.name97 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e',98 'f', 'g', 'h', 'i'])99 def test_file_list_one_line_comma_space(self):100 class opt(object):101 flist_obj = cli_mock.create_file('a, b c\nd,e\nf\ng h,i')102 flist = flist_obj.name103 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e',104 'f', 'g', 'h', 'i'])105 def test_file_list_line_end_comma_space(self):106 class opt(object):107 flist_obj = cli_mock.create_file('a, b c\nd,e, \nf,\ng h,i ,')108 flist = flist_obj.name109 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c', 'd', 'e',110 'f', 'g', 'h', 'i'])111 def test_file_list_no_eof(self):112 class opt(object):113 flist_obj = cli_mock.create_file('a\nb\nc')114 flist = flist_obj.name115 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c'])116 def test_file_list_blank_line(self):117 class opt(object):118 flist_obj = cli_mock.create_file('\na\nb\n\nc\n')119 flist = flist_obj.name120 self.__test_parsing_flist_good(opt(), ['a', 'b', 'c'])121 def test_file_list_escaped_commas(self):122 class opt(object):123 flist_obj = cli_mock.create_file('a\nb\\,c\\,d\nef\\,g')124 flist = flist_obj.name125 self.__test_parsing_flist_good(opt(), ['a', 'b,c,d', 'ef,g'])126 def test_file_list_escaped_commas_slashes(self):127 class opt(object):128 flist_obj = cli_mock.create_file('a\nb\\\\\\,c\\,d\nef\\\\,g')129 flist = flist_obj.name130 self.__test_parsing_flist_good(opt(), ['a', 'b\\,c,d', 'ef\\', 'g'])131 def test_file_list_opt_list_one(self):132 class opt(object):133 inline = 'a'134 self.__test_parsing_inline_good(opt(), ['a'])135 def test_file_list_opt_list_space(self):136 class opt(object):137 inline = 'a b c'138 self.__test_parsing_inline_good(opt(), ['a', 'b', 'c'])139 def test_file_list_opt_list_mix_space_comma(self):140 class opt(object):141 inline = 'a b,c,d e'142 self.__test_parsing_inline_good(opt(), ['a', 'b', 'c', 'd', 'e'])143 def test_file_list_opt_list_mix_comma_space(self):144 class opt(object):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!