OLD | NEW |
(Empty) | |
| 1 import os |
| 2 import pytest |
| 3 import subprocess |
| 4 |
| 5 SOURCEPATH = 'cms/tests/test_site/pages/' |
| 6 STATICPATH = 'cms/tests/static_out/' |
| 7 |
| 8 |
| 9 @pytest.fixture(scope='session', autouse=True) |
| 10 def static_session_setup(request): |
| 11 seen = set() |
| 12 session = request.node |
| 13 for item in session.items: |
| 14 cls = item.getparent(pytest.Class) |
| 15 if cls not in seen: |
| 16 if hasattr(cls.obj, 'generate_static_test_pages'): |
| 17 cls.obj.generate_static_test_pages() |
| 18 seen.add(cls) |
| 19 |
| 20 def static_tear_down(): |
| 21 subprocess.check_call(['rm', '-r', 'cms/tests/test_site/.hg']) |
| 22 subprocess.check_call(['rm', '-r', 'cms/tests/static_out']) |
| 23 request.addfinalizer(static_tear_down) |
| 24 |
| 25 |
| 26 @pytest.fixture(scope='session') |
| 27 def input_files(): |
| 28 return_data = {} |
| 29 print os.walk(SOURCEPATH) |
| 30 for (dirpath, dirnames, filenames) in os.walk(SOURCEPATH): |
| 31 for input_file in filenames: |
| 32 with open('{}/{}'.format(dirpath, input_file)) as f: |
| 33 return_data[input_file] = f.read() |
| 34 print return_data |
| 35 return return_data |
| 36 |
| 37 |
| 38 @pytest.fixture(scope='session') |
| 39 def output_files(): |
| 40 return_data = {} |
| 41 for (dirpath, dirnames, filenames) in os.walk(STATICPATH): |
| 42 for output_file in filenames: |
| 43 with open('{}/{}'.format(dirpath, output_file)) as f: |
| 44 return_data[output_file] = f.read() |
| 45 return return_data |
OLD | NEW |