Skip to content

Commit 7e5d556

Browse files
bmwiedemannwillmcgugan
authored andcommitted
Fix test_ftp_parse to pass in 2018 (#114)
because the embedded UNIX epoch values assumed that tm_year is 2017
1 parent 3a62b40 commit 7e5d556

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/test_ftp_parse.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
from __future__ import unicode_literals
22

33
from datetime import datetime
4+
import mock
45
import time
56
import unittest
67

78
from fs import _ftp_parse as ftp_parse
89

10+
time2017 = time.struct_time([2017, 11, 28, 1, 1, 1, 1, 332, 0])
11+
912

1013
class TestFTPParse(unittest.TestCase):
1114

12-
def test_parse_time(self):
15+
@mock.patch("time.localtime")
16+
def test_parse_time(self, mock_localtime):
1317
self.assertEqual(
1418
ftp_parse._parse_time('JUL 05 1974'),
1519
142214400.0
1620
)
1721

18-
year = time.localtime().tm_year
22+
mock_localtime.return_value = time2017
1923
self.assertEqual(
2024
ftp_parse._parse_time('JUL 05 02:00'),
2125
1499220000.0
@@ -32,7 +36,9 @@ def test_parse(self):
3236
def test_parse_line(self):
3337
self.assertIs(ftp_parse.parse_line('not a dir'), None)
3438

35-
def test_decode_linux(self):
39+
@mock.patch("time.localtime")
40+
def test_decode_linux(self, mock_localtime):
41+
mock_localtime.return_value = time2017
3642
directory = """\
3743
lrwxrwxrwx 1 0 0 19 Jan 18 2006 debian -> ./pub/mirror/debian
3844
drwxr-xr-x 10 0 0 4096 Aug 03 09:21 debian-archive

0 commit comments

Comments
 (0)