Merge remote-tracking branch 'origin/master' into 3915-immutable-size

This commit is contained in:
Itamar Turner-Trauring 2022-09-08 13:41:46 -04:00
commit b72b51d22d
3 changed files with 19 additions and 12 deletions

0
newsfragments/3916.minor Normal file
View File

View File

@ -14,11 +14,17 @@ if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from zope.interface import implementer from zope.interface import implementer
from twisted.trial.unittest import TestCase
from twisted.internet.interfaces import IPushProducer, IPullProducer from twisted.internet.interfaces import IPushProducer, IPullProducer
from allmydata.util.consumer import MemoryConsumer from allmydata.util.consumer import MemoryConsumer
from .common import (
SyncTestCase,
)
from testtools.matchers import (
Equals,
)
@implementer(IPushProducer) @implementer(IPushProducer)
@implementer(IPullProducer) @implementer(IPullProducer)
@ -50,7 +56,7 @@ class Producer(object):
self.consumer.unregisterProducer() self.consumer.unregisterProducer()
class MemoryConsumerTests(TestCase): class MemoryConsumerTests(SyncTestCase):
"""Tests for MemoryConsumer.""" """Tests for MemoryConsumer."""
def test_push_producer(self): def test_push_producer(self):
@ -60,14 +66,14 @@ class MemoryConsumerTests(TestCase):
consumer = MemoryConsumer() consumer = MemoryConsumer()
producer = Producer(consumer, [b"abc", b"def", b"ghi"]) producer = Producer(consumer, [b"abc", b"def", b"ghi"])
consumer.registerProducer(producer, True) consumer.registerProducer(producer, True)
self.assertEqual(consumer.chunks, [b"abc"]) self.assertThat(consumer.chunks, Equals([b"abc"]))
producer.iterate() producer.iterate()
producer.iterate() producer.iterate()
self.assertEqual(consumer.chunks, [b"abc", b"def", b"ghi"]) self.assertThat(consumer.chunks, Equals([b"abc", b"def", b"ghi"]))
self.assertEqual(consumer.done, False) self.assertFalse(consumer.done)
producer.iterate() producer.iterate()
self.assertEqual(consumer.chunks, [b"abc", b"def", b"ghi"]) self.assertThat(consumer.chunks, Equals([b"abc", b"def", b"ghi"]))
self.assertEqual(consumer.done, True) self.assertTrue(consumer.done)
def test_pull_producer(self): def test_pull_producer(self):
""" """
@ -76,8 +82,8 @@ class MemoryConsumerTests(TestCase):
consumer = MemoryConsumer() consumer = MemoryConsumer()
producer = Producer(consumer, [b"abc", b"def", b"ghi"]) producer = Producer(consumer, [b"abc", b"def", b"ghi"])
consumer.registerProducer(producer, False) consumer.registerProducer(producer, False)
self.assertEqual(consumer.chunks, [b"abc", b"def", b"ghi"]) self.assertThat(consumer.chunks, Equals([b"abc", b"def", b"ghi"]))
self.assertEqual(consumer.done, True) self.assertTrue(consumer.done)
# download_to_data() is effectively tested by some of the filenode tests, e.g. # download_to_data() is effectively tested by some of the filenode tests, e.g.

View File

@ -46,9 +46,10 @@ from hypothesis.strategies import (
binary, binary,
) )
from testtools import ( from .common import (
TestCase, SyncTestCase,
) )
from testtools.matchers import ( from testtools.matchers import (
Always, Always,
Equals, Equals,
@ -61,7 +62,7 @@ from testtools.twistedsupport import (
) )
class FakeWebTest(TestCase): class FakeWebTest(SyncTestCase):
""" """
Test the WebUI verified-fakes infrastucture Test the WebUI verified-fakes infrastucture
""" """