Skip to content

Commit ac3d797

Browse files
committed
Allows write_results to take a path
1 parent 2face67 commit ac3d797

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

axe_selenium_python/axe.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,19 @@ def report(self, violations):
9393
string += "\n\n\n"
9494
return string
9595

96-
def write_results(self, data, name="results.json"):
96+
def write_results(self, data, name):
9797
"""
9898
Write JSON to file with the specified name.
9999
100100
:param name: Name of file to be written to.
101101
:param output: JSON object.
102102
"""
103-
filepath = os.path.join(os.getcwd(), name)
103+
filepath = os.path.abspath(name)
104104

105105
with open(filepath, "w", encoding="utf8") as f:
106106
try:
107107
f.write(unicode(json.dumps(data, indent=4)))
108108
except NameError:
109109
f.write(json.dumps(data, indent=4))
110+
except FileNotFoundError as fnf_error:
111+
print(fnf_error)

0 commit comments

Comments
 (0)