test: move unittest aside source code

This commit is contained in:
debugtalk
2020-03-07 23:37:47 +08:00
parent bae0bda815
commit 1249d4d9c1
3 changed files with 8 additions and 4 deletions
@@ -1,12 +1,12 @@
import io import io
import os import os
import shutil import shutil
import unittest
from httprunner import exceptions, loader, utils from httprunner import exceptions, loader, utils
from tests.base import ApiServerUnittest
class TestUtils(ApiServerUnittest): class TestUtils(unittest.TestCase):
def test_set_os_environ(self): def test_set_os_environ(self):
self.assertNotIn("abc", os.environ) self.assertNotIn("abc", os.environ)
@@ -187,14 +187,18 @@ class TestUtils(ApiServerUnittest):
self.assertEqual(extended_variables_mapping["var1"], "val1") self.assertEqual(extended_variables_mapping["var1"], "val1")
def test_deepcopy_dict(self): def test_deepcopy_dict(self):
license_path = os.path.join(
os.path.dirname(os.path.dirname(__file__)),
"LICENSE"
)
data = { data = {
'a': 1, 'a': 1,
'b': [2, 4], 'b': [2, 4],
'c': lambda x: x+1, 'c': lambda x: x+1,
'd': open('LICENSE'), 'd': open(license_path),
'f': { 'f': {
'f1': {'a1': 2}, 'f1': {'a1': 2},
'f2': io.open('LICENSE', 'rb'), 'f2': io.open(license_path, 'rb'),
} }
} }
new_data = utils.deepcopy_dict(data) new_data = utils.deepcopy_dict(data)