From 4302c6735d2985ed76e4a2d4a3319c7ef2c7ca84 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 20 Jun 2018 11:39:40 +0200 Subject: Add __slots__ to classes This is mainly a quality of life change --- crocoite/browser.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crocoite/browser.py') diff --git a/crocoite/browser.py b/crocoite/browser.py index 57d0dd0..f583c9b 100644 --- a/crocoite/browser.py +++ b/crocoite/browser.py @@ -36,6 +36,9 @@ class Item: Simple wrapper containing Chrome request and response """ + __slots__ = ('tab', 'chromeRequest', 'chromeResponse', 'chromeFinished', + 'isRedirect', 'failed') + def __init__ (self, tab): self.tab = tab self.chromeRequest = None @@ -164,6 +167,7 @@ class SiteLoader: XXX: track popup windows/new tabs and close them """ + __slots__ = ('requests', 'browser', 'url', 'logger', 'queue', 'notify', 'tab') allowedSchemes = {'http', 'https'} def __init__ (self, browser, url, logger=logging.getLogger(__name__)): @@ -329,6 +333,8 @@ class ChromeService: ready. """ + __slots__ = ('binary', 'windowSize', 'p', 'userDataDir') + def __init__ (self, binary='google-chrome-stable', windowSize=(1920, 1080)): self.binary = binary self.windowSize = windowSize @@ -380,6 +386,8 @@ class ChromeService: self.p = None class NullService: + __slots__ = ('url') + def __init__ (self, url): self.url = url @@ -397,6 +405,7 @@ from operator import itemgetter class TestItem (Item): """ This should be as close to Item as possible """ + __slots__ = ('bodySend', '_body') base = 'http://localhost:8000/' def __init__ (self, path, status, headers, bodyReceive, bodySend=None): @@ -461,6 +470,8 @@ def startServer (): httpd.serve_forever() class TestSiteLoader (unittest.TestCase): + __slots__ = ('server', 'baseurl', 'service', 'browser') + def setUp (self): from multiprocessing import Process self.server = Process (target=startServer) -- cgit v1.2.3