mock getenv to always return the same value for $USER

This commit is contained in:
Bruno Binet 2012-04-04 22:48:11 +02:00
commit c430ab57ba

View file

@ -6,6 +6,8 @@ except ImportError:
import os import os
from filecmp import dircmp from filecmp import dircmp
from mock import patch
from .support import temporary_folder from .support import temporary_folder
from pelican import Pelican from pelican import Pelican
@ -28,6 +30,9 @@ class TestPelican(unittest.TestCase):
# ones and generate the output without raising any exception / issuing # ones and generate the output without raising any exception / issuing
# any warning. # any warning.
with temporary_folder() as temp_path: with temporary_folder() as temp_path:
with patch("pelican.contents.getenv") as mock_getenv:
# force getenv('USER') to always return the same value
mock_getenv.return_value = "Dummy Author"
pelican = Pelican(path=INPUT_PATH, output_path=temp_path) pelican = Pelican(path=INPUT_PATH, output_path=temp_path)
pelican.run() pelican.run()
diff = dircmp(temp_path, os.sep.join((OUTPUT_PATH, "basic"))) diff = dircmp(temp_path, os.sep.join((OUTPUT_PATH, "basic")))