Skip to content

Commit c96eb0c

Browse files
committed
Added test for writing results without filepath
1 parent b036ab3 commit c96eb0c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

axe_selenium_python/tests/test_axe.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import json
6-
from os import getenv, path
6+
from os import getcwd, getenv, path
77

88
import pytest
99
from selenium import webdriver
@@ -76,3 +76,17 @@ def test_write_results_to_file(tmpdir, mocker):
7676
actual_file_contents = json.loads(f.read())
7777

7878
assert data == actual_file_contents
79+
80+
81+
def test_write_results_without_filepath(mocker):
82+
axe = Axe(mocker.MagicMock())
83+
data = {"testKey": "testValue"}
84+
cwd = getcwd()
85+
filename = path.join(cwd, "results.json")
86+
87+
axe.write_results(data, filename)
88+
with open(filename) as f:
89+
actual_file_contents = json.loads(f.read())
90+
91+
assert data == actual_file_contents
92+
assert path.dirname(filename) == cwd

0 commit comments

Comments
 (0)