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

Unified Diff: tests/test_page_outputs.py

Issue 29512555: Noissue - Adds better locale support to test suite (Closed)
Patch Set: Created Aug. 11, 2017, 6:25 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/expected_output/en/translate ('k') | no next file » | 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
@@ -5,22 +5,24 @@
import signal
import pytest
import urllib2
import subprocess
from conftest import ROOTPATH
def get_dir_contents(path):
- return_data = {}
- for dirpath, dirnames, filenames in os.walk(path):
+ dirdata = {}
+ for dirpath, dirnames, filenames in sorted(os.walk(path)):
Vasily Kuznetsov 2017/08/11 07:08:08 We're putting the result into a dictionary here. D
Jon Sonesen 2017/08/11 07:43:55 There is no difference i meant to remove this than
for output_file in filenames:
- with open(os.path.join(dirpath, output_file)) as f:
- return_data[output_file] = f.read().strip()
- return return_data
+ 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
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.
@@ -56,17 +58,17 @@
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/en/'
+ yield 'http://localhost:5000/'
os.killpg(os.getpgid(p.pid), signal.SIGTERM)
@pytest.fixture(scope='session')
def output_pages(static_output):
return get_dir_contents(static_output)
@@ -78,11 +80,11 @@
@pytest.mark.parametrize('filename,expected_output', dynamic_expected_outputs)
def test_dynamic(dynamic_server, filename, expected_output):
response = urllib2.urlopen(dynamic_server + filename)
assert response.read().strip() == expected_output
def test_revision_arg(revision, output_pages):
if revision is None:
- assert 'bar' in output_pages
+ assert 'en/bar' in output_pages
else:
- assert 'bar' not in output_pages
+ assert 'en/bar' not in output_pages
« no previous file with comments | « tests/expected_output/en/translate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld