Skip to content

enter: false #747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ ignore = E111,
W503

[tool:pytest]
addopts = --reruns=5
addopts = --reruns=0
filterwarnings =
ignore:distutils Version classes are deprecated. Use packaging.version instead.

[isort]
combine_as_imports= true
Expand Down
16 changes: 11 additions & 5 deletions tests/fixtures/_util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import os
import pathlib

FIXTURE_PATH = pathlib.Path(__file__).parent

def curjoin(_file): # return filepath relative to __file__ (this file)
return os.path.join(os.path.dirname(__file__), _file)

def load_fixture(_file): # return fixture data, relative to __file__
return open(FIXTURE_PATH / _file).read()

def loadfixture(_file): # return fixture data, relative to __file__
return open(curjoin(_file)).read()

def write_config(
config_path: pathlib.Path, filename: str, content: str
) -> pathlib.Path:
config = config_path / filename
config.write_text(content, encoding="utf-8")
return config
6 changes: 3 additions & 3 deletions tests/fixtures/config/expand2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from .._util import loadfixture
from .._util import load_fixture

unexpanded_yaml = loadfixture("config/expand2-unexpanded.yaml")
expanded_yaml = loadfixture("config/expand2-expanded.yaml").format(
unexpanded_yaml = load_fixture("config/expand2-unexpanded.yaml")
expanded_yaml = load_fixture("config/expand2-expanded.yaml").format(
HOME=os.path.expanduser("~")
)
6 changes: 3 additions & 3 deletions tests/fixtures/config/shell_command_before_session.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .._util import loadfixture
from .._util import load_fixture

before = loadfixture("config/shell_command_before_session.yaml")
expected = loadfixture("config/shell_command_before_session-expected.yaml")
before = load_fixture("config/shell_command_before_session.yaml")
expected = load_fixture("config/shell_command_before_session-expected.yaml")
4 changes: 2 additions & 2 deletions tests/fixtures/config_teamocil/layouts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

teamocil_yaml = loadfixture("config_teamocil/layouts.yaml")
teamocil_yaml = load_fixture("config_teamocil/layouts.yaml")

teamocil_dict = {
"two-windows": {
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config_teamocil/test1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

teamocil_yaml = loadfixture("config_teamocil/test1.yaml")
teamocil_yaml = load_fixture("config_teamocil/test1.yaml")
teamocil_conf = {
"windows": [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config_teamocil/test2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

teamocil_yaml = loadfixture("config_teamocil/test2.yaml")
teamocil_yaml = load_fixture("config_teamocil/test2.yaml")
teamocil_dict = {
"windows": [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config_teamocil/test3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

teamocil_yaml = loadfixture("config_teamocil/test3.yaml")
teamocil_yaml = load_fixture("config_teamocil/test3.yaml")

teamocil_dict = {
"windows": [
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config_teamocil/test4.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

teamocil_yaml = loadfixture("config_teamocil/test4.yaml")
teamocil_yaml = load_fixture("config_teamocil/test4.yaml")

teamocil_dict = {
"windows": [
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config_tmuxinator/test1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

tmuxinator_yaml = loadfixture("config_tmuxinator/test1.yaml")
tmuxinator_yaml = load_fixture("config_tmuxinator/test1.yaml")
tmuxinator_dict = {
"windows": [
{"editor": {"layout": "main-vertical", "panes": ["vim", "guard"]}},
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config_tmuxinator/test2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

tmuxinator_yaml = loadfixture("config_tmuxinator/test2.yaml")
tmuxinator_yaml = load_fixture("config_tmuxinator/test2.yaml")

tmuxinator_dict = {
"project_name": "sample",
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/config_tmuxinator/test3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .._util import loadfixture
from .._util import load_fixture

tmuxinator_yaml = loadfixture("config_tmuxinator/test3.yaml")
tmuxinator_yaml = load_fixture("config_tmuxinator/test3.yaml")

tmuxinator_dict = {
"name": "sample",
Expand Down
32 changes: 16 additions & 16 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from tmuxp.workspacebuilder import WorkspaceBuilder

from .fixtures._util import curjoin, loadfixture
from .fixtures._util import FIXTURE_PATH, load_fixture


def test_creates_config_dir_not_exists(tmp_path: pathlib.Path):
Expand Down Expand Up @@ -305,7 +305,7 @@ def test_load_workspace(server, monkeypatch):
# a tmux session by the developer himself, delete the TMUX variable
# temporarily.
monkeypatch.delenv("TMUX", raising=False)
session_file = curjoin("workspacebuilder/two_pane.yaml")
session_file = FIXTURE_PATH / "workspacebuilder" / "two_pane.yaml"

# open it detached
session = load_workspace(
Expand All @@ -321,7 +321,7 @@ def test_load_workspace_named_session(server, monkeypatch):
# a tmux session by the developer himself, delete the TMUX variable
# temporarily.
monkeypatch.delenv("TMUX", raising=False)
session_file = curjoin("workspacebuilder/two_pane.yaml")
session_file = FIXTURE_PATH / "workspacebuilder" / "two_pane.yaml"

# open it detached
session = load_workspace(
Expand All @@ -342,7 +342,7 @@ def test_load_workspace_name_match_regression_252(
tmp_path: pathlib.Path, server, monkeypatch
):
monkeypatch.delenv("TMUX", raising=False)
session_file = curjoin("workspacebuilder/two_pane.yaml")
session_file = FIXTURE_PATH / "workspacebuilder" / "two_pane.yaml"

# open it detached
session = load_workspace(
Expand Down Expand Up @@ -407,8 +407,8 @@ def test_load_symlinked_workspace(server, tmp_path, monkeypatch):
def test_regression_00132_session_name_with_dots(
tmp_path: pathlib.Path, server, session
):
yaml_config = curjoin("workspacebuilder/regression_00132_dots.yaml")
cli_args = [yaml_config]
yaml_config = FIXTURE_PATH / "workspacebuilder" / "regression_00132_dots.yaml"
cli_args = [str(yaml_config)]
inputs = []
runner = CliRunner()
result = runner.invoke(
Expand Down Expand Up @@ -861,7 +861,7 @@ def test_help(cli_args, monkeypatch):
],
)
def test_import_teamocil(cli_args, inputs, tmp_path, monkeypatch):
teamocil_config = loadfixture("config_teamocil/test4.yaml")
teamocil_config = load_fixture("config_teamocil/test4.yaml")

teamocil_path = tmp_path / ".teamocil"
teamocil_path.mkdir()
Expand Down Expand Up @@ -900,7 +900,7 @@ def test_import_teamocil(cli_args, inputs, tmp_path, monkeypatch):
],
)
def test_import_tmuxinator(cli_args, inputs, tmp_path, monkeypatch):
tmuxinator_config = loadfixture("config_tmuxinator/test3.yaml")
tmuxinator_config = load_fixture("config_tmuxinator/test3.yaml")

tmuxinator_path = tmp_path / ".tmuxinator"
tmuxinator_path.mkdir()
Expand Down Expand Up @@ -1110,7 +1110,7 @@ def test_ls_cli(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path):
def test_load_plugins(monkeypatch_plugin_test_packages):
from tmuxp_test_plugin_bwb.plugin import PluginBeforeWorkspaceBuilder

plugins_config = loadfixture("workspacebuilder/plugin_bwb.yaml")
plugins_config = load_fixture("workspacebuilder/plugin_bwb.yaml")

sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(plugins_config).get()
Expand Down Expand Up @@ -1181,7 +1181,7 @@ def test_plugin_system_before_script(
# a tmux session by the developer himself, delete the TMUX variable
# temporarily.
monkeypatch.delenv("TMUX", raising=False)
session_file = curjoin("workspacebuilder/plugin_bs.yaml")
session_file = FIXTURE_PATH / "workspacebuilder" / "plugin_bs.yaml"

# open it detached
session = load_workspace(
Expand All @@ -1193,7 +1193,7 @@ def test_plugin_system_before_script(


def test_reattach_plugins(monkeypatch_plugin_test_packages, server):
config_plugins = loadfixture("workspacebuilder/plugin_r.yaml")
config_plugins = load_fixture("workspacebuilder/plugin_r.yaml")

sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(config_plugins).get()
Expand Down Expand Up @@ -1224,7 +1224,7 @@ def test_load_attached(server, monkeypatch):

monkeypatch.setattr("libtmux.session.Session.attach_session", attach_session_mock)

yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()

Expand All @@ -1244,7 +1244,7 @@ def test_load_attached_detached(server, monkeypatch):

monkeypatch.setattr("libtmux.session.Session.attach_session", attach_session_mock)

yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()

Expand All @@ -1264,7 +1264,7 @@ def test_load_attached_within_tmux(server, monkeypatch):

monkeypatch.setattr("libtmux.session.Session.switch_client", switch_client_mock)

yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()

Expand All @@ -1284,7 +1284,7 @@ def test_load_attached_within_tmux_detached(server, monkeypatch):

monkeypatch.setattr("libtmux.session.Session.switch_client", switch_client_mock)

yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()

Expand All @@ -1296,7 +1296,7 @@ def test_load_attached_within_tmux_detached(server, monkeypatch):


def test_load_append_windows_to_current_session(server, monkeypatch):
yaml_config = loadfixture("workspacebuilder/two_pane.yaml")
yaml_config = load_fixture("workspacebuilder/two_pane.yaml")
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()

Expand Down
Loading