LEFT | RIGHT |
1 import os | 1 import os |
2 import sys | 2 import sys |
3 import time | 3 import time |
4 import runpy | 4 import runpy |
5 import signal | 5 import signal |
6 import pytest | 6 import pytest |
7 import urllib2 | 7 import urllib2 |
8 import subprocess | 8 import subprocess |
9 from conftest import ROOTPATH | 9 from conftest import ROOTPATH |
10 | 10 |
11 | 11 |
12 def get_dir_contents(path): | 12 def get_dir_contents(path): |
13 return_data = {} | 13 return_data = {} |
14 for dirpath, dirnames, filenames in os.walk(path): | 14 for dirpath, dirnames, filenames in os.walk(path): |
15 for output_file in filenames: | 15 for output_file in filenames: |
16 with open(os.path.join(dirpath, output_file)) as f: | 16 with open(os.path.join(dirpath, output_file)) as f: |
17 return_data[output_file] = f.read().strip() | 17 return_data[output_file] = f.read().strip() |
18 return return_data | 18 return return_data |
19 | 19 |
20 | 20 |
21 def get_expected_outputs(test_type): | 21 def get_expected_outputs(test_type): |
22 expected_out_path = os.path.join(ROOTPATH, 'tests', 'expected_output') | 22 expected_out_path = os.path.join(ROOTPATH, 'tests', 'expected_output') |
23 outputs = get_dir_contents(expected_out_path) | 23 outputs = get_dir_contents(expected_out_path) |
24 for filename in list(outputs): | 24 for filename in list(outputs): |
| 25 # Move test-type-specific expected outputs (e.g. "xyz@static" -> "xyz") |
| 26 # and remove the expected outputs that don't apply for this test type. |
25 if filename.endswith('@' + test_type): | 27 if filename.endswith('@' + test_type): |
26 realname = filename.split('@')[0] | 28 realname = filename.split('@')[0] |
27 outputs[realname] = outputs[filename] | 29 outputs[realname] = outputs[filename] |
28 if '@' in filename: | 30 if '@' in filename: |
29 del outputs[filename] | 31 del outputs[filename] |
30 return outputs.items() | 32 return outputs.items() |
31 | 33 |
32 | 34 |
33 static_expected_outputs = get_expected_outputs('static') | 35 static_expected_outputs = get_expected_outputs('static') |
34 dynamic_expected_outputs = get_expected_outputs('dynamic') | 36 dynamic_expected_outputs = get_expected_outputs('dynamic') |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 def test_dynamic(dynamic_server, filename, expected_output): | 79 def test_dynamic(dynamic_server, filename, expected_output): |
78 response = urllib2.urlopen(dynamic_server + filename) | 80 response = urllib2.urlopen(dynamic_server + filename) |
79 assert response.read().strip() == expected_output | 81 assert response.read().strip() == expected_output |
80 | 82 |
81 | 83 |
82 def test_revision_arg(revision, output_pages): | 84 def test_revision_arg(revision, output_pages): |
83 if revision is None: | 85 if revision is None: |
84 assert 'bar' in output_pages | 86 assert 'bar' in output_pages |
85 else: | 87 else: |
86 assert 'bar' not in output_pages | 88 assert 'bar' not in output_pages |
LEFT | RIGHT |