Skip to content

Commit 5aa3385

Browse files
authored
Merge pull request #72 from confluentinc/pytest_timeouts
Pytest timeouts
2 parents bbe7c90 + 7b95623 commit 5aa3385

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ python:
44
- "3.4"
55
before_install:
66
- bash tools/bootstrap-librdkafka.sh v0.9.2 tmp-build
7+
- pip install pytest-timeout
78
install:
89
- pip install -v --global-option=build_ext --global-option="-Itmp-build/include/" --global-option="-Ltmp-build/lib" .
910
env:
1011
- LD_LIBRARY_PATH=$PWD/tmp-build/lib
11-
script: py.test --ignore=tmp-build
12+
script: py.test -v --timeout 20 --ignore=tmp-build

tests/test_Consumer.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

3-
from confluent_kafka import Consumer, TopicPartition, KafkaError, KafkaException, TIMESTAMP_NOT_AVAILABLE
3+
from confluent_kafka import Consumer, TopicPartition, KafkaError, KafkaException, TIMESTAMP_NOT_AVAILABLE, libversion
4+
import pytest
45

56

67
def test_basic_api():
@@ -64,8 +65,13 @@ def dummy_assign_revoke (consumer, partitions):
6465
kc.close()
6566

6667

68+
# librdkafka <=0.9.2 has a race-issue where it will hang indefinately
69+
# if a commit is issued when no coordinator is available.
70+
@pytest.mark.skipif(libversion()[1] <= 0x000902ff,
71+
reason="requires librdkafka >0.9.2")
6772
def test_on_commit ():
6873
""" Verify that on_commit is only called once per commit() (issue #71) """
74+
6975
class CommitState (object):
7076
def __init__(self, topic, partition):
7177
self.topic = topic

tox.ini

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
envlist = flake8,py27,py34,py35
33

44
[testenv]
5-
deps = pytest
6-
commands = py.test
5+
deps =
6+
pytest
7+
pytest-timeout
8+
commands = py.test -v --timeout 20 --ignore=tmp-build
79

810
[testenv:flake8]
911
deps = flake8
@@ -13,6 +15,6 @@ commands = flake8
1315
testpaths = tests
1416

1517
[flake8]
16-
exclude = venv,env,.env,.tox,.toxenv,.git,build,docs
18+
exclude = venv*,env,.env,.tox,.toxenv,.git,build,docs,tmp-build
1719
max-line-length = 119
1820
accept-encodings = utf-8

0 commit comments

Comments
 (0)