diff --git a/.travis.yml b/.travis.yml index 0c30569..c675756 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ cache: - $HOME/virtualenv/python2.7.9/lib/python2.7/site-packages - node_modules +install: pip install -r axe_selenium_python/tests/requirements/tests.txt +script: skip + jobs: include: - stage: @@ -53,13 +56,16 @@ jobs: script: tox - stage: deploy - if: tag =~ ^\d.\d.\d deploy: provider: pypi user: kimberlythegeek password: secure: LHsL91XR32/M4r5ETAvaN/vUTakYByIfdwdCw6EI59LBvSnwaSant010QIl39+uafuev57yzUC/Y+orefczjkJnG3KdQBNS0Rt/zWIMw0Dr6Fp41Vg66e5URK/FRIwK36WlWzOcd3GkrQLLaDeqnXVzDWVMuXPP9/1ssu6mvriSeLctPsmX5N6m4yZwxNtpFsTLEh+BumXiamCuqjTI0RpyqxYlUVfio0G5LWeY9rkPskrwbSbc8xhq/PMk/ecLtlAxdn8AwgjLYCAt9d6NRfgL4Yp0R+kkfUQsX1Wf8A/pBNRr8Ht8Hy4CNlnEphgao4fgVEY4dc6tZL3FXOU9jQSmbChoANlbPzDhO+nb6d/QW5vLHVDufKyRQqtFxD90XFXlWFc/0gnD6tPZhi+UEFmBMoo9ugWDnYUeBd1T3lbwKT7sOmOQS58WhDVMLxPwr2BfgItGrNsaVHmzx9v0BnxZvD5ilmvNPrad6Rcsa0N8GtNXpnbyaupWzA97bemzuLqNHOjTm6TMZWRol6lLEJsJ1MRs7xWI4DYztXzlWITH7rvf6NNyvXKe9FPV3Lfoei3k1mT8QuEh6bIEFpBKRVV0ObQVSfFQ4M4wbgDBb3CbHVqMqFHgi98mpUo9tNGm4uzZCXw3hfEQpUPugKaH+VHoaylE+MR+fOhsyVlLQluM= + install: skip + script: skip + skip_cleanup: true on: tags: true branch: master - distributions: sdist bdist_wheel + distributions: "sdist bdist_wheel" + skip_cleanup: true diff --git a/README.rst b/README.rst index c994d03..0d1fed4 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,8 @@ You will need the following prerequisites in order to use axe-selenium-python: - selenium >= 3.0.0 - Python 2.7 or 3.6 -- `geckodriver `_ downloaded and `added to your PATH `_ +- The appropriate driver for the browser you intend to use, downloaded and added to your path, e.g. geckodriver for Firefox: + - `geckodriver `_ downloaded and `added to your PATH `_ Installation ------------ @@ -73,12 +74,11 @@ Contributing Fork the repository and submit PRs with bug fixes and enhancements; contributions are very welcome. You can run the tests using -`Docker `_: +`tox `_: .. code-block:: bash - $ docker build -t axe-selenium-python . - $ docker run -it axe-selenium-python tox + $ tox Resources --------- @@ -117,7 +117,7 @@ version 1.2.3 version 1.2.1 ************** -- Updated axe.min.js to ``axe-core@2.6.1`` +- Updated axe to ``axe-core@2.6.1`` - Modified impact_included class method to reflect changes to the aXe API: - There are now only 3 impact levels: 'critical', 'serious', and 'minor' @@ -132,6 +132,7 @@ version 0.0.3 - Added run method to Axe class to simplify the usage in existing test suites - run method includes the ability to set what impact level to test for: 'minor', 'moderate', 'severe', 'critical' +<<<<<<< HEAD version 0.0.276 **************** - Added pytest-axe usage example to README @@ -141,6 +142,9 @@ version 0.0.275 - Added usage example to README version 0.0.273 +======= +version 0.0.28 +>>>>>>> ba24ec56528e4458f0a5604a8d511923c943a479 **************** - Added selenium instance as a class attribute - Changed file paths to OS independent structure diff --git a/axe_selenium_python/__init__.py b/axe_selenium_python/__init__.py index 5676c76..b86eab3 100644 --- a/axe_selenium_python/__init__.py +++ b/axe_selenium_python/__init__.py @@ -2,4 +2,4 @@ # 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 .axe import Axe # NOQA +from .axe import Axe # NOQA diff --git a/axe_selenium_python/axe.py b/axe_selenium_python/axe.py index 354271d..f1b6802 100644 --- a/axe_selenium_python/axe.py +++ b/axe_selenium_python/axe.py @@ -6,11 +6,12 @@ from io import open from os import path -_DEFAULT_SCRIPT = path.join(path.dirname(__file__), 'node_modules', 'axe-core', 'axe.min.js') +_DEFAULT_SCRIPT = path.join( + path.dirname(__file__), "node_modules", "axe-core", "axe.min.js" +) class Axe(object): - def __init__(self, selenium, script_url=_DEFAULT_SCRIPT): self.script_url = script_url self.selenium = selenium @@ -22,7 +23,7 @@ def inject(self): :param script_url: location of the axe-core script. :type script_url: string """ - with open(self.script_url, 'r', encoding='utf8') as f: + with open(self.script_url, "r", encoding="utf8") as f: self.selenium.execute_script(f.read()) def execute(self, context=None, options=None): @@ -32,18 +33,18 @@ def execute(self, context=None, options=None): :param context: which page part(s) to analyze and/or what to exclude. :param options: dictionary of aXe options. """ - template = 'return axe.run(%s).then(function(result){return result;});' - args = '' + template = "return axe.run(%s).then(function(result){return result;});" + args = "" # If context parameter is passed, add to args if context is not None: - args += '%r' % context + args += "%r" % context # Add comma delimiter only if both parameters are passed if context is not None and options is not None: - args += ',' + args += "," # If options parameter is passed, add to args if options is not None: - args += '%s' % options + args += "%s" % options command = template % args response = self.selenium.execute_script(command) @@ -58,36 +59,43 @@ def report(self, violations): :return report: Readable report of violations. :rtype: string """ - string = '' - string += 'Found ' + str(len(violations)) + ' accessibility violations:' + string = "" + string += "Found " + str(len(violations)) + " accessibility violations:" for violation in violations: - string += '\n\n\nRule Violated:\n' + violation['id'] + ' - ' + violation['description'] + \ - '\n\tURL: ' + violation['helpUrl'] + \ - '\n\tImpact Level: ' + violation['impact'] + \ - '\n\tTags:' - for tag in violation['tags']: - string += ' ' + tag - string += '\n\tElements Affected:' + string += ( + "\n\n\nRule Violated:\n" + + violation["id"] + + " - " + + violation["description"] + + "\n\tURL: " + + violation["helpUrl"] + + "\n\tImpact Level: " + + violation["impact"] + + "\n\tTags:" + ) + for tag in violation["tags"]: + string += " " + tag + string += "\n\tElements Affected:" i = 1 - for node in violation['nodes']: - for target in node['target']: - string += '\n\t' + str(i) + ') Target: ' + target + for node in violation["nodes"]: + for target in node["target"]: + string += "\n\t" + str(i) + ") Target: " + target i += 1 - for item in node['all']: - string += '\n\t\t' + item['message'] - for item in node['any']: - string += '\n\t\t' + item['message'] - for item in node['none']: - string += '\n\t\t' + item['message'] - string += '\n\n\n' + for item in node["all"]: + string += "\n\t\t" + item["message"] + for item in node["any"]: + string += "\n\t\t" + item["message"] + for item in node["none"]: + string += "\n\t\t" + item["message"] + string += "\n\n\n" return string - def write_results(self, data, name='results.json'): + def write_results(self, data, name="results.json"): """ Write JSON to file with the specified name. :param name: Name of file to be written to. :param output: JSON object. """ - with open(name, 'r', encoding='utf8') as f: + with open(name, "r", encoding="utf8") as f: f.write(json.dumps(data, indent=4)) diff --git a/axe_selenium_python/tests/conftest.py b/axe_selenium_python/tests/conftest.py index b6a729b..875d86b 100644 --- a/axe_selenium_python/tests/conftest.py +++ b/axe_selenium_python/tests/conftest.py @@ -11,15 +11,15 @@ @pytest.mark.optionalhook def pytest_html_results_table_header(cells): """Add description and sortable time header to HTML report.""" - cells.insert(2, html.th('Description')) - cells.insert(0, html.th('Time', class_='sortable time', col='time')) + cells.insert(2, html.th("Description")) + cells.insert(0, html.th("Time", class_="sortable time", col="time")) @pytest.mark.optionalhook def pytest_html_results_table_row(report, cells): """Add description and sortable time column to HTML report.""" cells.insert(2, html.td(report.description)) - cells.insert(1, html.td(datetime.utcnow(), class_='col-time')) + cells.insert(1, html.td(datetime.utcnow(), class_="col-time")) @pytest.mark.hookwrapper diff --git a/axe_selenium_python/tests/test_axe.py b/axe_selenium_python/tests/test_axe.py index 6d48d00..775c3ed 100644 --- a/axe_selenium_python/tests/test_axe.py +++ b/axe_selenium_python/tests/test_axe.py @@ -9,7 +9,7 @@ from ..axe import Axe -_DEFAULT_TEST_FILE = path.join(path.dirname(__file__), 'test_page.html') +_DEFAULT_TEST_FILE = path.join(path.dirname(__file__), "test_page.html") @pytest.fixture @@ -22,7 +22,7 @@ def driver(): @pytest.mark.nondestructive def test_run_axe_sample_page(driver): """Run axe against sample page and verify JSON output is as expected.""" - driver.get('file://' + _DEFAULT_TEST_FILE) + driver.get("file://" + _DEFAULT_TEST_FILE) axe = Axe(driver) axe.inject() data = axe.execute() diff --git a/setup.py b/setup.py index a851f68..e162648 100644 --- a/setup.py +++ b/setup.py @@ -5,28 +5,27 @@ from setuptools import find_packages, setup -with open('./README.rst') as f: +with open("./README.rst") as f: readme = f.read() -setup(name='axe-selenium-python', - version='2.1.2', - description='Python library to integrate axe and selenium for web \ - accessibility testing.', - long_description=readme, - url='http://github.com/mozilla-services/axe-selenium-python', - author='Kimberly Sereduck', - author_email='ksereduck@mozilla.com', - packages=find_packages(), - package_data={ - 'axe_selenium_python': [ - 'axe_selenium_python/node_modules/axe-core/axe.min.js', - 'axe_selenium_python/tests/test_page.html' - ], - }, - include_package_data=True, - install_requires=[ - 'selenium>=3.0.2', - 'pytest>=3.0' - ], - license='Mozilla Public License 2.0 (MPL 2.0)', - keywords='axe-core selenium pytest-selenium accessibility automation mozilla') +setup( + name="axe-selenium-python", + use_scm_version=True, + description="Python library to integrate axe and selenium for web \ + accessibility testing.", + long_description=open("README.rst").read(), + url="http://github.com/mozilla-services/axe-selenium-python", + author="Kimberly Sereduck", + author_email="ksereduck@mozilla.com", + packages=find_packages(), + package_data={ + "axe_selenium_python": [ + "axe_selenium_python/node_modules/axe-core/axe.min.js", + "axe_selenium_python/tests/test_page.html", + ] + }, + include_package_data=True, + install_requires=["selenium>=3.0.2", "pytest>=3.0"], + license="Mozilla Public License 2.0 (MPL 2.0)", + keywords="axe-core selenium pytest-selenium accessibility automation mozilla", +) diff --git a/tox.ini b/tox.ini index 2f67d87..f851245 100644 --- a/tox.ini +++ b/tox.ini @@ -19,7 +19,11 @@ deps = -raxe_selenium_python/tests/requirements/flake8.txt commands = flake8 {posargs:.} [flake8] -ignore = E501 +max-line-length = 88 +# Black will break a line before a binary operator when splitting a block +# of code over multiple lines. This is so that Black is compliant with the +# recent changes in the PEP8 style guide. +ignore = W503 [isort] default_section = THIRDPARTY