From dfbac8c7975867332ac6714388b5ead9823b2e84 Mon Sep 17 00:00:00 2001 From: dmitrypolo Date: Thu, 8 Aug 2019 14:48:28 -0400 Subject: [PATCH] Add markers to run remote tests by default only in CI (#572) --- pytest.ini | 4 ++++ tests/conftest.py | 9 +++++++++ tests/remote/test_devedition.py | 2 ++ tests/remote/test_fennec.py | 1 + tests/remote/test_firefox.py | 4 ++++ tests/remote/test_thunderbird.py | 4 ++++ tox.ini | 2 +- 7 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..85ce36cc --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +markers = + ci_only: Only run these tests within the CI environment. + diff --git a/tests/conftest.py b/tests/conftest.py index 0641c462..73ac79fb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 + """) diff --git a/tests/remote/test_devedition.py b/tests/remote/test_devedition.py index 8e326295..fd20b608 100644 --- a/tests/remote/test_devedition.py +++ b/tests/remote/test_devedition.py @@ -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'), @@ -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'), diff --git a/tests/remote/test_fennec.py b/tests/remote/test_fennec.py index 48d09ba6..1b63a3ab 100644 --- a/tests/remote/test_fennec.py +++ b/tests/remote/test_fennec.py @@ -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', diff --git a/tests/remote/test_firefox.py b/tests/remote/test_firefox.py index c6fd142f..7a8be9e9 100644 --- a/tests/remote/test_firefox.py +++ b/tests/remote/test_firefox.py @@ -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), @@ -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'), @@ -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'}, @@ -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'}, diff --git a/tests/remote/test_thunderbird.py b/tests/remote/test_thunderbird.py index 12f0f8a6..1c400422 100644 --- a/tests/remote/test_thunderbird.py +++ b/tests/remote/test_thunderbird.py @@ -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), @@ -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'), @@ -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'}, @@ -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'}, diff --git a/tox.ini b/tox.ini index c61c8eb8..ab23f119 100644 --- a/tox.ini +++ b/tox.ini @@ -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}