Skip to content

Commit 5152004

Browse files
author
Kimberly Sereduck
authored
updated write_results method to create a path object to support recent changes, updated readme to match (#151)
1 parent 9d48a64 commit 5152004

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ Usage
4747

4848
.. code-block:: python
4949
50-
import pytest
50+
import pytest
51+
import os
5152
from selenium import webdriver
5253
from axe_selenium_python import Axe
5354
@@ -60,7 +61,7 @@ Usage
6061
# Run axe accessibility checks.
6162
results = axe.execute()
6263
# Write results to file
63-
axe.write_results('a11y.json', results)
64+
axe.write_results(results, 'a11y.json')
6465
driver.close()
6566
# Assert no violations are found
6667
assert len(results["violations"]) == 0, axe.report(results["violations"])

axe_selenium_python/axe.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import json
6+
import os
67
from io import open
7-
from os import path
88

9-
_DEFAULT_SCRIPT = path.join(
10-
path.dirname(__file__), "node_modules", "axe-core", "axe.min.js"
9+
_DEFAULT_SCRIPT = os.path.join(
10+
os.path.dirname(__file__), "node_modules", "axe-core", "axe.min.js"
1111
)
1212

1313

@@ -100,7 +100,9 @@ def write_results(self, data, name="results.json"):
100100
:param name: Name of file to be written to.
101101
:param output: JSON object.
102102
"""
103-
with open(name, "w", encoding="utf8") as f:
103+
filepath = os.path.join(os.getcwd(), name)
104+
105+
with open(filepath, "w", encoding="utf8") as f:
104106
try:
105107
f.write(unicode(json.dumps(data, indent=4)))
106108
except NameError:

0 commit comments

Comments
 (0)