Skip to content

Commit c0d81b8

Browse files
tulinkryVladimir Kotal
authored andcommitted
Opengrok tools use pytest instead of unittest (#2504)
1 parent d0ba604 commit c0d81b8

File tree

8 files changed

+258
-251
lines changed

8 files changed

+258
-251
lines changed

opengrok-tools/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
145145
<include>MANIFEST.in</include>
146146
<include>README.md</include>
147147
<include>setup.py</include>
148+
<include>setup.cfg</include>
148149
</includes>
149150
</resource>
150151
</resources>
@@ -203,6 +204,7 @@ Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
203204
<argument>install</argument>
204205
<argument>--upgrade</argument>
205206
<argument>pip</argument>
207+
<argument>setuptools</argument>
206208
</arguments>
207209
</configuration>
208210
<phase>test</phase>

opengrok-tools/setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[aliases]
2+
test=pytest
3+
4+
[tool:pytest]
5+
addopts = -v --color=yes
6+
testpaths = src/test/python

opengrok-tools/setup.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ def my_test_suite():
4545
'pyyaml',
4646
'requests>=2.20.0',
4747
'resource',
48-
'filelock'
48+
'filelock',
49+
'setuptools>=36.7.2',
50+
],
51+
setup_requires=[
52+
'pytest-runner',
53+
'setuptools>=36.7.2',
4954
],
5055
tests_require=[
51-
'parameterized'
56+
'pytest',
5257
],
5358
entry_points={
5459
'console_scripts': [

opengrok-tools/src/test/python/test_binaries.py

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,31 @@
2323
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2424
#
2525

26-
import unittest
27-
28-
from parameterized import parameterized
26+
import pytest
2927

3028
from opengrok_tools.utils.command import Command
3129

3230

33-
class TestApp(unittest.TestCase):
34-
@parameterized.expand((
35-
('opengrok'),
36-
('opengrok-indexer'),
37-
('opengrok-groups'),
38-
('opengrok-config-merge'),
39-
('opengrok-deploy'),
40-
('opengrok-java'),
41-
('opengrok-mirror'),
42-
('opengrok-projadm'),
43-
('opengrok-reindex-project'),
44-
('opengrok-sync'),
45-
))
46-
def test_opengrok_binary(self, command):
47-
"""
48-
Test that installed command is able to run
49-
:param command: the command name
50-
:return:
51-
"""
52-
pass
53-
cmd = Command([command, '--help'])
54-
cmd.execute()
55-
self.assertEqual(0, cmd.getretcode())
56-
self.assertEqual(Command.FINISHED, cmd.getstate())
57-
self.assertTrue(len(cmd.getoutputstr()) > 1)
58-
59-
60-
if __name__ == '__main__':
61-
unittest.main()
31+
@pytest.mark.parametrize('command', (
32+
('opengrok'),
33+
('opengrok-indexer'),
34+
('opengrok-groups'),
35+
('opengrok-config-merge'),
36+
('opengrok-deploy'),
37+
('opengrok-java'),
38+
('opengrok-mirror'),
39+
('opengrok-projadm'),
40+
('opengrok-reindex-project'),
41+
('opengrok-sync'),
42+
))
43+
def test_opengrok_binary(command):
44+
"""
45+
Test that installed command is able to run
46+
:param command: the command name
47+
:return:
48+
"""
49+
cmd = Command([command, '--help'])
50+
cmd.execute()
51+
assert cmd.getretcode() == 0
52+
assert cmd.getstate() == Command.FINISHED
53+
assert len(cmd.getoutputstr()) > 1

0 commit comments

Comments
 (0)