Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: tests/test_render_script.py

Issue 29824555: Issue #4116: Make infile and outfile parameters of flrender script from python-abp optional (Closed)
Left Patch Set: Addressed comments from patch #2 Created July 16, 2018, 9:14 a.m.
Right Patch Set: Removed unnecessary locals() call Created July 17, 2018, 9:39 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « abp/filters/sources.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This file is part of Adblock Plus <https://adblockplus.org/>, 1 # This file is part of Adblock Plus <https://adblockplus.org/>,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 stdout, stderr = proc.communicate(input=test_in) 104 stdout, stderr = proc.communicate(input=test_in)
105 return proc.returncode, stderr.decode('utf-8'), stdout.decode('utf-8') 105 return proc.returncode, stderr.decode('utf-8'), stdout.decode('utf-8')
106 106
107 107
108 @pytest.mark.parametrize('test_input, args', [ 108 @pytest.mark.parametrize('test_input, args', [
109 ('None', ["'simple.txt'", 'str(dstfile)']), 109 ('None', ["'simple.txt'", 'str(dstfile)']),
110 ('None', ["'simple.txt'"]), 110 ('None', ["'simple.txt'"]),
111 ("rootdir.join('simple.txt').read()", []), 111 ("rootdir.join('simple.txt').read()", []),
112 ]) 112 ])
113 def test_render_no_includes(test_input, args, rootdir, dstfile): 113 def test_render_no_includes(test_input, args, rootdir, dstfile):
114 _locals = locals()
Vasily Kuznetsov 2018/07/17 09:26:58 Nit: this variable is not used now
Tudor Avram 2018/07/17 09:40:08 Done.
115 test_input = eval(test_input) 114 test_input = eval(test_input)
116 args = list(map(eval, args)) 115 args = list(map(eval, args))
117 _, _, stdout = run_script(*args, cwd=str(rootdir), test_in=test_input) 116 _, _, stdout = run_script(*args, cwd=str(rootdir), test_in=test_input)
118 117
119 if len(args) > 1: 118 if len(args) > 1:
120 output = dstfile.read() 119 output = dstfile.read()
121 else: 120 else:
122 output = stdout 121 output = stdout
123 122
124 assert 'Ok' in output 123 assert 'Ok' in output
125 assert '! Checksum:' in output 124 assert '! Checksum:' in output
125
126 126
127 def test_render_unicode(rootdir, dstfile): 127 def test_render_unicode(rootdir, dstfile):
128 code, err, _ = run_script(str(rootdir.join('unicode.txt')), str(dstfile)) 128 code, err, _ = run_script(str(rootdir.join('unicode.txt')), str(dstfile))
129 assert '\u1234' in dstfile.read(mode='rb').decode('utf-8') 129 assert '\u1234' in dstfile.read(mode='rb').decode('utf-8')
130 130
131 131
132 def test_render_with_includes(rootdir, dstfile): 132 def test_render_with_includes(rootdir, dstfile):
133 run_script(str(rootdir.join('includer.txt')), str(dstfile), 133 run_script(str(rootdir.join('includer.txt')), str(dstfile),
134 '-i', 'inc=' + str(rootdir.join('inc'))) 134 '-i', 'inc=' + str(rootdir.join('inc')))
135 assert 'I am included!' in dstfile.read() 135 assert 'I am included!' in dstfile.read()
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 @pytest.mark.slowtest 204 @pytest.mark.slowtest
205 def test_failed_web_include(rootdir, dstfile, webserver_port): 205 def test_failed_web_include(rootdir, dstfile, webserver_port):
206 url = 'http://localhost:{}/missing.txt'.format(webserver_port) 206 url = 'http://localhost:{}/missing.txt'.format(webserver_port)
207 webinc = rootdir.join('webinc.txt') 207 webinc = rootdir.join('webinc.txt')
208 webinc.write('[Adblock]\n%include {}%'.format(url)) 208 webinc.write('[Adblock]\n%include {}%'.format(url))
209 code, err, _ = run_script(str(webinc), str(dstfile)) 209 code, err, _ = run_script(str(webinc), str(dstfile))
210 assert code == 1 210 assert code == 1
211 assert err.startswith( 211 assert err.startswith(
212 "HTTP 404 Not found: '{0}' when including '{0}'".format(url)) 212 "HTTP 404 Not found: '{0}' when including '{0}'".format(url))
LEFTRIGHT

Powered by Google App Engine
This is Rietveld