summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-08-01 14:00:48 -0400
committerNick Mathewson <nickm@torproject.org>2019-08-01 14:00:48 -0400
commit5d98b54725efb15e904ea7abacdfe85da2a82bc5 (patch)
treec92335fb2e927f7574a3da87374dbe240a5b6080 /scripts
parent30da1b61c66794fa3b321573ef7b871081cf8eff (diff)
downloadtor-5d98b54725efb15e904ea7abacdfe85da2a82bc5.tar.gz
tor-5d98b54725efb15e904ea7abacdfe85da2a82bc5.zip
Port practracker unit tests to python 3
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/maint/practracker/practracker_tests.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/maint/practracker/practracker_tests.py b/scripts/maint/practracker/practracker_tests.py
index 865f68d186..45719d6cb7 100755
--- a/scripts/maint/practracker/practracker_tests.py
+++ b/scripts/maint/practracker/practracker_tests.py
@@ -4,7 +4,12 @@
import unittest
-import StringIO
+try:
+ # python 2 names the module this way...
+ from StringIO import StringIO
+except ImportError:
+ # python 3 names the module this way.
+ from io import StringIO
import metrics
@@ -38,7 +43,7 @@ fun,(
class TestFunctionLength(unittest.TestCase):
def test_function_length(self):
- funcs = StringIO.StringIO(function_file)
+ funcs = StringIO(function_file)
# All functions should have length 2
for name, lines in metrics.get_function_lines(funcs):
self.assertEqual(name, "fun")
@@ -50,7 +55,7 @@ class TestFunctionLength(unittest.TestCase):
class TestIncludeCount(unittest.TestCase):
def test_include_count(self):
- f = StringIO.StringIO("""
+ f = StringIO("""
# include <abc.h>
# include "def.h"
#include "ghi.h"