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: Fixed minor flake8 issue Created July 16, 2018, 11:49 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()
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
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 203
205 @pytest.mark.slowtest 204 @pytest.mark.slowtest
206 def test_failed_web_include(rootdir, dstfile, webserver_port): 205 def test_failed_web_include(rootdir, dstfile, webserver_port):
207 url = 'http://localhost:{}/missing.txt'.format(webserver_port) 206 url = 'http://localhost:{}/missing.txt'.format(webserver_port)
208 webinc = rootdir.join('webinc.txt') 207 webinc = rootdir.join('webinc.txt')
209 webinc.write('[Adblock]\n%include {}%'.format(url)) 208 webinc.write('[Adblock]\n%include {}%'.format(url))
210 code, err, _ = run_script(str(webinc), str(dstfile)) 209 code, err, _ = run_script(str(webinc), str(dstfile))
211 assert code == 1 210 assert code == 1
212 assert err.startswith( 211 assert err.startswith(
213 "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