[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Fix metric test
commit 6844a56c81b05a70ef6ba2a1c8ec3acd663e6340
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Fri Jan 17 14:29:52 2020 -0800
Fix metric test
Just the normal unicode/byte issue. This fixes...
Traceback (most recent call last):
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_metrics.py", line 164, in test_email_metrics
email_metrix.recordValidEmailRequest(responder)
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/metrics.py", line 411, in recordValidEmailRequest
self._recordEmailRequest(smtpAutoresp, True)
File "/home/atagar/Desktop/tor/bridgedb/bridgedb/metrics.py", line 403, in _recordEmailRequest
sld = emailAddr.domain.split(".")[0]
builtins.TypeError: a bytes-like object is required, not 'str'
Test results mostly unchanged...
before: FAILED (skips=114, failures=15, errors=109, successes=747)
after: FAILED (skips=114, failures=16, errors=108, successes=747)
---
bridgedb/metrics.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bridgedb/metrics.py b/bridgedb/metrics.py
index 2785874..bb888d9 100644
--- a/bridgedb/metrics.py
+++ b/bridgedb/metrics.py
@@ -279,6 +279,9 @@ class Metrics(metaclass=Singleton):
combinations.
"""
+ if isinstance(countryOrProvider, bytes):
+ countryOrProvider = countryOrProvider.decode('utf-8')
+
countryOrProvider = countryOrProvider.lower()
bridgeType = bridgeType.lower()
success = "success" if success else "fail"
@@ -400,7 +403,7 @@ class EmailMetrics(Metrics):
logging.debug("Recording %svalid email request for %s from %s." %
("" if success else "in", bridgeType, emailAddr))
- sld = emailAddr.domain.split(".")[0]
+ sld = emailAddr.domain.split(b".")[0]
# Now update our metrics.
key = self.createKey(self.keyPrefix, bridgeType, sld, success,
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits