[bridgedb/master] Fix singleton metaclass definition

commit e3fc34053f98990d28a2121dabd93f4ee5f6edb3 Author: Damian Johnson <atagar@torproject.org> Date: Fri Jan 17 13:48:34 2020 -0800 Fix singleton metaclass definition This fixes the following... Traceback (most recent call last): File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_metrics.py", line 41, in setUp type(metrics.HTTPSMetrics()).clear() builtins.AttributeError: type object 'HTTPSMetrics' has no attribute 'clear' Test results changed as follows... before: FAILED (skips=114, failures=15, errors=116, successes=740) after: FAILED (skips=114, failures=15, errors=111, successes=745) --- bridgedb/metrics.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bridgedb/metrics.py b/bridgedb/metrics.py index 6b2e5cb..5d8bda3 100644 --- a/bridgedb/metrics.py +++ b/bridgedb/metrics.py @@ -184,16 +184,13 @@ class Singleton(type): pass -class Metrics(object): +class Metrics(metaclass=Singleton): """Base class representing metrics. This class provides functionality that our three distribution mechanisms share. """ - # We're using a meta class to implement a singleton for Metrics. - __metaclass__ = Singleton - def __init__(self, binSize=BIN_SIZE): logging.debug("Instantiating metrics class.") self.binSize = binSize
participants (1)
-
phw@torproject.org