Skip to content

Commit bfdbf1e

Browse files
committed
Switch using pytest
1 parent 309e18e commit bfdbf1e

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ MANIFEST
1010
*.egg-info
1111
*.egg
1212
chromedriver.log
13+
.pytest_cache
1314

1415
dist
1516
build

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
mockito >= 1.0.0
55
robotstatuschecker >= 1.4
66
approvaltests >= 0.2.4
7+
pytest
78
requests
89

910
# Include normal dependencies from requirements.txt. Makes it possible to use

utest/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Before running the test, install the dependencies::
88

99
Unit Tests
1010
----------
11-
Units tests are written by using the Python default `unittest`_ framework.
11+
Units tests are written by using the `pytest`_ framework.
1212
Unit test can be executed by running::
1313

1414
python utest/run.py
@@ -33,7 +33,7 @@ must handled with `try/except ImportError:` and skipped with:
3333
imported from `from robot.utils import JYTHON`
3434

3535

36-
.. _unittest: https://docs.python.org/3/library/unittest.html
36+
.. _pytest: https://docs.pytest.org/en/latest/
3737
.. _ApprovalTests: https://github.com/approvals/ApprovalTests.Python
3838
.. _ApprovalTests blog post: http://blog.approvaltests.com/
3939
.. _Jython: http://www.jython.org/

utest/run.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import shutil
55
import sys
66
from os.path import abspath, dirname, join
7-
from unittest import defaultTestLoader, TextTestRunner
7+
8+
from pytest import main as py_main
89

910

1011
CURDIR = dirname(abspath(__file__))
12+
SRC = join(CURDIR, os.pardir, 'src')
1113

1214

1315
def remove_output_dir():
@@ -18,13 +20,12 @@ def remove_output_dir():
1820

1921

2022
def run_unit_tests():
21-
sys.path.insert(0, join(CURDIR, os.pardir, 'src'))
23+
sys.path.insert(0, SRC)
2224
try:
23-
suite = defaultTestLoader.discover(join(CURDIR, 'test'), 'test_*.py')
24-
result = TextTestRunner().run(suite)
25+
result = py_main(['--rootdir=%s' % CURDIR])
2526
finally:
2627
sys.path.pop(0)
27-
return min(len(result.failures) + len(result.errors), 255)
28+
return result
2829

2930

3031
if __name__ == '__main__':

0 commit comments

Comments
 (0)