Skip to content

Commit 6e27c2a

Browse files
committed
Run tests with pytest
Signed-off-by: Aanand Prasad <[email protected]>
1 parent 36424ca commit 6e27c2a

File tree

6 files changed

+9
-20
lines changed

6 files changed

+9
-20
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ build-py3:
1313
test: unit-test integration-test unit-test-py3 integration-test-py3
1414

1515
unit-test: build
16-
docker run docker-py python tests/test.py
16+
docker run docker-py py.test tests/test.py
1717

1818
unit-test-py3: build-py3
19-
docker run docker-py3 python tests/test.py
19+
docker run docker-py3 py.test tests/test.py
2020

2121
integration-test: build
2222
docker run -e NOT_ON_HOST=true -v `$(HOST_TMPDIR)`:/tmp -v /var/run/docker.sock:/var/run/docker.sock docker-py python tests/integration_test.py

test-requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
mock==1.0.1
2-
coverage==3.7.1
2+
pytest==2.7.2
3+
pytest-cov==2.1.0

tests/fake_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import fake_stat
15+
from . import fake_stat
1616

1717
CURRENT_VERSION = 'v1.19'
1818

tests/test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,15 @@
2727
import tempfile
2828
import threading
2929
import time
30-
import unittest
3130
import warnings
3231
import random
3332

3433
import docker
3534
import requests
3635
import six
3736

38-
import base
39-
import fake_api
37+
from . import base
38+
from . import fake_api
4039

4140
try:
4241
from unittest import mock
@@ -2331,6 +2330,3 @@ def test_early_stream_response(self):
23312330

23322331
self.assertEqual(list(stream), [
23332332
str(i).encode() for i in range(50)])
2334-
2335-
if __name__ == '__main__':
2336-
unittest.main()

tests/utils_test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import os.path
3-
import unittest
43
import tempfile
54

65
from docker.client import Client
@@ -13,7 +12,7 @@
1312
from docker.utils.ports import build_port_bindings, split_port
1413
from docker.auth import resolve_repository_name, resolve_authconfig
1514

16-
import base
15+
from . import base
1716

1817

1918
class UtilsTest(base.BaseTestCase):
@@ -474,6 +473,3 @@ def test_build_port_bindings_with_nonmatching_internal_port_ranges(self):
474473
["127.0.0.1:1000:1000", "127.0.0.1:2000:2000"])
475474
self.assertEqual(port_bindings["1000"], [("127.0.0.1", "1000")])
476475
self.assertEqual(port_bindings["2000"], [("127.0.0.1", "2000")])
477-
478-
if __name__ == '__main__':
479-
unittest.main()

tox.ini

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ skipsdist=True
55
[testenv]
66
usedevelop=True
77
commands =
8-
{envbindir}/coverage run -p tests/test.py
9-
{envbindir}/coverage run -p tests/utils_test.py
10-
{envbindir}/coverage combine
11-
{envbindir}/coverage report
12-
{envbindir}/coverage html
8+
py.test --cov=docker tests/test.py tests/utils_test.py
139
deps =
1410
-r{toxinidir}/test-requirements.txt
1511
-r{toxinidir}/requirements.txt

0 commit comments

Comments
 (0)