Skip to content

Commit 7d7af06

Browse files
author
Brandon Duffany
committed
Add --full option
1 parent 41520c3 commit 7d7af06

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

codebender_testing/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,13 @@ def compile_sketches(self, sketches, iframe=False, logfile=None):
287287
format string, which will be formatted appropriately.
288288
`iframe` specifies whether the urls pointed to by `selector` are contained
289289
within an iframe.
290+
If the `--full` argument is provided (and hence
291+
`self.run_full_compile_tests` is `True`, we do not log, and limit the
292+
number of sketches compiled to 1.
290293
"""
291-
if logfile is None:
292-
for sketch in sketches:
294+
sketch_limit = None if self.run_full_compile_tests else 1
295+
if logfile is None or not self.run_full_compile_tests:
296+
for sketch in sketches[:sketch_limit]:
293297
self.compile_sketch(sketch, iframe=iframe)
294298
else:
295299
log_entry = {'url': self.site_url, 'succeeded': [], 'failed': []}
@@ -322,14 +326,15 @@ class SeleniumTestCase(CodebenderSeleniumBot):
322326

323327
@classmethod
324328
@pytest.fixture(scope="class", autouse=True)
325-
def _testcase_attrs(cls, webdriver, testing_url):
329+
def _testcase_attrs(cls, webdriver, testing_url, testing_full):
326330
"""Sets up any class attributes to be used by any SeleniumTestCase.
327331
Here, we just store fixtures as class attributes. This allows us to avoid
328332
the pytest boilerplate of getting a fixture value, and instead just
329333
refer to the fixture as `self.<fixture>`.
330334
"""
331335
cls.driver = webdriver
332336
cls.site_url = testing_url
337+
cls.run_full_compile_tests = testing_full
333338

334339
@pytest.fixture(scope="class")
335340
def tester_login(self):

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,19 @@ def pytest_addoption(parser):
2626
"""Adds command line options to py.test."""
2727
parser.addoption("--url", action="store", default=BASE_URL,
2828
help="URL to use for testing, e.g. http://localhost, http://codebender.cc")
29+
parser.addoption("--full", action="store_true", default=False,
30+
help="Whether to run the complete set of compile tests.")
2931

3032
@pytest.fixture(scope="class")
3133
def testing_url(request):
3234
"""A fixture to get the --url parameter."""
3335
return request.config.getoption("--url")
3436

37+
@pytest.fixture(scope="class")
38+
def testing_full(request):
39+
"""A fixture to get the --full parameter."""
40+
return request.config.getoption("--full")
41+
3542
@pytest.fixture(autouse=True)
3643
def skip_by_site(request, testing_url):
3744
"""Skips tests that require a certain site URL in order to run properly."""

0 commit comments

Comments
 (0)