Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Testgres tests create log dir in exact place#243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletionstests/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,6 +50,17 @@ def CalcRootDir() -> str:
r = os.path.abspath(r)
return r

# --------------------------------------------------------------------
def CalcRootLogDir() -> str:
if TestConfigPropNames.TEST_CFG__LOG_DIR in os.environ:
resultPath = os.environ[TestConfigPropNames.TEST_CFG__LOG_DIR]
else:
rootDir = __class__.CalcRootDir()
resultPath = os.path.join(rootDir, "logs")

assert type(resultPath) == str # noqa: E721
return resultPath

# --------------------------------------------------------------------
def CalcCurrentTestWorkerSignature() -> str:
currentPID = os.getpid()
Expand DownExpand Up@@ -86,11 +97,18 @@ class TestStartupData:
TestStartupData__Helper.CalcCurrentTestWorkerSignature()
)

sm_RootLogDir: str = TestStartupData__Helper.CalcRootLogDir()

# --------------------------------------------------------------------
def GetRootDir() -> str:
assert type(__class__.sm_RootDir) == str # noqa: E721
return __class__.sm_RootDir

# --------------------------------------------------------------------
def GetRootLogDir() -> str:
assert type(__class__.sm_RootLogDir) == str # noqa: E721
return __class__.sm_RootLogDir

# --------------------------------------------------------------------
def GetCurrentTestWorkerSignature() -> str:
assert type(__class__.sm_CurrentTestWorkerSignature) == str # noqa: E721
Expand DownExpand Up@@ -954,13 +972,9 @@ def pytest_configure(config: pytest.Config) -> None:
log_name = TestStartupData.GetCurrentTestWorkerSignature()
log_name += ".log"

if TestConfigPropNames.TEST_CFG__LOG_DIR in os.environ:
log_path_v = os.environ[TestConfigPropNames.TEST_CFG__LOG_DIR]
log_path = pathlib.Path(log_path_v)
else:
log_path = config.rootpath.joinpath("logs")
log_dir = TestStartupData.GetRootLogDir()

log_path.mkdir(exist_ok=True)
pathlib.Path(log_dir).mkdir(exist_ok=True)

logging_plugin: _pytest.logging.LoggingPlugin = config.pluginmanager.get_plugin(
"logging-plugin"
Expand All@@ -969,7 +983,7 @@ def pytest_configure(config: pytest.Config) -> None:
assert logging_plugin is not None
assert isinstance(logging_plugin, _pytest.logging.LoggingPlugin)

logging_plugin.set_log_path(str(log_path / log_name))
logging_plugin.set_log_path(os.path.join(log_dir, log_name))


# /////////////////////////////////////////////////////////////////////////////

[8]ページ先頭

©2009-2025 Movatter.jp