Skip to content
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

Concatenate strings that are separated by a single space #782

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def setup_ansible_config(tmpdir, name, host, user, port, key):
"ansible_user={}".format(user),
"ansible_port={}".format(port),
]
tmpdir.join("inventory").write("[testgroup]\n" + " ".join(items) + "\n")
tmpdir.join("inventory").write(f'[testgroup]\n{" ".join(items)}\n')
tmpdir.mkdir("host_vars").join(name).write(ANSIBLE_HOSTVARS)
tmpdir.mkdir("group_vars").join("testgroup").write(
("---\n" "myhostvar: should_be_overriden\n" "mygroupvar: qux\n")
"---\nmyhostvar: should_be_overriden\nmygroupvar: qux\n"
)
vault_password_file = tmpdir.join("vault-pass.txt")
vault_password_file.write("polichinelle\n")
Expand Down
10 changes: 6 additions & 4 deletions test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,18 @@ def test_encoding(host):
elif host.backend.get_connection_type() == "ansible" and host.backend.force_ansible:
# XXX: this encoding issue comes directly from ansible
# not sure how to handle this...
assert cmd.stderr == (
"ls: impossible d'accéder à '/é': " "Aucun fichier ou dossier de ce type"
assert (
cmd.stderr
== "ls: impossible d'accéder à '/é': Aucun fichier ou dossier de ce type"
)
else:
assert cmd.stderr_bytes == (
b"ls: impossible d'acc\xe9der \xe0 '/\xe9': "
b"Aucun fichier ou dossier de ce type\n"
)
assert cmd.stderr == (
"ls: impossible d'accéder à '/é': " "Aucun fichier ou dossier de ce type\n"
assert (
cmd.stderr
== "ls: impossible d'accéder à '/é': Aucun fichier ou dossier de ce type\n"
)


Expand Down
4 changes: 2 additions & 2 deletions test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def test_file(host):


def test_ansible_unavailable(host):
expected = "Ansible module is only available with " "ansible connection backend"
expected = "Ansible module is only available with ansible connection backend"
with pytest.raises(RuntimeError) as excinfo:
host.ansible("setup")
assert expected in str(excinfo.value)
Expand Down Expand Up @@ -374,7 +374,7 @@ def test_ansible_module(host):
except host.ansible.AnsibleException as exc:
assert exc.result["rc"] == 2
# notez que the debian bookworm container is set to LANG=fr_FR
assert exc.result["msg"] == ("[Errno 2] Aucun fichier ou dossier " "de ce type")
assert exc.result["msg"] == "[Errno 2] Aucun fichier ou dossier de ce type"

result = host.ansible("command", "echo foo", check=False)
assert result["stdout"] == "foo"
Expand Down
2 changes: 1 addition & 1 deletion testinfra/backend/lxc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, name: str, *args: Any, **kwargs: Any):
def run(self, command: str, *args: str, **kwargs: Any) -> base.CommandResult:
cmd = self.get_command(command, *args)
out = self.run_local(
"lxc exec %s --mode=non-interactive -- " "/bin/sh -c %s", self.name, cmd
"lxc exec %s --mode=non-interactive -- /bin/sh -c %s", self.name, cmd
)
out.command = self.encode(cmd)
return out
2 changes: 1 addition & 1 deletion testinfra/modules/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def need_ansible(func):
def wrapper(self, *args, **kwargs):
if not self._host.backend.HAS_RUN_ANSIBLE:
raise RuntimeError(
("Ansible module is only available with ansible " "connection backend")
("Ansible module is only available with ansible connection backend")
)
return func(self, *args, **kwargs)

Expand Down
4 changes: 1 addition & 3 deletions testinfra/modules/mountpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ def get_module_class(cls, host):
raise NotImplementedError

def __repr__(self):
return (
"<MountPoint(path={}, device={}, filesystem={}, " "options={})>"
).format(
return ("<MountPoint(path={}, device={}, filesystem={}, options={})>").format(
self.path,
self.device,
self.filesystem,
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Facter(InstanceModule):
"""

def __call__(self, *facts):
cmd = "facter --json --puppet " + " ".join(facts)
cmd = f'facter --json --puppet {" ".join(facts)}'
return json.loads(self.check_output(cmd))

def __repr__(self):
Expand Down
Loading