Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3191632

Browse files
committed
#18453: fix unused variables in test_xmlrpc. Patch by Vajrasky Kok.
1 parent 0f12be1 commit 3191632

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/test/test_xmlrpc.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import sys
44
import time
55
import unittest
6+
from unittest import mock
67
import xmlrpc.client as xmlrpclib
78
import xmlrpc.server
89
import http.client
@@ -249,7 +250,14 @@ def test_dotted_attribute(self):
249250

250251
class DateTimeTestCase(unittest.TestCase):
251252
def test_default(self):
252-
t = xmlrpclib.DateTime()
253+
with mock.patch('time.localtime') as localtime_mock:
254+
time_struct = time.struct_time(
255+
[2013, 7, 15, 0, 24, 49, 0, 196, 0])
256+
localtime_mock.return_value = time_struct
257+
localtime = time.localtime()
258+
t = xmlrpclib.DateTime()
259+
self.assertEqual(str(t),
260+
time.strftime("%Y%m%dT%H:%M:%S", localtime))
253261

254262
def test_time(self):
255263
d = 1181399930.036952
@@ -286,7 +294,7 @@ def test_decode(self):
286294
self.assertEqual(t1, tref)
287295

288296
t2 = xmlrpclib._datetime(d)
289-
self.assertEqual(t1, tref)
297+
self.assertEqual(t2, tref)
290298

291299
def test_comparison(self):
292300
now = datetime.datetime.now()

0 commit comments

Comments
 (0)