| Index: tests/test_page_outputs.py | 
| =================================================================== | 
| --- a/tests/test_page_outputs.py | 
| +++ b/tests/test_page_outputs.py | 
| @@ -13,46 +13,59 @@ | 
| def get_expected_outputs(test_type): | 
| expected_out_path = os.path.join(ROOTPATH, 'tests', 'expected_output') | 
| - outputs = get_dir_contents(expected_out_path) | 
| + outputs = get_dir_contents(expected_out_path, True) | 
| + result = {} | 
| for filename in list(outputs): | 
| - # Move test-type-specific expected outputs (e.g. "xyz@static" -> "xyz") | 
| - # There are cases where we need to test outputs which differ depending | 
| - # on how they are generated; either statically or dynamically | 
| - if filename.endswith('@' + test_type): | 
| - realname = filename.split('@')[0] | 
| - outputs[realname] = outputs[filename] | 
| - # Remove the expected outputs that don't apply for this test type. | 
| - if '@' in filename: | 
| - del outputs[filename] | 
| - return outputs.items() | 
| + ttype = os.path.split(os.path.split(filename)[0])[1] | 
| + if ttype == test_type or ttype == 'common': | 
| + result[filename] = outputs[filename] | 
| + return result.items() | 
| static_expected_outputs = get_expected_outputs('static') | 
| dynamic_expected_outputs = get_expected_outputs('dynamic') | 
| +relative_expected_outputs = get_expected_outputs('relative') | 
| + | 
| + | 
| +def generate_static_pages(temp_site, tmpdir_factory, *extra_args): | 
| + dst_path = str(tmpdir_factory.mktemp('static')) | 
| + sys.argv = ['filler', temp_site, dst_path] + list(extra_args) | 
| + with mock.patch('cms.sources.FileSource.version', 1): | 
| + runpy.run_module('cms.bin.generate_static_pages', | 
| + run_name='__main__') | 
| + return get_dir_contents(dst_path) | 
| @pytest.fixture(scope='session') | 
| -def static_output(request, temp_site): | 
| - static_out_path = os.path.join(temp_site, 'static_out') | 
| - sys.argv = ['filler', temp_site, static_out_path] | 
| - with mock.patch('cms.sources.FileSource.version', 1): | 
| - runpy.run_module('cms.bin.generate_static_pages', run_name='__main__') | 
| - return static_out_path | 
| +def output_pages(temp_site, tmpdir_factory): | 
| + return generate_static_pages(temp_site, tmpdir_factory) | 
| @pytest.fixture(scope='session') | 
| -def output_pages(static_output): | 
| - return get_dir_contents(static_output) | 
| +def output_pages_relative(temp_site, tmpdir_factory): | 
| + return generate_static_pages(temp_site, tmpdir_factory, '--relative') | 
| @pytest.mark.parametrize('filename,expected_output', static_expected_outputs) | 
| def test_static(output_pages, filename, expected_output): | 
| + filename = os.path.join(os.path.split(os.path.split(filename)[0])[0], | 
| + os.path.split(filename)[1]) | 
| if expected_output.startswith('## MISSING'): | 
| assert filename not in output_pages | 
| else: | 
| assert expected_output == output_pages[filename] | 
| +@pytest.mark.parametrize('filename,expected_output', relative_expected_outputs) | 
| +def test_static_relative(output_pages_relative, filename, expected_output): | 
| + filename = os.path.join(os.path.split(os.path.split(filename)[0])[0], | 
| + os.path.split(filename)[1]) | 
| + if expected_output.startswith('## MISSING'): | 
| + assert filename not in output_pages_relative | 
| + else: | 
| + assert expected_output == output_pages_relative[filename] | 
| + | 
| + | 
| def test_cache(output_pages): | 
| source = FileSource(os.path.join('test_site')) | 
| assert source.get_cache_dir() == os.path.join('test_site', 'cache') | 
| @@ -60,6 +73,9 @@ | 
| @pytest.mark.parametrize('filename,expected_output', dynamic_expected_outputs) | 
| def test_dynamic_server_handler(filename, expected_output, temp_site): | 
| + filename = os.path.join(os.path.split(os.path.split(filename)[0])[0], | 
| + os.path.split(filename)[1]) | 
| + | 
| def cleanup(page): | 
| return page.replace(os.linesep, '').strip() |