Return the current user name, or None if getuser() does not work in the current environment (see #1010).
()
| 230 | |
| 231 | |
| 232 | def get_user() -> str | None: |
| 233 | """Return the current user name, or None if getuser() does not work |
| 234 | in the current environment (see #1010).""" |
| 235 | try: |
| 236 | # In some exotic environments, getpass may not be importable. |
| 237 | import getpass |
| 238 | |
| 239 | return getpass.getuser() |
| 240 | except (ImportError, OSError, KeyError): |
| 241 | return None |
| 242 | |
| 243 | |
| 244 | def pytest_configure(config: Config) -> None: |
no outgoing calls