Skip to content

Commit df1552f

Browse files
committed
Fixed default arguments and updated path handling logic
1 parent c42aa7d commit df1552f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

axe_selenium_python/axe.py

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

96-
def write_results(self, data, name):
96+
def write_results(self, data, name=None):
9797
"""
9898
Write JSON to file with the specified name.
9999
100-
:param name: Name of file to be written to.
100+
:param name: Path to the file to be written to. If no path is passed
101+
a new file will be created.
101102
:param output: JSON object.
102103
"""
103-
filepath = os.path.abspath(name)
104+
105+
if name:
106+
filepath = os.path.abspath(name)
107+
else:
108+
filepath = os.path.join(os.path.getcwd(), name)
104109

105110
with open(filepath, "w", encoding="utf8") as f:
106111
try:
107112
f.write(unicode(json.dumps(data, indent=4)))
108113
except NameError:
109114
f.write(json.dumps(data, indent=4))
110-
except FileNotFoundError as fnf_error:
111-
print(fnf_error)

0 commit comments

Comments
 (0)