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

Commit2f550d8

Browse files
Testgres tests create log dir in exact place (#243)
When we do not define TEST_CFG__LOG_DIR it is expected the testgres tests will create a log directory in a root of testgres project folder.We used config.rootpath for detect this folder in pytest_configure function.It was occurred that config.rootpath can point to another (unexpected) place.So we will use exact code to calculate testgres project folder (see TestStartupData.GetRootLogDir) to avid this problem.
1 parent94d7572 commit2f550d8

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

‎tests/conftest.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ def CalcRootDir() -> str:
5050
r=os.path.abspath(r)
5151
returnr
5252

53+
# --------------------------------------------------------------------
54+
defCalcRootLogDir()->str:
55+
ifTestConfigPropNames.TEST_CFG__LOG_DIRinos.environ:
56+
resultPath=os.environ[TestConfigPropNames.TEST_CFG__LOG_DIR]
57+
else:
58+
rootDir=__class__.CalcRootDir()
59+
resultPath=os.path.join(rootDir,"logs")
60+
61+
asserttype(resultPath)==str# noqa: E721
62+
returnresultPath
63+
5364
# --------------------------------------------------------------------
5465
defCalcCurrentTestWorkerSignature()->str:
5566
currentPID=os.getpid()
@@ -86,11 +97,18 @@ class TestStartupData:
8697
TestStartupData__Helper.CalcCurrentTestWorkerSignature()
8798
)
8899

100+
sm_RootLogDir:str=TestStartupData__Helper.CalcRootLogDir()
101+
89102
# --------------------------------------------------------------------
90103
defGetRootDir()->str:
91104
asserttype(__class__.sm_RootDir)==str# noqa: E721
92105
return__class__.sm_RootDir
93106

107+
# --------------------------------------------------------------------
108+
defGetRootLogDir()->str:
109+
asserttype(__class__.sm_RootLogDir)==str# noqa: E721
110+
return__class__.sm_RootLogDir
111+
94112
# --------------------------------------------------------------------
95113
defGetCurrentTestWorkerSignature()->str:
96114
asserttype(__class__.sm_CurrentTestWorkerSignature)==str# noqa: E721
@@ -954,13 +972,9 @@ def pytest_configure(config: pytest.Config) -> None:
954972
log_name=TestStartupData.GetCurrentTestWorkerSignature()
955973
log_name+=".log"
956974

957-
ifTestConfigPropNames.TEST_CFG__LOG_DIRinos.environ:
958-
log_path_v=os.environ[TestConfigPropNames.TEST_CFG__LOG_DIR]
959-
log_path=pathlib.Path(log_path_v)
960-
else:
961-
log_path=config.rootpath.joinpath("logs")
975+
log_dir=TestStartupData.GetRootLogDir()
962976

963-
log_path.mkdir(exist_ok=True)
977+
pathlib.Path(log_dir).mkdir(exist_ok=True)
964978

965979
logging_plugin:_pytest.logging.LoggingPlugin=config.pluginmanager.get_plugin(
966980
"logging-plugin"
@@ -969,7 +983,7 @@ def pytest_configure(config: pytest.Config) -> None:
969983
assertlogging_pluginisnotNone
970984
assertisinstance(logging_plugin,_pytest.logging.LoggingPlugin)
971985

972-
logging_plugin.set_log_path(str(log_path/log_name))
986+
logging_plugin.set_log_path(os.path.join(log_dir,log_name))
973987

974988

975989
# /////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp