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

Side by Side Diff: tests/test_page_outputs.py

Issue 29857615: Issue 6867 - Fix pytest 3.7.1 mock regression (Closed) Base URL: https://hg.adblockplus.org/cms
Patch Set: Address PS1 Comments Created Aug. 16, 2018, 9:11 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tox.ini » ('j') | tox.ini » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os 1 import os
2 import sys 2 import sys
3 import runpy 3 import runpy
4 4
5 import mock 5 import mock
6 import pytest 6 import pytest
7 import urllib2 7 import urllib2
8 8
9 from .conftest import ROOTPATH 9 from .conftest import ROOTPATH
10 from .utils import get_dir_contents, run_test_server 10 from .utils import get_dir_contents, run_test_server
(...skipping 13 matching lines...) Expand all
24 # Remove the expected outputs that don't apply for this test type. 24 # Remove the expected outputs that don't apply for this test type.
25 if '@' in filename: 25 if '@' in filename:
26 del outputs[filename] 26 del outputs[filename]
27 return outputs.items() 27 return outputs.items()
28 28
29 29
30 static_expected_outputs = get_expected_outputs('static') 30 static_expected_outputs = get_expected_outputs('static')
31 dynamic_expected_outputs = get_expected_outputs('dynamic') 31 dynamic_expected_outputs = get_expected_outputs('dynamic')
32 32
33 33
34 @mock.patch('cms.sources.FileSource.version', 1)
35 @pytest.fixture(scope='session') 34 @pytest.fixture(scope='session')
36 def static_output(request, temp_site): 35 def static_output(request, temp_site):
37 static_out_path = os.path.join(temp_site, 'static_out') 36 static_out_path = os.path.join(temp_site, 'static_out')
38 sys.argv = ['filler', temp_site, static_out_path] 37 sys.argv = ['filler', temp_site, static_out_path]
39 38 with mock.patch('cms.sources.FileSource.version', 1):
40 runpy.run_module('cms.bin.generate_static_pages', run_name='__main__') 39 runpy.run_module('cms.bin.generate_static_pages', run_name='__main__')
41 return static_out_path 40 return static_out_path
42 41
43 42
44 @pytest.fixture(scope='module') 43 @pytest.fixture(scope='module')
45 def dynamic_server(temp_site): 44 def dynamic_server(temp_site):
46 with run_test_server(temp_site) as ts: 45 with run_test_server(temp_site) as ts:
47 yield ts 46 yield ts
48 47
49 48
50 @pytest.fixture(scope='session') 49 @pytest.fixture(scope='session')
(...skipping 11 matching lines...) Expand all
62 61
63 @pytest.mark.parametrize('filename,expected_output', dynamic_expected_outputs) 62 @pytest.mark.parametrize('filename,expected_output', dynamic_expected_outputs)
64 def test_dynamic(dynamic_server, filename, expected_output): 63 def test_dynamic(dynamic_server, filename, expected_output):
65 response = urllib2.urlopen(dynamic_server + filename) 64 response = urllib2.urlopen(dynamic_server + filename)
66 assert expected_output == response.read().strip() 65 assert expected_output == response.read().strip()
67 66
68 67
69 def test_cache(output_pages): 68 def test_cache(output_pages):
70 source = FileSource(os.path.join('test_site')) 69 source = FileSource(os.path.join('test_site'))
71 assert source.get_cache_dir() == os.path.join('test_site', 'cache') 70 assert source.get_cache_dir() == os.path.join('test_site', 'cache')
OLDNEW
« no previous file with comments | « no previous file | tox.ini » ('j') | tox.ini » ('J')

Powered by Google App Engine
This is Rietveld