Skip to content

Commit a67d2b0

Browse files
author
Konstantinacc
committed
Added @pytest.fixture does_not_require_extension.
Files affected: conftest.py, test_alerts.py. This marker is used so that we skip tests when running under chrome since we have an unexpected behavior when the extension is not installed.
1 parent 51eb5aa commit a67d2b0

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,20 @@ def test_some_feature():
114114
required_url = request.node.get_marker('requires_url').args[0]
115115
if required_url.rstrip('/') != testing_url.rstrip('/'):
116116
pytest.skip('skipped test that requires --url=%s' % required_url)
117+
118+
@pytest.fixture(autouse=True)
119+
def does_not_require_extension(request, webdriver):
120+
"""Mark that a test doesn't require the codebender extension.
121+
This marker is used so that we skip tests when running under chrome since
122+
we have an unexpected behavior when the extension is not installed.
123+
This functionality should be invoked as a pytest marker, e.g.:
124+
125+
```
126+
@pytest.mark.does_not_require_extension
127+
def test_some_feature():
128+
...
129+
```
130+
"""
131+
if request.node.get_marker('does_not_require_extension'):
132+
if webdriver.desired_capabilities["browserName"] == "chrome":
133+
pytest.skip("skipped test that does not require codebender extension.")

tests/noplugin/alerts/test_alerts.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def create_test_project(self, tester_login):
1616
performing any of these tests."""
1717
self.create_sketch(TEST_PROJECT_NAME)
1818

19+
@pytest.mark.does_not_require_extension
1920
def test_alert(self):
2021
operation_output = self.driver.find_element_by_id('operation_output')
2122
assert "To program your Arduino from your browser, install" \
@@ -24,6 +25,7 @@ def test_alert(self):
2425
def test_remove_sketch(self):
2526
self.delete_project(TEST_PROJECT_NAME)
2627

28+
@pytest.mark.does_not_require_extension
2729
def test_library_example(self, tester_logout):
2830
self.open('/libraries')
2931
library_example = """
@@ -40,6 +42,7 @@ def test_library_example(self, tester_logout):
4042
if flash_btn.is_enabled():
4143
assert False
4244

45+
@pytest.mark.does_not_require_extension
4346
def test_embeded_view(self, tester_logout):
4447
self.open('/embed/microview_test')
4548
output = self.driver.find_element_by_id('cb_cf_operation_output')
@@ -49,12 +52,14 @@ def test_embeded_view(self, tester_logout):
4952
if microview_test.is_enabled():
5053
assert False
5154

55+
@pytest.mark.does_not_require_extension
5256
def test_walkthrough_page_2(self, tester_logout):
5357
self.open('/static/walkthrough/page/2')
5458
output = self.driver.find_element_by_id('cb_cf_operation_output')
5559
assert "To program your Arduino from your browser, install" \
5660
" the codebender plugin." in output.text
5761

62+
@pytest.mark.does_not_require_extension
5863
def test_walkthrough_page_3(self, tester_logout):
5964
self.open('/static/walkthrough/page/3')
6065
WebDriverWait(self.driver, TIMEOUT).until(
@@ -66,7 +71,7 @@ def test_walkthrough_page_3(self, tester_logout):
6671
current_url = urlparse(self.driver.current_url)
6772
assert current_url.path == '/static/walkthrough/page/2'
6873

69-
74+
@pytest.mark.does_not_require_extension
7075
def test_walkthrough_page_4(self, tester_logout):
7176
self.open('/static/walkthrough/page/4')
7277
WebDriverWait(self.driver, TIMEOUT).until(

0 commit comments

Comments
 (0)