From c430ab57ba1c2276f0a150cd8c6467fdb12a01b5 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 4 Apr 2012 22:48:11 +0200 Subject: [PATCH] mock getenv to always return the same value for $USER --- tests/test_pelican.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/test_pelican.py b/tests/test_pelican.py index 49328ebe..1192dfe1 100644 --- a/tests/test_pelican.py +++ b/tests/test_pelican.py @@ -6,6 +6,8 @@ except ImportError: import os from filecmp import dircmp +from mock import patch + from .support import temporary_folder from pelican import Pelican @@ -28,12 +30,15 @@ class TestPelican(unittest.TestCase): # ones and generate the output without raising any exception / issuing # any warning. with temporary_folder() as temp_path: - pelican = Pelican(path=INPUT_PATH, output_path=temp_path) - pelican.run() - diff = dircmp(temp_path, os.sep.join((OUTPUT_PATH, "basic"))) - self.assertEqual(diff.left_only, []) - self.assertEqual(diff.right_only, []) - self.assertEqual(diff.diff_files, []) + 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.run() + diff = dircmp(temp_path, os.sep.join((OUTPUT_PATH, "basic"))) + self.assertEqual(diff.left_only, []) + self.assertEqual(diff.right_only, []) + self.assertEqual(diff.diff_files, []) def test_custom_generation_works(self): # the same thing with a specified set of settings should work