Skip to content

Commit

Permalink
test solution for #212
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed Feb 18, 2024
1 parent ba423a4 commit 97821e9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pypiper/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@


LOCK_PREFIX = "lock."
LOGFILE_SUFFIX = "_log.md"


class Unbuffered(object):
Expand Down Expand Up @@ -210,7 +211,7 @@ def __init__(
# Establish the log file to check safety with logging keyword arguments.
# Establish the output folder since it's required for the log file.
self.outfolder = os.path.join(outfolder, "") # trailing slash
self.pipeline_log_file = pipeline_filepath(self, suffix="_log.md")
self.pipeline_log_file = pipeline_filepath(self, suffix=LOGFILE_SUFFIX)

# Set up logger
logger_kwargs = logger_kwargs or {}
Expand Down
19 changes: 18 additions & 1 deletion tests/pipeline_manager/test_manager_constructor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
""" Test effects of construction of a pipeline manager. """

import argparse
import os

import pytest

from pypiper.manager import CHECKPOINT_SPECIFICATIONS
from pypiper.manager import CHECKPOINT_SPECIFICATIONS, LOGFILE_SUFFIX
from tests.helpers import named_param

__author__ = "Vince Reuter"
Expand All @@ -24,6 +25,22 @@ def test_manager_starts_in_null_checkpoint_state(get_pipe_manager, checkpoint_ty
assert getattr(pm, checkpoint_type) is None


def test_logger_logfile_collision_with_manager_logfile_is_expected_error__issue_212(
get_pipe_manager, tmpdir
):
pipe_name = "test_issue212"
with pytest.raises(ValueError) as err_ctx:
get_pipe_manager(
name=pipe_name,
logger_kwargs={
"logfile": os.path.join(tmpdir.strpath, pipe_name + LOGFILE_SUFFIX)
},
)
assert str(err_ctx.value).startswith(
f"The logfile given for the pipeline manager's logger matches that which will be used by the manager itself"
)


class ManagerConstructorCheckpointSpecificationTests:
"""Tests for manager's constructor's ability to parse and set
checkpoint specifications, which can determine aspects of control flow."""
Expand Down

0 comments on commit 97821e9

Please sign in to comment.