Skip to content

Commit afaab34

Browse files
author
Kimberly Sereduck
authored
Updated readme, black python code formatting (#136)
* make it black * update readme to remove docker references
1 parent 0ab1ee3 commit afaab34

8 files changed

Lines changed: 87 additions & 66 deletions

File tree

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ cache:
77
- $HOME/virtualenv/python2.7.9/lib/python2.7/site-packages
88
- node_modules
99

10+
install: pip install -r axe_selenium_python/tests/requirements/tests.txt
11+
script: skip
12+
1013
jobs:
1114
include:
1215
- stage:
@@ -53,13 +56,16 @@ jobs:
5356

5457
script: tox
5558
- stage: deploy
56-
if: tag =~ ^\d.\d.\d
5759
deploy:
5860
provider: pypi
5961
user: kimberlythegeek
6062
password:
6163
secure: LHsL91XR32/M4r5ETAvaN/vUTakYByIfdwdCw6EI59LBvSnwaSant010QIl39+uafuev57yzUC/Y+orefczjkJnG3KdQBNS0Rt/zWIMw0Dr6Fp41Vg66e5URK/FRIwK36WlWzOcd3GkrQLLaDeqnXVzDWVMuXPP9/1ssu6mvriSeLctPsmX5N6m4yZwxNtpFsTLEh+BumXiamCuqjTI0RpyqxYlUVfio0G5LWeY9rkPskrwbSbc8xhq/PMk/ecLtlAxdn8AwgjLYCAt9d6NRfgL4Yp0R+kkfUQsX1Wf8A/pBNRr8Ht8Hy4CNlnEphgao4fgVEY4dc6tZL3FXOU9jQSmbChoANlbPzDhO+nb6d/QW5vLHVDufKyRQqtFxD90XFXlWFc/0gnD6tPZhi+UEFmBMoo9ugWDnYUeBd1T3lbwKT7sOmOQS58WhDVMLxPwr2BfgItGrNsaVHmzx9v0BnxZvD5ilmvNPrad6Rcsa0N8GtNXpnbyaupWzA97bemzuLqNHOjTm6TMZWRol6lLEJsJ1MRs7xWI4DYztXzlWITH7rvf6NNyvXKe9FPV3Lfoei3k1mT8QuEh6bIEFpBKRVV0ObQVSfFQ4M4wbgDBb3CbHVqMqFHgi98mpUo9tNGm4uzZCXw3hfEQpUPugKaH+VHoaylE+MR+fOhsyVlLQluM=
64+
install: skip
65+
script: skip
66+
skip_cleanup: true
6267
on:
6368
tags: true
6469
branch: master
65-
distributions: sdist bdist_wheel
70+
distributions: "sdist bdist_wheel"
71+
skip_cleanup: true

README.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ You will need the following prerequisites in order to use axe-selenium-python:
2929

3030
- selenium >= 3.0.0
3131
- Python 2.7 or 3.6
32-
- `geckodriver <https://github.com/mozilla/geckodriver/releases>`_ downloaded and `added to your PATH <https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path#answer-40208762>`_
32+
- The appropriate driver for the browser you intend to use, downloaded and added to your path, e.g. geckodriver for Firefox:
33+
- `geckodriver <https://github.com/mozilla/geckodriver/releases>`_ downloaded and `added to your PATH <https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path#answer-40208762>`_
3334

3435
Installation
3536
------------
@@ -73,12 +74,11 @@ Contributing
7374

7475
Fork the repository and submit PRs with bug fixes and enhancements;
7576
contributions are very welcome. You can run the tests using
76-
`Docker <https://www.docker.com/>`_:
77+
`tox <https://tox.readthedocs.io/en/latest/>`_:
7778

7879
.. code-block:: bash
7980
80-
$ docker build -t axe-selenium-python .
81-
$ docker run -it axe-selenium-python tox
81+
$ tox
8282
8383
Resources
8484
---------
@@ -117,7 +117,7 @@ version 1.2.3
117117

118118
version 1.2.1
119119
**************
120-
- Updated axe.min.js to ``axe-core@2.6.1``
120+
- Updated axe to ``axe-core@2.6.1``
121121
- Modified impact_included class method to reflect changes to the aXe API:
122122
- There are now only 3 impact levels: 'critical', 'serious', and 'minor'
123123

@@ -132,6 +132,7 @@ version 0.0.3
132132
- Added run method to Axe class to simplify the usage in existing test suites
133133
- run method includes the ability to set what impact level to test for: 'minor', 'moderate', 'severe', 'critical'
134134

135+
<<<<<<< HEAD
135136
version 0.0.276
136137
****************
137138
- Added pytest-axe usage example to README
@@ -141,6 +142,9 @@ version 0.0.275
141142
- Added usage example to README
142143

143144
version 0.0.273
145+
=======
146+
version 0.0.28
147+
>>>>>>> ba24ec56528e4458f0a5604a8d511923c943a479
144148
****************
145149
- Added selenium instance as a class attribute
146150
- Changed file paths to OS independent structure

axe_selenium_python/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
from .axe import Axe # NOQA
5+
from .axe import Axe # NOQA

axe_selenium_python/axe.py

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from io import open
77
from os import path
88

9-
_DEFAULT_SCRIPT = path.join(path.dirname(__file__), 'node_modules', 'axe-core', 'axe.min.js')
9+
_DEFAULT_SCRIPT = path.join(
10+
path.dirname(__file__), "node_modules", "axe-core", "axe.min.js"
11+
)
1012

1113

1214
class Axe(object):
13-
1415
def __init__(self, selenium, script_url=_DEFAULT_SCRIPT):
1516
self.script_url = script_url
1617
self.selenium = selenium
@@ -22,7 +23,7 @@ def inject(self):
2223
:param script_url: location of the axe-core script.
2324
:type script_url: string
2425
"""
25-
with open(self.script_url, 'r', encoding='utf8') as f:
26+
with open(self.script_url, "r", encoding="utf8") as f:
2627
self.selenium.execute_script(f.read())
2728

2829
def execute(self, context=None, options=None):
@@ -32,18 +33,18 @@ def execute(self, context=None, options=None):
3233
:param context: which page part(s) to analyze and/or what to exclude.
3334
:param options: dictionary of aXe options.
3435
"""
35-
template = 'return axe.run(%s).then(function(result){return result;});'
36-
args = ''
36+
template = "return axe.run(%s).then(function(result){return result;});"
37+
args = ""
3738

3839
# If context parameter is passed, add to args
3940
if context is not None:
40-
args += '%r' % context
41+
args += "%r" % context
4142
# Add comma delimiter only if both parameters are passed
4243
if context is not None and options is not None:
43-
args += ','
44+
args += ","
4445
# If options parameter is passed, add to args
4546
if options is not None:
46-
args += '%s' % options
47+
args += "%s" % options
4748

4849
command = template % args
4950
response = self.selenium.execute_script(command)
@@ -58,36 +59,43 @@ def report(self, violations):
5859
:return report: Readable report of violations.
5960
:rtype: string
6061
"""
61-
string = ''
62-
string += 'Found ' + str(len(violations)) + ' accessibility violations:'
62+
string = ""
63+
string += "Found " + str(len(violations)) + " accessibility violations:"
6364
for violation in violations:
64-
string += '\n\n\nRule Violated:\n' + violation['id'] + ' - ' + violation['description'] + \
65-
'\n\tURL: ' + violation['helpUrl'] + \
66-
'\n\tImpact Level: ' + violation['impact'] + \
67-
'\n\tTags:'
68-
for tag in violation['tags']:
69-
string += ' ' + tag
70-
string += '\n\tElements Affected:'
65+
string += (
66+
"\n\n\nRule Violated:\n"
67+
+ violation["id"]
68+
+ " - "
69+
+ violation["description"]
70+
+ "\n\tURL: "
71+
+ violation["helpUrl"]
72+
+ "\n\tImpact Level: "
73+
+ violation["impact"]
74+
+ "\n\tTags:"
75+
)
76+
for tag in violation["tags"]:
77+
string += " " + tag
78+
string += "\n\tElements Affected:"
7179
i = 1
72-
for node in violation['nodes']:
73-
for target in node['target']:
74-
string += '\n\t' + str(i) + ') Target: ' + target
80+
for node in violation["nodes"]:
81+
for target in node["target"]:
82+
string += "\n\t" + str(i) + ") Target: " + target
7583
i += 1
76-
for item in node['all']:
77-
string += '\n\t\t' + item['message']
78-
for item in node['any']:
79-
string += '\n\t\t' + item['message']
80-
for item in node['none']:
81-
string += '\n\t\t' + item['message']
82-
string += '\n\n\n'
84+
for item in node["all"]:
85+
string += "\n\t\t" + item["message"]
86+
for item in node["any"]:
87+
string += "\n\t\t" + item["message"]
88+
for item in node["none"]:
89+
string += "\n\t\t" + item["message"]
90+
string += "\n\n\n"
8391
return string
8492

85-
def write_results(self, data, name='results.json'):
93+
def write_results(self, data, name="results.json"):
8694
"""
8795
Write JSON to file with the specified name.
8896
8997
:param name: Name of file to be written to.
9098
:param output: JSON object.
9199
"""
92-
with open(name, 'r', encoding='utf8') as f:
100+
with open(name, "r", encoding="utf8") as f:
93101
f.write(json.dumps(data, indent=4))

axe_selenium_python/tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
@pytest.mark.optionalhook
1212
def pytest_html_results_table_header(cells):
1313
"""Add description and sortable time header to HTML report."""
14-
cells.insert(2, html.th('Description'))
15-
cells.insert(0, html.th('Time', class_='sortable time', col='time'))
14+
cells.insert(2, html.th("Description"))
15+
cells.insert(0, html.th("Time", class_="sortable time", col="time"))
1616

1717

1818
@pytest.mark.optionalhook
1919
def pytest_html_results_table_row(report, cells):
2020
"""Add description and sortable time column to HTML report."""
2121
cells.insert(2, html.td(report.description))
22-
cells.insert(1, html.td(datetime.utcnow(), class_='col-time'))
22+
cells.insert(1, html.td(datetime.utcnow(), class_="col-time"))
2323

2424

2525
@pytest.mark.hookwrapper

axe_selenium_python/tests/test_axe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from ..axe import Axe
1111

12-
_DEFAULT_TEST_FILE = path.join(path.dirname(__file__), 'test_page.html')
12+
_DEFAULT_TEST_FILE = path.join(path.dirname(__file__), "test_page.html")
1313

1414

1515
@pytest.fixture
@@ -22,7 +22,7 @@ def driver():
2222
@pytest.mark.nondestructive
2323
def test_run_axe_sample_page(driver):
2424
"""Run axe against sample page and verify JSON output is as expected."""
25-
driver.get('file://' + _DEFAULT_TEST_FILE)
25+
driver.get("file://" + _DEFAULT_TEST_FILE)
2626
axe = Axe(driver)
2727
axe.inject()
2828
data = axe.execute()

setup.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,27 @@
55

66
from setuptools import find_packages, setup
77

8-
with open('./README.rst') as f:
8+
with open("./README.rst") as f:
99
readme = f.read()
1010

11-
setup(name='axe-selenium-python',
12-
version='2.1.2',
13-
description='Python library to integrate axe and selenium for web \
14-
accessibility testing.',
15-
long_description=readme,
16-
url='http://github.com/mozilla-services/axe-selenium-python',
17-
author='Kimberly Sereduck',
18-
author_email='ksereduck@mozilla.com',
19-
packages=find_packages(),
20-
package_data={
21-
'axe_selenium_python': [
22-
'axe_selenium_python/node_modules/axe-core/axe.min.js',
23-
'axe_selenium_python/tests/test_page.html'
24-
],
25-
},
26-
include_package_data=True,
27-
install_requires=[
28-
'selenium>=3.0.2',
29-
'pytest>=3.0'
30-
],
31-
license='Mozilla Public License 2.0 (MPL 2.0)',
32-
keywords='axe-core selenium pytest-selenium accessibility automation mozilla')
11+
setup(
12+
name="axe-selenium-python",
13+
use_scm_version=True,
14+
description="Python library to integrate axe and selenium for web \
15+
accessibility testing.",
16+
long_description=open("README.rst").read(),
17+
url="http://github.com/mozilla-services/axe-selenium-python",
18+
author="Kimberly Sereduck",
19+
author_email="ksereduck@mozilla.com",
20+
packages=find_packages(),
21+
package_data={
22+
"axe_selenium_python": [
23+
"axe_selenium_python/node_modules/axe-core/axe.min.js",
24+
"axe_selenium_python/tests/test_page.html",
25+
]
26+
},
27+
include_package_data=True,
28+
install_requires=["selenium>=3.0.2", "pytest>=3.0"],
29+
license="Mozilla Public License 2.0 (MPL 2.0)",
30+
keywords="axe-core selenium pytest-selenium accessibility automation mozilla",
31+
)

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ deps = -raxe_selenium_python/tests/requirements/flake8.txt
1919
commands = flake8 {posargs:.}
2020

2121
[flake8]
22-
ignore = E501
22+
max-line-length = 88
23+
# Black will break a line before a binary operator when splitting a block
24+
# of code over multiple lines. This is so that Black is compliant with the
25+
# recent changes in the PEP8 style guide.
26+
ignore = W503
2327

2428
[isort]
2529
default_section = THIRDPARTY

0 commit comments

Comments
 (0)