mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
mock getenv to always return the same value for $USER
This commit is contained in:
parent
c4c49678f9
commit
c430ab57ba
1 changed files with 11 additions and 6 deletions
|
|
@ -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,12 +30,15 @@ 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:
|
||||||
pelican = Pelican(path=INPUT_PATH, output_path=temp_path)
|
with patch("pelican.contents.getenv") as mock_getenv:
|
||||||
pelican.run()
|
# force getenv('USER') to always return the same value
|
||||||
diff = dircmp(temp_path, os.sep.join((OUTPUT_PATH, "basic")))
|
mock_getenv.return_value = "Dummy Author"
|
||||||
self.assertEqual(diff.left_only, [])
|
pelican = Pelican(path=INPUT_PATH, output_path=temp_path)
|
||||||
self.assertEqual(diff.right_only, [])
|
pelican.run()
|
||||||
self.assertEqual(diff.diff_files, [])
|
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):
|
def test_custom_generation_works(self):
|
||||||
# the same thing with a specified set of settings should work
|
# the same thing with a specified set of settings should work
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue