Repository: ansible/ansible-navigator (language: python)

Issue:
Replace collection stdout tests
Leverage the cmd in tty subprocess function to replace previous tmux tests
- additionally, check for bind_mounts #1416 
- refactor the generate log directory function to use the test path
- Switch to Pathlib paths in changes
- Switch tmux session id to just a UUID
- Update type hints as needed
- Remove fixtures from previous tests


Discussion / hints:

Fix patch:
diff --git a/.flake8 b/.flake8
index d23431811..94053eddb 100644
--- a/.flake8
+++ b/.flake8
@@ -77,7 +77,6 @@ per-file-ignores =
   # The following were present during the initial implementation.
   # They are expected to be fixed and unignored over time.
   src/ansible_navigator/ui_framework/validators.py: D400, D401, D403, DAR101, DAR201, DAR401
-  tests/conftest.py: D210, D400, D401, D403, DAR101, DAR201, DAR301, DAR401
   tests/integration/_action_run_test.py: D205, D400, D401, D403, DAR101, DAR201, DAR401
   tests/integration/_cli2runner.py: D400, D401, D403, DAR101, DAR401
   tests/integration/_common.py: D103, D400, D401, D403, DAR101, DAR201, DAR401


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index 5eced5a91..a4fa37bfc 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,5 @@
 # cspell:ignore sessionstart,unconfigure,workerinput
-"""fixtures for all tests"""
+"""Fixtures for all tests."""
 from __future__ import annotations
 
 import errno
@@ -12,6 +12,7 @@
 
 from copy import deepcopy
 from pathlib import Path
+from typing import Generator
 from typing import Protocol
 
 import pytest
@@ -34,8 +35,11 @@
 from .defaults import FIXTURES_DIR
 
 
-def _valid_container_engine():
-    """Returns an available container engine."""
+def _valid_container_engine() -> str:
+    """Return an available container engine.
+
+    :returns: The container engine or exits
+    """
     for engine in ("podman", "docker"):
         if shutil.which(engine):
             return engine
@@ -44,51 +48,74 @@ def _valid_container_engine():
 
 
 @pytest.fixture(scope="session", name="valid_container_engine")
-def fixture_valid_container_engine():
-    """Returns an available container engine."""
+def fixture_valid_container_engine() -> str:
+    """Return an available container engine.
+
+    :returns: The container engine or exits
+    """
     return _valid_container_engine()
 
 
-def default_ee_image_name():
-    """Returns the default ee image name."""
+def default_ee_image_name() -> str:
+    """Return the default ee image name.
+
+    :returns: The default ee image name
+    """
     return ImageEntry.DEFAULT_EE.get(app_name=APP_NAME)
 
 
 @pytest.fixture(scope="session", name="default_ee_image_name")
-def fixture_default_image_name():
-    """Returns the default ee image name."""
+def fixture_default_image_name() -> str:
+    """Return the default ee image name.
+
+    :returns: The default ee image name
+    """
     return default_ee_image_name()
 
 
-def small_image_name():
-    """Returns the small image name"""
+def small_image_name() -> str:
+    """Return the small image name.
+
+    :returns: The small image name
+    """
     return ImageEntry.SMALL_IMAGE.get(app_name=APP_NAME)
 
 
 @pytest.fixture(scope="session", name="small_image_name")
-def fixture_small_image_name():
-    """Returns the small image name"""
+def fixture_small_image_name() -> str:
+    """Return the small image name.
+
+    :returns: The small image name
+    """
     return small_image_name()
 
 
 @pytest.fixture(scope="function")
-def locked_directory(tmpdir):
-    """directory without read-write for throwing errors"""
+def locked_directory(tmpdir) -> Generator[str, None, None]:
+    """Directory without read-write for throwing errors.
+
+    :param tmpdir: Fixture for temporary directory
+    :yields: The temporary directory
+    """
     os.chmod(tmpdir, 0o000)
     yield tmpdir
     os.chmod(tmpdir, 0o777)
 
 
 @pytest.fixture(scope="session")
-def pullable_image(valid_container_engine):
-    """A container that can be pulled."""
+def pullable_image(valid_container_engine) -> Generator[str, None, None]:
+    """Return a container that can be pulled.
+
+    :param valid_container_engine: Fixture for a valid container engine
+    :yields: The image name
+    """
     image = ImageEntry.PULLABLE_IMAGE.get(app_name=APP_NAME)
     yield image
     subprocess.run([valid_container_engine, "image", "rm", image], check=True)
 
 
 @pytest.fixture
-def patch_curses(monkeypatch):
+def patch_curses(monkeypatch) -> None:
     """Patch curses so it doesn't traceback during tests.
 
     :param monkeypatch: Fixture for patching
@@ -99,10 +126,11 @@ def patch_curses(monkeypatch):
 
 
 @pytest.fixture
-def use_venv(monkeypatch: pytest.MonkeyPatch):
-    """Set the path such that it includes the virtual environment
+def use_venv(monkeypatch: pytest.MonkeyPatch) -> None:
+    """Set the path such that it includes the virtual environment.
 
     :param monkeypatch: Fixture for patching
+    :raises AssertionError: If the virtual environment is not set
     """
     venv_path = os.environ.get("VIRTUAL_ENV")
     if venv_path is None:
@@ -115,7 +143,7 @@ def use_venv(monkeypatch: pytest.MonkeyPatch):
 
 @pytest.fixture(name="settings_samples")
 def _settings_samples() -> tuple[str, str]:
-    """Provide the full settings samples
+    """Provide the full settings samples.
 
     :returns: The commented and uncommented samples
     """
@@ -163,10 +191,11 @@ def settings_env_var_to_full(
 
 
 @pytest.fixture
-def test_dir_fixture_dir(request):
+def test_dir_fixture_dir(request) -> Path:
     """Provide the fixture directory for a given test directory.
 
     :param request: The pytest request object
+    :returns: The fixture directory
     """
     test_dir = Path(FIXTURES_DIR) / request.path.parent.relative_to(Path(__file__).parent)
     return test_dir
@@ -203,13 +232,15 @@ def _cmd_in_tty(
     bytes_input: bytes | None = None,
     cwd: Path | None = None,
 ) -> tuple[str, str, int]:
-    """Capture the output of cmd using a tty
+    """Capture the output of cmd using a tty.
 
     Based on Andy Hayden's gist:
     https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e
 
     :param cmd: The command to run
     :param bytes_input: Some bytes to input
+    :param cwd: The working directory
+    :raises OSError: Error if the command fails
     :returns: stdout, stderr, and the exit code
     """
     # pylint: disable=too-many-locals
@@ -263,7 +294,7 @@ def _cmd_in_tty(
 
 @pytest.fixture
 def cmd_in_tty():
-    """Provide the cmd in tty function as a fixture
+    """Provide the cmd in tty function as a fixture.
 
     :yields: The cmd_in_tty function
     """
@@ -274,7 +305,7 @@ class TCmdInTty(Protocol):
     """Type hint for the cmd_in_tty fixture."""
 
     def __call__(self, cmd: str, bytes_input: bytes | None = None) -> tuple[str, str, int]:
-        """Prove the callable type hint for the cmd_in_tty fixture
+        """Provide the callable type hint for the cmd_in_tty fixture.
 
         :param cmd: The command to run
         :param bytes_input: Some bytes to input