mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-26 10:50:12 +08:00
fix #418: deepcopy testcase when testcase contains BufferReader
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
|
||||
@@ -214,6 +215,26 @@ class TestUtils(ApiServerUnittest):
|
||||
self.assertIsInstance(ordered_dict, dict)
|
||||
self.assertIn("a", ordered_dict)
|
||||
|
||||
def test_deepcopy_dict(self):
|
||||
data = {
|
||||
'a': 1,
|
||||
'b': [2, 4],
|
||||
'c': lambda x: x+1,
|
||||
'd': open('LICENSE'),
|
||||
'f': {
|
||||
'f1': {'a1': 2},
|
||||
'f2': io.open('LICENSE', 'rb'),
|
||||
}
|
||||
}
|
||||
new_data = utils.deepcopy_dict(data)
|
||||
data["a"] = 0
|
||||
self.assertEqual(new_data["a"], 1)
|
||||
data["f"]["f1"] = 123
|
||||
self.assertEqual(new_data["f"]["f1"], {'a1': 2})
|
||||
self.assertEqual(id(new_data["d"]), id(data["d"]))
|
||||
self.assertNotEqual(id(new_data["b"]), id(data["b"]))
|
||||
self.assertEqual(id(new_data["c"]), id(data["c"]))
|
||||
|
||||
def test_update_ordered_dict(self):
|
||||
map_list = [
|
||||
{"a": 1},
|
||||
|
||||
Reference in New Issue
Block a user