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

Unified Diff: tests/test_page_outputs.py

Issue 29555839: Issue 5336 - Allow additional include, page, and template paths using CMS (Closed)
Patch Set: Rename 'static' parameter to 'cached' Created Oct. 2, 2017, 10:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/test_multi_source.py ('k') | tests/utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/test_page_outputs.py
===================================================================
--- a/tests/test_page_outputs.py
+++ b/tests/test_page_outputs.py
@@ -1,28 +1,16 @@
import os
import sys
-import time
import runpy
-import signal
import pytest
import urllib2
-import subprocess
-from conftest import ROOTPATH
-
-def get_dir_contents(path):
- dirdata = {}
- for dirpath, dirnames, filenames in os.walk(path):
- for output_file in filenames:
- filepath = os.path.join(dirpath, output_file)
- with open(filepath) as f:
- locale = os.path.split(os.path.split(filepath)[0])[1]
- dirdata[os.path.join(locale, output_file)] = f.read().strip()
- return dirdata
+from .conftest import ROOTPATH
+from .utils import get_dir_contents, run_test_server
def get_expected_outputs(test_type):
expected_out_path = os.path.join(ROOTPATH, 'tests', 'expected_output')
outputs = get_dir_contents(expected_out_path)
for filename in list(outputs):
# Move test-type-specific expected outputs (e.g. "xyz@static" -> "xyz")
# and remove the expected outputs that don't apply for this test type.
@@ -49,27 +37,20 @@
sys.argv = ['filler', temp_site, static_out_path]
if revision is not None:
sys.argv += ['--rev', revision]
runpy.run_module('cms.bin.generate_static_pages', run_name='__main__')
return static_out_path
-@pytest.yield_fixture()
+@pytest.fixture(scope='module')
def dynamic_server(temp_site):
- args = ['python', 'runserver.py', temp_site]
- # Werkzeug is a dependency of flask which we are using for the mock api
- # however there is an issue with Werkzeug that prevents it from properly
- # handling the SIGTERM sent by p.kill() or terminate()
- # Issue: https://github.com/pallets/werkzeug/issues/58
- p = subprocess.Popen(args, stdout=subprocess.PIPE, preexec_fn=os.setsid)
- time.sleep(0.5)
- yield 'http://localhost:5000/'
- os.killpg(os.getpgid(p.pid), signal.SIGTERM)
+ with run_test_server(temp_site) as ts:
+ yield ts
@pytest.fixture(scope='session')
def output_pages(static_output):
return get_dir_contents(static_output)
@pytest.mark.parametrize('filename,expected_output', static_expected_outputs)
« no previous file with comments | « tests/test_multi_source.py ('k') | tests/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld