How to use get_source_lines method in refurb

Best Python code snippet using refurb_python

test_parser_get_source_lines.py

Source:test_parser_get_source_lines.py Github

copy

Full Screen

2from pyhaml_jinja.errors import TemplateSyntaxError3from pyhaml_jinja.parser import Parser4class TestParserGetSourceLines(unittest2.TestCase):5 def test_empty(self):6 self.assertEqual([''], Parser.get_source_lines(''))7 self.assertEqual([''], Parser.get_source_lines(None))8 self.assertEqual([''], Parser.get_source_lines('\n'))9 def test_basic(self):10 source = (11 '%div\n'12 ' text\n'13 '%p\n'14 ' %p\n'15 ' nested-text\n'16 )17 lines = Parser.get_source_lines(source)18 self.assertEqual(['%div', ' text', '%p', ' %p', ' nested-text'],19 lines)20 def test_trailing_whitespace(self):21 source = (22 '%div' + ' ' # 5 whitespace characters at the end.23 )24 lines = Parser.get_source_lines(source)25 self.assertEqual(['%div'], lines)26 def test_comment(self):27 source = (28 '%div\n'29 '; comment\n'30 ' text\n'31 )32 lines = Parser.get_source_lines(source)33 self.assertEqual(3, len(lines))34 self.assertEqual(['%div', '', ' text'], lines)35 def test_line_continuation(self):36 source = (37 '%div(a="1", \\\n'38 ' b="2")\n'39 ' text\n'40 )41 lines = Parser.get_source_lines(source)42 self.assertEqual(3, len(lines))43 self.assertEqual(['%div(a="1", b="2")', '', ' text'], lines)44 def test_line_continuation_ending_prematurely(self):45 source = (46 '%div(a="1", \\ \n'47 )48 with self.assertRaises(TemplateSyntaxError):49 Parser.get_source_lines(source)50 def test_line_continuation_indented_properly(self):51 source = (52 '%div\n'53 ' %p(a="1", \\ \n'54 ' b="2")\n'55 ' Text\n'56 )57 lines = Parser.get_source_lines(source)58 self.assertEqual(['%div', ' %p(a="1", b="2")', '', ' Text'], lines)59 def test_jinja_variables(self):60 source = '#{var} #{var2}'61 lines = Parser.get_source_lines(source)62 self.assertEquals(['{{ var }} {{ var2 }}'], lines)63 source = '%hr(class="#{class}")'64 lines = Parser.get_source_lines(source)...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...32 if d and d[-1] != '':33 d.append('')34 output = {'asm': '\n'.join(d)}35 if srcmap:36 output['map'] = self.get_source_lines(a)37 result[fname] = output38 return result39 @property40 def functions(self):41 return self.scanner.functions42 def get_source_lines(self, addrs):43 return self.mapper.get_source_lines(addrs)44 @property45 def plt(self):46 return self.scanner.plt47 def read_string(self, addr):48 return self.reader.read_string(addr)49 @property50 def sections(self):51 return self.scanner.sections52 @property53 def symbols(self):...

Full Screen

Full Screen

patch_source_cache.py

Source:patch_source_cache.py Github

copy

Full Screen

1import linecache2from idlelib import rpc3from friendly_traceback import source_cache4def _get_lines(filename, linenumber=None):5 rpchandler = rpc.objecttable["exec"].rpchandler6 lines = rpchandler.remotecall("linecache", "getlines", (filename, None), {})7 new_lines = []8 for line in lines:9 if not line.endswith("\n"):10 line += "\n"11 if filename.startswith("<pyshell#") and line.startswith("\t"):12 # Remove extra indentation added in the shell (\t == 8 spaces)13 line = " " + line[1:]14 new_lines.append(line)15 if linenumber is None:16 return new_lines17 return new_lines[linenumber - 1 : linenumber]18old_get_lines = source_cache.cache.get_source_lines19def new_get_lines(filename, module_globals=None):20 """Intended to replace the undocumented linecache.getlines, with the21 same signature.22 """23 lines = _get_lines(filename)24 if not lines:25 lines = old_get_lines(filename=filename, module_globals=module_globals)26 return lines27source_cache.cache.get_source_lines = new_get_lines...

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 refurb 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