Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions axe_selenium_python/axe.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ def report(self, violations):
string += "\n\n\n"
return string

def write_results(self, data, name="results.json"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a default parameter so that write_results can be called without a filename or path.

def write_results(self, data, name=None):
"""
Write JSON to file with the specified name.

:param name: Name of file to be written to.
:param name: Path to the file to be written to. If no path is passed
a new file will be created.
:param output: JSON object.
"""
filepath = os.path.join(os.getcwd(), name)

if name:
filepath = os.path.abspath(name)
else:
filepath = os.path.join(os.path.getcwd(), name)

with open(filepath, "w", encoding="utf8") as f:
try:
Expand Down