Repository: tmux-python/libtmux (language: python)

Issue:
feat(new_session): add width/height parameters



Discussion / hints:
# [Codecov](https://codecov.io/gh/tmux-python/libtmux/pull/469?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python) Report
> Merging [#469](https://codecov.io/gh/tmux-python/libtmux/pull/469?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python) (57fa790) into [master](https://codecov.io/gh/tmux-python/libtmux/commit/2d10fec97b7c4ec3e946918accab969dcb7c6e0b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python) (2d10fec) will **increase** coverage by `0.06%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##           master     #469      +/-   ##
==========================================
+ Coverage   88.85%   88.91%   +0.06%     
==========================================
  Files          35       35              
  Lines        3471     3481      +10     
  Branches      481      483       +2     
==========================================
+ Hits         3084     3095      +11     
+ Misses        280      278       -2     
- Partials      107      108       +1     
```


| [Impacted Files](https://codecov.io/gh/tmux-python/libtmux/pull/469?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python) | Coverage Δ | |
|---|---|---|
| [src/libtmux/server.py](https://codecov.io/gh/tmux-python/libtmux/pull/469?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python#diff-c3JjL2xpYnRtdXgvc2VydmVyLnB5) | `65.75% <100.00%> (+0.77%)` | :arrow_up: |
| [tests/test\_server.py](https://codecov.io/gh/tmux-python/libtmux/pull/469?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python#diff-dGVzdHMvdGVzdF9zZXJ2ZXIucHk=) | `100.00% <100.00%> (ø)` | |
| [src/libtmux/session.py](https://codecov.io/gh/tmux-python/libtmux/pull/469?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python#diff-c3JjL2xpYnRtdXgvc2Vzc2lvbi5weQ==) | `76.55% <0.00%> (-0.48%)` | :arrow_down: |
| [src/libtmux/pane.py](https://codecov.io/gh/tmux-python/libtmux/pull/469?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python#diff-c3JjL2xpYnRtdXgvcGFuZS5weQ==) | `92.45% <0.00%> (+0.94%)` | :arrow_up: |

:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tmux-python)


Fix patch:
diff --git a/CHANGES b/CHANGES
index 5dde2fac7..3b9327f6d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -18,6 +18,8 @@ $ pip install --user --upgrade --pre libtmux
 
 - Server.new_session: Accept `x` and `y`, thanks
   @rockandska (#469)
+- New test fixture: `session_params`. The dict is used direclty in the `session`
+  pytest fixture (#470)
 
 ## libtmux 0.19.1 (2022-01-07)
 


Test patch:
diff --git a/docs/pytest-plugin/index.md b/docs/pytest-plugin/index.md
index bceb87f08..cc02ac118 100644
--- a/docs/pytest-plugin/index.md
+++ b/docs/pytest-plugin/index.md
@@ -69,6 +69,30 @@ options:
 
 You could also read the code and override {func}`server fixtures <libtmux.pytest_plugin.server>`'s in your own doctest. doctest.
 
+(custom_session_params)=
+
+### Custom session parameters
+
+You can override `session_params` to custom the `session` fixture. The
+dictionary will directly pass into :meth:`Server.new_sesion` keyword arguments.
+
+```python
+import pytest
+
+@pytest.fixture
+def session_params():
+    return {
+        'x': 800,
+        'y': 600
+    }
+
+
+def test_something(session):
+    assert session
+```
+
+The above will assure the libtmux session launches with `-x 800 -y 600`.
+
 (set_home)=
 
 ### Setting a temporary home directory
diff --git a/src/libtmux/pytest_plugin.py b/src/libtmux/pytest_plugin.py
index d900011a1..f24bfdbd0 100644
--- a/src/libtmux/pytest_plugin.py
+++ b/src/libtmux/pytest_plugin.py
@@ -144,7 +144,47 @@ def fin() -> None:
 
 
 @pytest.fixture(scope="function")
-def session(request: pytest.FixtureRequest, server: Server) -> "Session":
+def session_params() -> t.Dict[str, t.Any]:
+    """Returns a new, temporary :class:`libtmux.Session`
+
+    >>> import pytest
+    >>> from libtmux.session import Session
+
+    >>> @pytest.fixture
+    ... def session_params(session_params):
+    ...     return {
+    ...         'x': 800,
+    ...         'y': 600,
+    ...     }
+
+    >>> def test_example(session: "Session") -> None:
+    ...     assert isinstance(session.name, str)
+    ...     assert session.name.startswith('libtmux_')
+    ...     window = session.new_window(window_name='new one')
+    ...     assert window.name == 'new one'
+
+    .. ::
+        >>> locals().keys()
+        dict_keys(...)
+
+        >>> source = ''.join([e.source for e in request._pyfuncitem.dtest.examples][:4])
+        >>> pytester = request.getfixturevalue('pytester')
+
+        >>> pytester.makepyfile(**{'whatever.py': source})
+        PosixPath(...)
+
+        >>> result = pytester.runpytest('whatever.py', '--disable-warnings')
+        ===...
+
+        >>> result.assert_outcomes(passed=1)
+    """
+    return {}
+
+
+@pytest.fixture(scope="function")
+def session(
+    request: pytest.FixtureRequest, session_params: t.Dict[str, t.Any], server: Server
+) -> "Session":
     """Returns a new, temporary :class:`libtmux.Session`
 
     >>> from libtmux.session import Session
@@ -185,7 +225,7 @@ def session(request: pytest.FixtureRequest, server: Server) -> "Session":
     TEST_SESSION_NAME = get_test_session_name(server=server)
 
     try:
-        session = server.new_session(session_name=TEST_SESSION_NAME)
+        session = server.new_session(session_name=TEST_SESSION_NAME, **session_params)
     except exc.LibTmuxException as e:
         raise e