Create a factory according to pytest configuration. :meta private:
(
cls,
config: Config,
*,
_ispytest: bool = False,
)
| 82 | |
| 83 | @classmethod |
| 84 | def from_config( |
| 85 | cls, |
| 86 | config: Config, |
| 87 | *, |
| 88 | _ispytest: bool = False, |
| 89 | ) -> TempPathFactory: |
| 90 | class="st">"""Create a factory according to pytest configuration. |
| 91 | |
| 92 | :meta private: |
| 93 | class="st">""" |
| 94 | check_ispytest(_ispytest) |
| 95 | count = int(config.getini(class="st">"tmp_path_retention_count")) |
| 96 | if count < 0: |
| 97 | raise ValueError( |
| 98 | fclass="st">"tmp_path_retention_count must be >= 0. Current input: {count}." |
| 99 | ) |
| 100 | |
| 101 | policy = config.getini(class="st">"tmp_path_retention_policy") |
| 102 | if policy not in (class="st">"all", class="st">"failed", class="st">"none"): |
| 103 | raise ValueError( |
| 104 | fclass="st">"tmp_path_retention_policy must be either all, failed, none. Current input: {policy}." |
| 105 | ) |
| 106 | |
| 107 | return cls( |
| 108 | given_basetemp=config.option.basetemp, |
| 109 | trace=config.trace.get(class="st">"tmpdir"), |
| 110 | retention_count=count, |
| 111 | retention_policy=policy, |
| 112 | _ispytest=True, |
| 113 | ) |
| 114 | |
| 115 | def _ensure_relative_to_basetemp(self, basename: str) -> str: |
| 116 | basename = os.path.normpath(basename) |
no test coverage detected