diff options
author | Jeff Widman <jeff@jeffwidman.com> | 2018-10-28 22:28:58 -0700 |
---|---|---|
committer | Jeff Widman <jeff@jeffwidman.com> | 2018-10-29 02:01:20 -0700 |
commit | ca004366b863f23ecadd7a5bb3525dda4311f367 (patch) | |
tree | e5567c2e6fb7169b92610b838638af4b97c8d8cb /test/test_consumer.py | |
parent | 4d13713c515796afa535e980b15fa0c2c86ba0eb (diff) | |
download | kafka-python-ca004366b863f23ecadd7a5bb3525dda4311f367.tar.gz |
Migrate from `Unittest` to `pytest`
I only migrated tests that will continue to be used even after the
removal of the old `Simple*` classes in #1196.
The `decorator` in tox is leftover from a previous usage that was
already removed from the code but not from tox.
Diffstat (limited to 'test/test_consumer.py')
-rw-r--r-- | test/test_consumer.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/test/test_consumer.py b/test/test_consumer.py index 013529f..4ea01c8 100644 --- a/test/test_consumer.py +++ b/test/test_consumer.py @@ -2,6 +2,7 @@ import sys from mock import MagicMock, patch from . import unittest +import pytest from kafka import SimpleConsumer, KafkaConsumer, MultiProcessConsumer from kafka.errors import ( @@ -11,17 +12,13 @@ from kafka.structs import ( FetchResponsePayload, OffsetAndMessage, OffsetFetchResponsePayload) -class TestKafkaConsumer(unittest.TestCase): - def test_non_integer_partitions(self): - with self.assertRaises(AssertionError): - SimpleConsumer(MagicMock(), 'group', 'topic', partitions=['0']) - +class TestKafkaConsumer: def test_session_timeout_larger_than_request_timeout_raises(self): - with self.assertRaises(KafkaConfigurationError): + with pytest.raises(KafkaConfigurationError): KafkaConsumer(bootstrap_servers='localhost:9092', api_version=(0,9), group_id='foo', session_timeout_ms=60000, request_timeout_ms=40000) def test_fetch_max_wait_larger_than_request_timeout_raises(self): - with self.assertRaises(KafkaConfigurationError): + with pytest.raises(KafkaConfigurationError): KafkaConsumer(bootstrap_servers='localhost:9092', fetch_max_wait_ms=41000, request_timeout_ms=40000) def test_subscription_copy(self): @@ -43,7 +40,12 @@ class TestMultiProcessConsumer(unittest.TestCase): self.assertEqual(fetch_last_known_offsets.call_args[0], (partitions,) ) self.assertEqual(client.get_partition_ids_for_topic.call_count, 0) # pylint: disable=no-member + class TestSimpleConsumer(unittest.TestCase): + def test_non_integer_partitions(self): + with self.assertRaises(AssertionError): + SimpleConsumer(MagicMock(), 'group', 'topic', partitions=['0']) + def test_simple_consumer_failed_payloads(self): client = MagicMock() consumer = SimpleConsumer(client, group=None, |