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

Unified Diff: cms/tests/static_tests/conftest.py

Issue 29345468: Issue 4045 - Add Test Suite To CMS (Closed)
Patch Set: fix Popen object return Created June 29, 2016, 1:23 p.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
Index: cms/tests/static_tests/conftest.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/cms/tests/static_tests/conftest.py
@@ -0,0 +1,45 @@
+import os
+import pytest
+import subprocess
+
+SOURCEPATH = 'cms/tests/test_site/pages/'
+STATICPATH = 'cms/tests/static_out/'
+
+
+@pytest.fixture(scope='session', autouse=True)
+def static_session_setup(request):
Vasily Kuznetsov 2016/07/01 14:26:16 Here again, it seems that we don't need the test c
Jon Sonesen 2016/07/01 15:58:13 I agree. But what do you mean temporary directory
Vasily Kuznetsov 2016/07/01 16:47:58 I think it's preferable to create a temporary dire
+ seen = set()
+ session = request.node
+ for item in session.items:
+ cls = item.getparent(pytest.Class)
+ if cls not in seen:
+ if hasattr(cls.obj, 'generate_static_test_pages'):
+ cls.obj.generate_static_test_pages()
+ seen.add(cls)
+
+ def static_tear_down():
+ subprocess.check_call(['rm', '-r', 'cms/tests/test_site/.hg'])
+ subprocess.check_call(['rm', '-r', 'cms/tests/static_out'])
+ request.addfinalizer(static_tear_down)
+
+
+@pytest.fixture(scope='session')
+def input_files():
+ return_data = {}
+ print os.walk(SOURCEPATH)
+ for (dirpath, dirnames, filenames) in os.walk(SOURCEPATH):
+ for input_file in filenames:
+ with open('{}/{}'.format(dirpath, input_file)) as f:
+ return_data[input_file] = f.read()
+ print return_data
+ return return_data
+
+
+@pytest.fixture(scope='session')
+def output_files():
+ return_data = {}
+ for (dirpath, dirnames, filenames) in os.walk(STATICPATH):
+ for output_file in filenames:
+ with open('{}/{}'.format(dirpath, output_file)) as f:
+ return_data[output_file] = f.read()
+ return return_data

Powered by Google App Engine
This is Rietveld