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

Delta Between Two Patch Sets: tests/utils.py

Issue 29886648: Issue #6942 - Add XTM integration in CMS (Closed)
Left Patch Set: Addressed initial comments Created Sept. 25, 2018, 12:24 p.m.
Right Patch Set: Addressed comments from Patch Set #4 Created Oct. 5, 2018, 4:23 p.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
LEFTRIGHT
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
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
11 # GNU General Public License for more details. 11 # GNU General Public License for more details.
12 # 12 #
13 # You should have received a copy of the GNU General Public License 13 # You should have received a copy of the GNU General Public License
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
15 15
16 import contextlib 16 import contextlib
17 import os 17 import os
18 import signal 18 import signal
19 import subprocess 19 import subprocess
20 import time 20 import time
21 import zipfile 21 import zipfile
22 from io import BytesIO 22 from io import BytesIO
23
23 import pytest 24 import pytest
Vasily Kuznetsov 2018/09/26 15:45:27 Nit: there should be an empty line before pytest,
Tudor Avram 2018/10/04 06:48:15 Done.
24 25
25 26
26 def get_dir_contents(path): 27 def get_dir_contents(path):
27 # TODO: This function is duplicated in test_page_outputs.py. 28 # TODO: This function is duplicated in test_page_outputs.py.
28 dirdata = {} 29 dirdata = {}
29 for dirpath, dirnames, filenames in os.walk(path): 30 for dirpath, dirnames, filenames in os.walk(path):
30 for output_file in filenames: 31 for output_file in filenames:
31 filepath = os.path.join(dirpath, output_file) 32 filepath = os.path.join(dirpath, output_file)
32 with open(filepath) as f: 33 with open(filepath) as f:
33 locale = os.path.split(os.path.split(filepath)[0])[1] 34 locale = os.path.split(os.path.split(filepath)[0])[1]
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 77
77 memory_zip.seek(0) 78 memory_zip.seek(0)
78 return memory_zip 79 return memory_zip
79 80
80 81
81 def exception_test(func, exception, exp_msg, *args, **kw): 82 def exception_test(func, exception, exp_msg, *args, **kw):
82 with pytest.raises(exception) as err: 83 with pytest.raises(exception) as err:
83 func(*args, **kw) 84 func(*args, **kw)
84 85
85 assert exp_msg in str(err.value) 86 assert exp_msg in str(err.value)
LEFTRIGHT

Powered by Google App Engine
This is Rietveld