Skip to content

Typos corrected and small wording change #800

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 1 commit into from
Apr 1, 2025
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
6 changes: 3 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ Changelog
======

* package: fix is_installed and version behavior for uninstalled packages (#321 and #326)
* ansible: Use predictibles test ordering when using pytest-xdist to fix random test collections errors (#316)
* ansible: Use predictable test ordering when using pytest-xdist to fix random test collections errors (#316)

1.13.0
======
Expand Down Expand Up @@ -436,7 +436,7 @@ Changelog
1.9.0
=====

* Interface: allow to find 'ip' command ousite of PATH
* Interface: allow to find 'ip' command outside of PATH
* Fix --nagios option with python 3

1.8.0
Expand Down Expand Up @@ -514,7 +514,7 @@ Changelog
1.5.2
=====

* Honnor become_user when using the ansible backend
* Honor become_user when using the ansible backend

1.5.1
=====
Expand Down
8 changes: 3 additions & 5 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@ def teardown():
request.addfinalizer(teardown)

port = check_output("docker port %s 22", docker_id)
# IPv4 addresses seem to be reported consistently
# in the first line of the output.
# To workaround https://github.com/moby/moby/issues/42442
# use only the values of the first line of the command
# output
# IPv4 addresses seem to be reported consistently in the first line
# of the output. To workaround https://github.com/moby/moby/issues/42442
# use only the first line of the command output.
port = int(port.splitlines()[0].rsplit(":", 1)[-1])

return docker_id, docker_host, port
Expand Down
6 changes: 3 additions & 3 deletions test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def test_ansible_get_host(kwargs, inventory, expected):
"-o ControlPersist=60s host true"
),
),
# identity_file has highest priority
# identity_file has the highest priority
(
b"host ansible_user=user ansible_ssh_pass=password ansible_ssh_private_key_file=some_file",
(
Expand Down Expand Up @@ -475,8 +475,8 @@ def test_ansible_unknown_option():


def test_backend_importables():
# just check that all declared backend are importable and NAME is set
# correctly
# check that all declared backends are importable and the backend name
# is set correctly
for connection_type in testinfra.backend.BACKENDS:
obj = testinfra.backend.get_backend_class(connection_type)
assert obj.get_connection_type() == connection_type
Expand Down
6 changes: 3 additions & 3 deletions test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_rpmdb_corrupted(host):

@pytest.mark.testinfra_hosts("docker://rockylinux9")
def test_non_default_package_tool(host):
# Make non default pkg tool binary present
# Make non-default pkg tool binary present
host.run("install -m a+rx /bin/true /usr/bin/dpkg-query")
assert host.package("openssh").is_installed

Expand Down Expand Up @@ -150,7 +150,7 @@ def test_facter(host):
assert host.facter()["os"]["distro"]["codename"] == "bookworm"
assert host.facter("virtual") in (
{"virtual": "docker"},
{"virtual": "hyperv"}, # github action uses hyperv
{"virtual": "hyperv"}, # GitHub action uses hyperv
{"virtual": "physical"}, # I've this on my machine...
)

Expand Down Expand Up @@ -643,7 +643,7 @@ def test_addr(host):
assert not non_resolvable.is_reachable
assert not non_resolvable.port(80).is_reachable

# Some arbitrary internal IP, hopefully non reachable
# Some arbitrary internal IP, hopefully non-reachable
# IP addresses are always resolvable no matter what
non_reachable_ip = host.addr("10.42.13.73")
assert non_reachable_ip.is_resolvable
Expand Down
2 changes: 1 addition & 1 deletion testinfra/backend/paramiko.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


class IgnorePolicy(paramiko.MissingHostKeyPolicy):
"""Policy for ignoring missing host key."""
"""Policy for ignoring a missing host key."""

def missing_host_key(
self, client: paramiko.SSHClient, hostname: str, key: paramiko.pkey.PKey
Expand Down
4 changes: 2 additions & 2 deletions testinfra/backend/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def run_ssh(self, command: str) -> base.CommandResult:
class SafeSshBackend(SshBackend):
"""Run command using ssh command but try to get a more sane output

When using ssh (or a potentially bugged wrapper) additional output can be
added in stdout/stderr and exit status may not be propagate correctly
When using ssh (or a potentially bugged wrapper), additional output can be
added in stdout/stderr and exit status may not be propagated correctly

To avoid that kind of bugs, we wrap the command to have an output like
this:
Expand Down
4 changes: 2 additions & 2 deletions testinfra/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def exists(self, command: str) -> bool:
def find_command(
self, command: str, extrapaths: Iterable[str] = ("/sbin", "/usr/sbin")
) -> str:
"""Return path of given command
"""Return the path of the given command

raise ValueError if command cannot be found
"""
Expand Down Expand Up @@ -147,7 +147,7 @@ def get_host(cls, hostspec: str, **kwargs: Any) -> "Host":
`hostspec` should be like
`<backend_type>://<name>?param1=value1&param2=value2`

Params can also be passed in `**kwargs` (eg. get_host("local://",
Params can also be passed in `**kwargs` (e.g. get_host("local://",
sudo=True) is equivalent to get_host("local://?sudo=true"))

Examples::
Expand Down
6 changes: 3 additions & 3 deletions testinfra/modules/addr.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ class Addr(Module):
>>> google.port(666).is_reachable
False

Can also be use within a network namespace_.
It can also be used within a network namespace_.

>>> localhost = host.addr("localhost", "ns1")
>>> localhost.is_resolvable
True

Network namespaces can only be used if ip_ command is available
because in this case, the module use ip-netns_ as command prefix.
In the other case, it will raise NotImplementedError.
because in this case, the module uses ip-netns_ as command prefix.
In the other case, it will raise a NotImplementedError.

.. _namespace: https://man7.org/linux/man-pages/man7/namespaces.7.html
.. _ip: https://man7.org/linux/man-pages/man8/ip.8.html
Expand Down
4 changes: 2 additions & 2 deletions testinfra/modules/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


class AnsibleException(Exception):
"""Exception raised when an error occur in an ansible call
"""Exception raised when an error occurs in an ansible call.

result from ansible can be accessed through the ``result`` attribute
Result from ansible can be accessed through the ``result`` attribute.

>>> try:
... host.ansible("command", "echo foo")
Expand Down
6 changes: 3 additions & 3 deletions testinfra/modules/blockdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@


class BlockDevice(Module):
"""Information for block device.
"""Information for a block device.

Should be used with sudo or under root.

If device is not a block device, RuntimeError is raised.
If the device is not a block device, RuntimeError is raised.
"""

@property
Expand Down Expand Up @@ -90,7 +90,7 @@ def start_sector(self):

@property
def is_writable(self):
"""Return True if device is writable (have no RO status)
"""Return True if the device is writable (have no RO status)

>>> host.block_device("/dev/sda").is_writable
True
Expand Down
4 changes: 2 additions & 2 deletions testinfra/modules/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ def version(cls, format=None):
def get_containers(cls, **filters):
"""Return a list of containers

By default return list of all containers, including non-running
By default, return a list of all containers, including non-running
containers.

Filtering can be done using filters keys defined on
https://docs.docker.com/engine/reference/commandline/ps/#filtering

Multiple filters for a given key is handled by giving a list of string
Multiple filters for a given key are handled by giving a list of strings
as value.

>>> host.docker.get_containers()
Expand Down
6 changes: 3 additions & 3 deletions testinfra/modules/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def mode(self):
>>> oct(host.file("/etc/shadow").mode) == '0o640'
True

You can also utilize the file mode constants from
You can also use the file mode constants from
the stat_ library for testing file mode.

>>> import stat
Expand All @@ -128,7 +128,7 @@ def mode(self):
raise NotImplementedError

def contains(self, pattern):
"""Checks content of file for pattern
"""Checks file content with a pattern

This uses grep and thus follows the grep regex syntax.
"""
Expand Down Expand Up @@ -181,7 +181,7 @@ def mtime(self):

@property
def size(self):
"""Return size of file in bytes"""
"""Return file size in bytes"""
raise NotImplementedError

def listdir(self):
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, name):

@property
def exists(self):
"""Test if group exists
"""Test if the group exists

>>> host.group("wheel").exists
True
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def default(cls, family=None):

@classmethod
def names(cls):
# -o is to tell the ip command to return 1 line per interface
# -o is to tell the ip command to return one line per interface
out = cls.check_output(f"{cls(None)._ip} -o link show")
interfaces = []
for line in out.splitlines():
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/iptables.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def rules(self, table="filter", chain=None, version=4):

Based on output of `iptables -t TABLE -S CHAIN` command

optionally takes takes the following arguments:
optionally takes the following arguments:
- table: defaults to `filter`
- chain: defaults to all chains
- version: default 4 (iptables), optionally 6 (ip6tables)
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def is_installed(self):

@property
def release(self):
"""Return the release specific info from the package version
"""Return the release-specific info from the package version

>>> host.package("nginx").release
'1.el6'
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_packages(cls, pip_path="pip"):

@classmethod
def get_outdated_packages(cls, pip_path="pip"):
"""Get all outdated packages with current and latest version
"""Get all outdated packages with the current and latest version

>>> host.pip.get_outdated_packages(
... pip_path='~/venv/website/bin/pip')
Expand Down
6 changes: 3 additions & 3 deletions testinfra/modules/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def name(self):
def get_containers(cls, **filters):
"""Return a list of containers

By default return list of all containers, including non-running
By default, return a list of all containers, including non-running
containers.

Filtering can be done using filters keys defined in
podman-ps(1).

Multiple filters for a given key is handled by giving a list of string
as value.
Multiple filters for a given key are handled by giving a list of
strings as value.

>>> host.podman.get_containers()
[<podman nginx>, <podman redis>, <podman app>]
Expand Down
3 changes: 2 additions & 1 deletion testinfra/modules/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class PosixProcess(Process):

def _get_processes(self, **filters):
cmd = "ps -Aww -o %s"
# lstart and args attributes contains spaces. Put them at the end of the list
# "lstart" and "args" attributes contains spaces. Put them at the
# end of the list.
attributes = sorted(
({"pid", "comm", "pcpu", "pmem"} | set(filters)) - {"lstart", "args"}
) + ["lstart", "args"]
Expand Down
8 changes: 4 additions & 4 deletions testinfra/modules/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, name):

@property
def exists(self):
"""Test if service is exists"""
"""Test if the service exists"""
raise NotImplementedError

@property
Expand All @@ -53,7 +53,7 @@ def is_valid(self):
"""Test if service is valid

This method is only available in the systemd implementation,
it will raise ``NotImplementedError`` in others implementation
it will raise ``NotImplementedError`` in other implementations.
"""
raise NotImplementedError

Expand All @@ -62,7 +62,7 @@ def is_masked(self):
"""Test if service is masked

This method is only available in the systemd implementation,
it will raise ``NotImplementedError`` in others implementations
it will raise ``NotImplementedError`` in other implementations.
"""
raise NotImplementedError

Expand All @@ -78,7 +78,7 @@ def systemd_properties(self):
'/lib/systemd/system/ntp.service'

This method is only available in the systemd implementation,
it will raise ``NotImplementedError`` in others implementations
it will raise ``NotImplementedError`` in other implementations.

Note: based on `systemctl show`_

Expand Down
6 changes: 3 additions & 3 deletions testinfra/modules/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def is_listening(self):
>>> host.socket("tcp://80").is_listening
False

.. note:: If you don't specify a host for udp and tcp sockets,
.. Note:: If you don't specify a host for udp and tcp sockets,
then the socket is listening if and only if the
socket listen on **both** all ipv4 and ipv6 addresses
(ie 0.0.0.0 and ::)
socket listens on **both** all ipv4 and ipv6 addresses
(i.e. 0.0.0.0 and ::)
"""
sockets = list(self._iter_sockets(True))
if self.protocol == "unix":
Expand Down
2 changes: 1 addition & 1 deletion testinfra/modules/sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class Sudo(InstanceModule):
"""Sudo module allow to run certain portion of code under another user.
"""Sudo module allows to run certain portion of code under another user.

It is used as a context manager and can be nested.

Expand Down
4 changes: 2 additions & 2 deletions testinfra/modules/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def _parse_status(line):
splitted = line.split()
name = splitted[0]
status = splitted[1]
# some old supervisorctl versions exit status is 0 even if it cannot
# connect to supervisord socket and output the error to stdout. So we
# Some old supervisorctl versions exit status is 0 even if it cannot
# connect to supervisord socket and output the error to stdout. So we
# check that parsed status is a known status.
if status not in STATUS:
supervisor_not_running()
Expand Down
Loading