Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 53 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you aren't starting any kind of window manager. If you don't want these to run headless, you need to start a window management service. See this.

Or you could run firefox as headless using the env variable MOZ_HEADLESS=1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try setting MOZ_HEADLESS=1, and I'm still seeing the same error.

As far as checking for not None, I'm not really sure what to check for, unless I save JSON data and check the new data against that.

I really just want to see if it returns anything.

What do you suggest?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could either have firefox open a page within a directory or you could use this.

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
4 changes: 2 additions & 2 deletions axe_selenium_python/axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
3 changes: 1 addition & 2 deletions axe_selenium_python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
4 changes: 2 additions & 2 deletions axe_selenium_python/tests/requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pytest==3.1.1
pytest-selenium==1.10.0
pytest==3.4.2
pytest-selenium==1.12.0
15 changes: 8 additions & 7 deletions axe_selenium_python/tests/test_axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# You can obtain one at http://mozilla.org/MPL/2.0/.

from os import path

import pytest


Expand All @@ -11,38 +12,38 @@ 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
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
Expand Down
3 changes: 3 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ commands = flake8 {posargs:.}

[flake8]
ignore = E501

[pytest]
base_url = http://www.mozillians.org