How to use _push_file method in autotest

Best Python code snippet using autotest_python

source.py

Source:source.py Github

copy

Full Screen

...120 gpl_txt]121 for fname in incorrect:122 help_text.append((' ' * 4) + fname)123 self.fail('\n'.join(help_text))124 def _push_file(self, dict_, fname, line_no):125 if fname not in dict_:126 dict_[fname] = [line_no]127 else:128 dict_[fname].append(line_no)129 def _format_message(self, dict_, message):130 files = ["%s: %s" % (f, ', '.join([str(i + 1) for i in lines]))131 for f, lines in dict_.items()]132 files.sort()133 return message + '\n\n %s' % ('\n '.join(files))134 def _iter_source_files_lines(self):135 for fname, text in get_source_file_contents():136 lines = text.splitlines(True)137 last_line_no = len(lines) - 1138 for line_no, line in enumerate(lines):139 yield fname, line_no, line140 def test_no_tabs(self):141 """Check that there are no tabs in Python files."""142 tabs = {}143 for fname, line_no, line in self._iter_source_files_lines():144 if '\t' in line:145 self._push_file(tabs, fname, line_no)146 if tabs:147 self.fail(self._format_message(tabs,148 'Tab characters were found in the following source files.'149 '\nThey should either be replaced by "\\t" or by spaces:'))150 def test_unix_newlines(self):151 """Check for unix new lines."""152 illegal_newlines = {}153 for fname, line_no, line in self._iter_source_files_lines():154 if not line.endswith('\n') or line.endswith('\r\n'):155 self._push_file(illegal_newlines, fname, line_no)156 if illegal_newlines:157 self.fail(self._format_message(illegal_newlines,158 'Non-unix newlines were found in the following source files:'))159 def test_trailing_whitespace(self):160 """Check that there is not trailing whitespace in Python files."""161 trailing_whitespace = {}162 for fname, line_no, line in self._iter_source_files_lines():163 if line.rstrip("\n").endswith(" "):164 self._push_file(trailing_whitespace, fname, line_no)165 if trailing_whitespace:166 self.fail(self._format_message(trailing_whitespace,167 'Trailing whitespace was found in the following source files.'))168 def test_shebang_lines(self):169 """Check that files with shebang lines and only those are executable."""170 files_with_shebang = {}171 files_without_shebang= {}172 for fname, line_no, line in self._iter_source_files_lines():173 if line_no >= 1:174 continue175 executable = (os.stat(fname).st_mode & 0o111)176 has_shebang = line.startswith("#!")177 if has_shebang and not executable:178 self._push_file(files_with_shebang, fname, line_no)179 if not has_shebang and executable:180 self._push_file(files_without_shebang, fname, line_no)181 if files_with_shebang:182 self.fail(self._format_message(files_with_shebang,183 'Files with shebang line that are not executable:'))184 if files_without_shebang:185 self.fail(self._format_message(files_without_shebang,...

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:

YouTube

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

Run autotest 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?

Helpful

NotHelpful