Skip to content

Commit

Permalink
Add markers to run remote tests by default only in CI (mozilla#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrypolo authored and whimboo committed Aug 8, 2019
1 parent 685d934 commit dfbac8c
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
markers =
ci_only: Only run these tests within the CI environment.

9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ def httpd():
httpd.start(block=False)
yield httpd
httpd.stop()


def pytest_runtest_setup(item):
ci_enabled = os.getenv('CI', False)
for marker in item.iter_markers():
if marker.name == 'ci_only' and not ci_enabled:
pytest.skip("""
Can not run this test when not running in CI environment
""")
2 changes: 2 additions & 0 deletions tests/remote/test_devedition.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from mozdownload.utils import urljoin


@pytest.mark.ci_only
@pytest.mark.parametrize("args,url", [
({'application': 'devedition', 'platform': 'linux', 'version': '60.0b1'},
'devedition/releases/60.0b1/linux-i686/en-US/firefox-60.0b1.tar.bz2'),
Expand All @@ -36,6 +37,7 @@ def test_release_scraper(tmpdir, args, url):
assert unquote(scraper.url) == urljoin(BASE_URL, url)


@pytest.mark.ci_only
@pytest.mark.parametrize("args,url", [
({'application': 'devedition', 'platform': 'linux', 'version': '60.0b1', 'build_number': 1},
'devedition/candidates/60.0b1-candidates/build3/linux-i686/en-US/firefox-60.0b1.tar.bz2'),
Expand Down
1 change: 1 addition & 0 deletions tests/remote/test_fennec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import mozdownload


@pytest.mark.ci_only
@pytest.mark.parametrize("args", [
# Support for API level 9 ended on Mar 11th 2016
{'application': 'fennec', 'platform': 'android-api-9',
Expand Down
4 changes: 4 additions & 0 deletions tests/remote/test_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from mozdownload.utils import urljoin


@pytest.mark.ci_only
@pytest.mark.parametrize("args,url", [
({'application': 'firefox', 'platform': 'linux', 'version': 'latest'},
None),
Expand Down Expand Up @@ -44,6 +45,7 @@ def test_release_scraper(tmpdir, args, url):
assert unquote(scraper.url) == urljoin(BASE_URL, url)


@pytest.mark.ci_only
@pytest.mark.parametrize("args,url", [
({'application': 'firefox', 'platform': 'linux', 'version': '45.4.0esr', 'build_number': 1},
'firefox/candidates/45.4.0esr-candidates/build1/linux-i686/en-US/firefox-45.4.0esr.tar.bz2'),
Expand Down Expand Up @@ -73,6 +75,7 @@ def test_candidate_scraper(tmpdir, args, url):
assert unquote(scraper.url) == urljoin(BASE_URL, url)


@pytest.mark.ci_only
@pytest.mark.parametrize("args", [
{'branch': 'mozilla-central', 'platform': 'linux'},
{'branch': 'mozilla-central', 'platform': 'linux64'},
Expand All @@ -98,6 +101,7 @@ def test_daily_scraper(tmpdir, args):
mozdownload.DailyScraper(destination=tmpdir, **args)


@pytest.mark.ci_only
@pytest.mark.parametrize("args", [
{'branch': 'mozilla-central', 'platform': 'linux'},
{'branch': 'mozilla-central', 'platform': 'linux64'},
Expand Down
4 changes: 4 additions & 0 deletions tests/remote/test_thunderbird.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from mozdownload.utils import urljoin


@pytest.mark.ci_only
@pytest.mark.parametrize("args,url", [
({'application': 'thunderbird', 'platform': 'win32', 'version': 'latest'},
None),
Expand All @@ -34,6 +35,7 @@ def test_release_scraper(tmpdir, args, url):
assert unquote(scraper.url) == urljoin(BASE_URL, url)


@pytest.mark.ci_only
@pytest.mark.parametrize("args,url", [
({'application': 'thunderbird', 'platform': 'linux', 'version': '52.7.0'},
'thunderbird/candidates/52.7.0-candidates/build1/linux-i686/en-US/thunderbird-52.7.0.tar.bz2'),
Expand All @@ -57,6 +59,7 @@ def test_candidate_scraper(tmpdir, args, url):
assert unquote(scraper.url) == urljoin(BASE_URL, url)


@pytest.mark.ci_only
@pytest.mark.parametrize("args", [
{'application': 'thunderbird', 'platform': 'linux', 'branch': 'comm-central'},
{'application': 'thunderbird', 'platform': 'linux64', 'branch': 'comm-central'},
Expand All @@ -77,6 +80,7 @@ def test_daily_scraper(tmpdir, args):
mozdownload.DailyScraper(destination=tmpdir, **args)


@pytest.mark.ci_only
@pytest.mark.parametrize("args", [
{'application': 'thunderbird', 'branch': 'comm-central', 'platform': 'win32'},
{'application': 'thunderbird', 'branch': 'comm-central', 'platform': 'win64'},
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ envlist = py27, py36, pylama

[testenv]
usedevelop = true
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH CI
deps = -rrequirements/tests.txt
commands =
pytest --verbose --cov {posargs}
Expand Down

0 comments on commit dfbac8c

Please sign in to comment.