Skip to content

Commit a5e6555

Browse files
Kimberly Sereduckkimberlythegeek
authored andcommitted
cleaned up toxfile and tests (#60)
1 parent 375272a commit a5e6555

File tree

2 files changed

+20
-43
lines changed

2 files changed

+20
-43
lines changed

axe_selenium_python/tests/test_axe.py

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
33
# You can obtain one at http://mozilla.org/MPL/2.0/.
44

5-
import os
6-
import re
7-
import sys
8-
import time
9-
5+
from os import path
106
import pytest
117

128

139
@pytest.mark.nondestructive
14-
def test_rules(axe):
10+
def test_get_rules(axe):
1511
"""Assert number of rule tests matches number of available rules."""
1612
axe.inject()
1713
rules = axe.get_rules()
@@ -27,39 +23,28 @@ def test_execute(axe):
2723

2824

2925
@pytest.mark.nondestructive
30-
def test_write_results(base_url, axe):
31-
"""Write JSON results to file."""
32-
# get string of current python version
33-
version = 'v' + str(sys.version_info[0]) + '_' + \
34-
str(sys.version_info[1]) + '_' + str(sys.version_info[2])
35-
# strip protocol and dots
36-
filename = re.sub('(http:\/\/|https:\/\/|\.php|\.asp|\.html)', '', base_url)
37-
# replace slashes with underscores
38-
filename = re.sub('(\/|\.)', '_', filename)
39-
# create filename "examplecom-datetime-python-version.json"
40-
filename += '-' + time.strftime('%m-%d-%y-%X') + '-' + version + '.json'
41-
42-
axe.inject()
43-
data = axe.execute()
44-
axe.write_results(filename, data)
45-
# check that file exists and is not empty
46-
assert os.path.exists(filename) and os.path.getsize(filename) > 0, \
47-
'Output file not found.'
48-
49-
50-
@pytest.mark.nondestructive
51-
def test_violations(axe):
52-
"""Assert that no violations were found."""
26+
def test_run(base_url, axe):
27+
"""Assert that run method returns results."""
5328
violations = axe.run()
54-
55-
report = axe.report(violations)
56-
assert len(violations) == 0, report
29+
assert violations is not None
5730

5831

5932
@pytest.mark.nondestructive
6033
def test_report(axe):
61-
"""Test that report exists"""
34+
"""Test that report exists."""
6235
violations = axe.run()
6336

6437
report = axe.report(violations)
6538
assert report is not None, report
39+
40+
41+
@pytest.mark.nondestructive
42+
def test_write_results(base_url, axe):
43+
"""Assert that write results method creates a file."""
44+
axe.inject()
45+
data = axe.execute()
46+
filename = 'results.json'
47+
axe.write_results(filename, data)
48+
# check that file exists and is not empty
49+
assert path.exists(filename), 'Output file not found.'
50+
assert path.getsize(filename) > 0, 'File contains no data.'

tox.ini

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,12 @@ skipsdist = true
44

55
[testenv]
66
skip_install = true
7-
deps =
8-
-raxe_selenium_python/tests/requirements/tests.txt
9-
commands =
10-
py.test -r=a --verbose --driver=Firefox {posargs}
7+
deps = -raxe_selenium_python/tests/requirements/tests.txt
8+
commands = pytest --verbose --driver=Firefox {posargs}
119

1210
[testenv:flake8]
1311
deps = -raxe_selenium_python/tests/requirements/flake8.txt
1412
commands = flake8 {posargs:.}
1513

1614
[flake8]
1715
ignore = E501
18-
19-
[pytest]
20-
addopts = --verbose -r=a --driver=Firefox
21-
testpaths = .
22-
xfail_strict = true
23-
base_url = https://mozillians.org

0 commit comments

Comments
 (0)