Skip to content

Commit

Permalink
skip tests that require git if git is not installed
Browse files Browse the repository at this point in the history
and minor tweaks to subprocess handling
  • Loading branch information
avaris committed Oct 28, 2023
1 parent b10c7c6 commit b6a9a83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pelican/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ def diff_subproc(first, second):
['git', '--no-pager', 'diff', '--no-ext-diff', '--exit-code',
'-w', first, second],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
stderr=subprocess.PIPE,
text=True,
)


Expand Down
9 changes: 7 additions & 2 deletions pelican/tests/test_pelican.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
LoggedTestCase,
diff_subproc,
locale_available,
mute
mute,
skipIfNoExecutable,
)

CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -69,7 +70,8 @@ def assertDirsEqual(self, left_path, right_path, msg=None):
if proc.returncode != 0:
msg = self._formatMessage(
msg,
"%s and %s differ:\n%s" % (left_path, right_path, err)
"%s and %s differ:\nstdout:\n%s\nstderr\n%s" %
(left_path, right_path, out, err)
)
raise self.failureException(msg)

Expand All @@ -88,6 +90,7 @@ def test_order_of_generators(self):
generator_classes, Sequence,
"_get_generator_classes() must return a Sequence to preserve order")

@skipIfNoExecutable(['git', '--version'])
def test_basic_generation_works(self):
# when running pelican without settings, it should pick up the default
# ones and generate correct output without raising any exception
Expand All @@ -107,6 +110,7 @@ def test_basic_generation_works(self):
msg="Unable to find.*skipping url replacement",
level=logging.WARNING)

@skipIfNoExecutable(['git', '--version'])
def test_custom_generation_works(self):
# the same thing with a specified set of settings should work
settings = read_settings(path=SAMPLE_CONFIG, override={
Expand All @@ -121,6 +125,7 @@ def test_custom_generation_works(self):
self.temp_path, os.path.join(OUTPUT_PATH, 'custom')
)

@skipIfNoExecutable(['git', '--version'])
@unittest.skipUnless(locale_available('fr_FR.UTF-8') or
locale_available('French'), 'French locale needed')
def test_custom_locale_generation_works(self):
Expand Down

0 comments on commit b6a9a83

Please sign in to comment.