mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
bugfix and tests for no settings path (no -s option)
This commit is contained in:
parent
5ccbbcc7d1
commit
e86f4eedcf
2 changed files with 12 additions and 5 deletions
|
|
@ -150,6 +150,10 @@ class TestUtils(LoggedTestCase):
|
||||||
self.assertEqual(next(folder_watcher), True)
|
self.assertEqual(next(folder_watcher), True)
|
||||||
self.assertEqual(next(file_watcher), True)
|
self.assertEqual(next(file_watcher), True)
|
||||||
|
|
||||||
|
# file watcher with None or empty path should return None
|
||||||
|
self.assertEqual(next(utils.file_watcher('')), None)
|
||||||
|
self.assertEqual(next(utils.file_watcher(None)), None)
|
||||||
|
|
||||||
empty_path = os.path.join(os.path.dirname(__file__), 'empty')
|
empty_path = os.path.join(os.path.dirname(__file__), 'empty')
|
||||||
try:
|
try:
|
||||||
os.mkdir(empty_path)
|
os.mkdir(empty_path)
|
||||||
|
|
|
||||||
|
|
@ -463,12 +463,15 @@ def file_watcher(path):
|
||||||
'''Generator for monitoring a file for modifications'''
|
'''Generator for monitoring a file for modifications'''
|
||||||
LAST_MTIME = 0
|
LAST_MTIME = 0
|
||||||
while True:
|
while True:
|
||||||
mtime = os.stat(path).st_mtime
|
if path:
|
||||||
if mtime > LAST_MTIME:
|
mtime = os.stat(path).st_mtime
|
||||||
LAST_MTIME = mtime
|
if mtime > LAST_MTIME:
|
||||||
yield True
|
LAST_MTIME = mtime
|
||||||
|
yield True
|
||||||
|
else:
|
||||||
|
yield False
|
||||||
else:
|
else:
|
||||||
yield False
|
yield None
|
||||||
|
|
||||||
|
|
||||||
def set_date_tzinfo(d, tz_name=None):
|
def set_date_tzinfo(d, tz_name=None):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue