mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Port practracker unit tests to python 3
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user