Skip to content

Commit 954e8db

Browse files
committed
Add a way to run tests on an installed version of uvloop
1 parent 9dfbf0c commit 954e8db

File tree

8 files changed

+31
-14
lines changed

8 files changed

+31
-14
lines changed

.ci/build-manylinux-wheels.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PIP="/opt/python/${PYTHON_VERSION}/bin/pip"
88
${PIP} install --upgrade pip wheel
99
${PIP} install --upgrade setuptools
1010
${PIP} install -r /io/.ci/requirements.txt
11-
make -C /io/ PYTHON="${PYTHON}"
11+
make -C /io/ PYTHON="${PYTHON}" clean compile
1212
${PIP} wheel /io/ -w /io/dist/
1313

1414
# Bundle external shared libraries into the wheels.
@@ -21,5 +21,5 @@ PYTHON="/opt/python/${PYTHON_VERSION}/bin/python"
2121
PIP="/opt/python/${PYTHON_VERSION}/bin/pip"
2222
${PIP} install ${PYMODULE} --no-index -f file:///io/dist
2323
rm -rf /io/tests/__pycache__
24-
make -C /io/ PYTHON="${PYTHON}" test
24+
make -C /io/ PYTHON="${PYTHON}" testinstalled
2525
rm -rf /io/tests/__pycache__

.ci/travis-build-wheels.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ elif [ "${TRAVIS_OS_NAME}" == "osx" ]; then
6262

6363
pip install ${PYMODULE} --no-index -f "file:///${_root}/dist"
6464
pushd / >/dev/null
65-
make -C "${_root}" test
65+
make -C "${_root}" testinstalled
6666
popd >/dev/null
6767

6868
_upload_wheels

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ matrix:
5050
dist: trusty
5151
sudo: false
5252
language: python
53-
python: "3.6-dev"
53+
python: "3.6"
5454
env: BUILD=tests
5555

5656
- os: linux

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: _default clean clean-libuv distclean compile debug docs test release
1+
.PHONY: _default clean clean-libuv distclean compile debug docs test testinstalled release
22

33

44
PYTHON ?= python
@@ -9,7 +9,7 @@ _default: compile
99

1010
clean:
1111
rm -fr dist/ doc/_build/ *.egg-info uvloop/loop.*.pyd
12-
rm -fr build/lib.* build/temp.*
12+
rm -fr build/lib.* build/temp.* build/libuv
1313
rm -fr uvloop/*.c uvloop/*.html uvloop/*.so
1414
rm -fr uvloop/handles/*.html uvloop/includes/*.html
1515
find . -name '__pycache__' | xargs rm -rf
@@ -44,5 +44,9 @@ test:
4444
$(PYTHON) setup.py test
4545

4646

47+
testinstalled:
48+
$(PYTHON) tests/__init__.py
49+
50+
4751
release: distclean compile test
4852
$(PYTHON) setup.py sdist bdist_wheel upload

tests/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
import os.path
2+
import sys
13
import unittest
4+
import unittest.runner
25

36

47
def suite():
58
test_loader = unittest.TestLoader()
6-
test_suite = test_loader.discover('.', pattern='test_*.py')
9+
test_suite = test_loader.discover(
10+
os.path.dirname(__file__), pattern='test_*.py')
711
return test_suite
12+
13+
14+
if __name__ == '__main__':
15+
runner = unittest.runner.TextTestRunner()
16+
result = runner.run(suite())
17+
sys.exit(not result.wasSuccessful())

tests/test_tcp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,9 @@ class Test_AIO_TCP(_TestTCP, tb.AIOTestCase):
842842

843843
class _TestSSL(tb.SSLTestCase):
844844

845+
ONLYCERT = tb._cert_fullname(__file__, 'ssl_cert.pem')
846+
ONLYKEY = tb._cert_fullname(__file__, 'ssl_key.pem')
847+
845848
def test_create_server_ssl_1(self):
846849
CNT = 0 # number of clients that were successful
847850
TOTAL_CNT = 25 # total number of clients that test will create

tests/test_unix.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,9 @@ class Test_AIO_Unix(_TestUnix, tb.AIOTestCase):
420420

421421
class _TestSSL(tb.SSLTestCase):
422422

423+
ONLYCERT = tb._cert_fullname(__file__, 'ssl_cert.pem')
424+
ONLYKEY = tb._cert_fullname(__file__, 'ssl_key.pem')
425+
423426
def test_create_unix_server_ssl_1(self):
424427
CNT = 0 # number of clients that were successful
425428
TOTAL_CNT = 25 # total number of clients that test will create

uvloop/_testbase.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ def tearDown(self):
133133
def skip_unclosed_handles_check(self):
134134
self._check_unclosed_resources_in_debug = False
135135

136-
def _cert_fullname(name):
137-
fullname = os.path.join(
138-
os.path.dirname(os.path.dirname(__file__)),
139-
'tests', 'certs', name)
136+
137+
def _cert_fullname(test_file_name, cert_file_name):
138+
fullname = os.path.abspath(os.path.join(
139+
os.path.dirname(test_file_name), 'certs', cert_file_name))
140140
assert os.path.isfile(fullname)
141141
return fullname
142142

@@ -173,9 +173,6 @@ def find_free_port(start_from=50000):
173173

174174
class SSLTestCase:
175175

176-
ONLYCERT = _cert_fullname('ssl_cert.pem')
177-
ONLYKEY = _cert_fullname('ssl_key.pem')
178-
179176
def _create_server_ssl_context(self, certfile, keyfile=None):
180177
sslcontext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
181178
sslcontext.options |= ssl.OP_NO_SSLv2

0 commit comments

Comments
 (0)