diff --git a/.travis.yml b/.travis.yml index d39a1ca..727c51c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,53 @@ -language: python -python: 2.7 -env: - - TOXENV=flake8 -install: - - pip install tox -script: - - tox -notifications: - email: kpennington@mozilla.com +cache: pip + +sudo: required +jobs: + include: + - stage: + language: python + python: 2.7.12 + addons: + firefox: latest-nightly + env: + - TOXENV=py27 + - MOZ_HEADLESS=1 + before_install: + - wget -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-linux64.tar.gz + - mkdir $HOME/geckodriver && tar xvf /tmp/geckodriver.tar.gz -C $HOME/geckodriver + - export PATH=$HOME/geckodriver:$PATH + - firefox --version + - geckodriver --version + install: + - pip install tox + script: tox + notifications: + email: ksereduck@mozilla.com + - stage: + language: python + python: 3.6 + addons: + firefox: latest-nightly + env: + - TOXENV=py3 + - MOZ_HEADLESS=1 + before_install: + - wget -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-linux64.tar.gz + - wget -O /tmp/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.20.0/geckodriver-v0.20.0-linux64.tar.gz + - mkdir $HOME/geckodriver && tar xvf /tmp/geckodriver.tar.gz -C $HOME/geckodriver + - export PATH=$HOME/geckodriver:$PATH + - firefox --version + - geckodriver --version + install: + - pip install tox + script: tox + notifications: + email: ksereduck@mozilla.com + - stage: + language: python + python: 3.6 + env: TOXENV=flake8 + install: + - pip install tox + script: tox + notifications: + email: ksereduck@mozilla.com diff --git a/axe_selenium_python/axe.py b/axe_selenium_python/axe.py index 7db6130..e4e183d 100644 --- a/axe_selenium_python/axe.py +++ b/axe_selenium_python/axe.py @@ -2,10 +2,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -from os import environ, path import json -import time import re +import time +from os import environ, path _DEFAULT_SCRIPT = path.join(path.dirname(__file__), 'src', 'axe.min.js') diff --git a/axe_selenium_python/tests/conftest.py b/axe_selenium_python/tests/conftest.py index 99f345d..f214267 100644 --- a/axe_selenium_python/tests/conftest.py +++ b/axe_selenium_python/tests/conftest.py @@ -6,9 +6,8 @@ from datetime import datetime import pytest -from py.xml import html - from axe_selenium_python import Axe +from py.xml import html _DEFAULT_SCRIPT = os.path.join(os.path.dirname(__file__), 'src', 'axe.min.js') diff --git a/axe_selenium_python/tests/requirements/tests.txt b/axe_selenium_python/tests/requirements/tests.txt index 9669093..6324aac 100644 --- a/axe_selenium_python/tests/requirements/tests.txt +++ b/axe_selenium_python/tests/requirements/tests.txt @@ -1,2 +1,2 @@ -pytest==3.1.1 -pytest-selenium==1.10.0 +pytest==3.4.2 +pytest-selenium==1.12.0 diff --git a/axe_selenium_python/tests/test_axe.py b/axe_selenium_python/tests/test_axe.py index b555b87..2fdea6f 100644 --- a/axe_selenium_python/tests/test_axe.py +++ b/axe_selenium_python/tests/test_axe.py @@ -3,6 +3,7 @@ # You can obtain one at http://mozilla.org/MPL/2.0/. from os import path + import pytest @@ -11,7 +12,7 @@ def test_get_rules(axe): """Assert number of rule tests matches number of available rules.""" axe.inject() rules = axe.get_rules() - assert len(rules) == 58, len(rules) + assert len(rules) == 60 @pytest.mark.nondestructive @@ -19,30 +20,30 @@ def test_execute(axe): """Run axe against base_url and verify JSON output.""" axe.inject() data = axe.execute() - assert data is not None, data + assert data @pytest.mark.nondestructive -def test_run(base_url, axe): +def test_run(axe): """Assert that run method returns results.""" violations = axe.run() - assert violations is not None + assert violations @pytest.mark.nondestructive def test_report(axe): """Test that report exists.""" violations = axe.run() - report = axe.report(violations) - assert report is not None, report + assert report is not None and len(report) > 0 @pytest.mark.nondestructive -def test_write_results(base_url, axe): +def test_write_results(axe): """Assert that write results method creates a file.""" axe.inject() data = axe.execute() + filename = 'results.json' axe.write_results(filename, data) # check that file exists and is not empty diff --git a/tox.ini b/tox.ini index 7247427..ff9c916 100644 --- a/tox.ini +++ b/tox.ini @@ -13,3 +13,6 @@ commands = flake8 {posargs:.} [flake8] ignore = E501 + +[pytest] +base_url = http://www.mozillians.org