假设我们有一个现有的地图:
const m1 = new Map([['color', 'red'], ['owner', 'Flavio'], ['age', 2]])
如果我们要创建一个新地图,是否足够:
const m2 = new Map(m1);
或者也许是:
const m2 = new Map(Array.from(m1))
答案 0 :(得分:0)
MDN表示您可以这样做。
import sys
import mock
import unittest
import StringIO
import __builtin__
# [..] your code
class Test(unittest.TestCase):
@mock.patch.object(__builtin__, 'raw_input')
def test_refreshtime_validation(self, mocked_raw_input):
my_stdout = StringIO.StringIO()
sys.stdout = my_stdout
mocked_raw_input.side_effect = ['error', '0', '1']
outputs = '\n**Please enter a valid number (Must be an integer).**\n'+\
'\n\n**Please enter a valid number (Must be greater than 0).**\n\n'
valid_value = refreshtime_validation()
sys.stdout = sys.__stdout__
self.assertEquals(my_stdout.getvalue(), outputs)
self.assertEquals(valid_value, 1)
unittest.main()