test(Slot): cover __repr__

Issue: #4324
This commit is contained in:
Ammar Najjar 2020-08-28 13:58:32 +02:00
parent 5ab1a318e8
commit 0e57918231
No known key found for this signature in database
GPG Key ID: 4E358D38135EE7EA
2 changed files with 11 additions and 1 deletions

View File

@ -43,7 +43,7 @@ class Slot:
cls_name = self.__class__.__name__
return (f"{cls_name}(concurrency={self.concurrency!r}, "
f"delay={self.delay:.2f}, "
f"randomize_delay={self.randomize_delay!r}")
f"randomize_delay={self.randomize_delay!r})")
def __str__(self):
return (

View File

@ -0,0 +1,10 @@
from twisted.trial import unittest
from scrapy.core.downloader import Slot
class SlotTest(unittest.TestCase):
def test_repr(self):
slot = Slot(concurrency=8, delay=0.1, randomize_delay=True)
self.assertEqual(repr(slot), 'Slot(concurrency=8, delay=0.10, randomize_delay=True)')