diff --git a/cloudinit/config/cc_chef.py b/cloudinit/config/cc_chef.py index 4b350724a22..60f1c176f0b 100644 --- a/cloudinit/config/cc_chef.py +++ b/cloudinit/config/cc_chef.py @@ -337,7 +337,7 @@ def install_chef(cloud: Cloud, chef_cfg): ) install_chef_from_gems(ruby_version, chef_version, cloud.distro) # Retain backwards compat, by preferring True instead of False - # when not provided/overriden... + # when not provided/overridden... run = util.get_cfg_option_bool(chef_cfg, "exec", default=True) elif install_type == "packages": # This will install and run the chef-client from packages diff --git a/cloudinit/config/cc_phone_home.py b/cloudinit/config/cc_phone_home.py index 9de45678298..26695135089 100644 --- a/cloudinit/config/cc_phone_home.py +++ b/cloudinit/config/cc_phone_home.py @@ -123,7 +123,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: else: real_submit_keys[k] = str(v) - # Incase the url is parameterized + # In case the url is parameterized url_params = { "INSTANCE_ID": all_keys["instance_id"], } diff --git a/cloudinit/config/cc_ssh.py b/cloudinit/config/cc_ssh.py index 04a6e9c057d..95a76d448e6 100644 --- a/cloudinit/config/cc_ssh.py +++ b/cloudinit/config/cc_ssh.py @@ -65,7 +65,7 @@ def set_redhat_keyfile_perms(keyfile: str) -> None: - 'ssh_keys' group is present and owns the private keys. - private keys have permission 0o640. For fedora 38, centos 10 stream and above: - - ssh version is atleast version 9. + - ssh version is at least version 9. - 'ssh_keys' group is absent. 'root' group owns the keys. - private keys have permission 0o600, same as upstream. Public keys in all cases have permission 0o644. diff --git a/cloudinit/config/cc_ssh_import_id.py b/cloudinit/config/cc_ssh_import_id.py index 7d98832257e..dc6adcf0482 100644 --- a/cloudinit/config/cc_ssh_import_id.py +++ b/cloudinit/config/cc_ssh_import_id.py @@ -105,7 +105,7 @@ def import_ssh_ids(ids, user): except KeyError as exc: raise exc - # TODO: We have a use case that involes setting a proxy value earlier + # TODO: We have a use case that involves setting a proxy value earlier # in boot and the user wants this env used when using ssh-import-id. # E.g.,: # bootcmd: diff --git a/cloudinit/config/cc_yum_add_repo.py b/cloudinit/config/cc_yum_add_repo.py index f20f7ea0018..9bfebbfd129 100644 --- a/cloudinit/config/cc_yum_add_repo.py +++ b/cloudinit/config/cc_yum_add_repo.py @@ -135,7 +135,7 @@ def handle(name: str, cfg: Config, cloud: Cloud, args: list) -> None: if missing_required == len(req_fields): LOG.warning( - "Repository %s should contain atleast one of the" + "Repository %s should contain at least one of the" " following configuration entries: %s, skipping!", repo_id, ", ".join(req_fields), diff --git a/cloudinit/config/schema.py b/cloudinit/config/schema.py index 6be53a3ba4c..b21c77f89fa 100644 --- a/cloudinit/config/schema.py +++ b/cloudinit/config/schema.py @@ -258,7 +258,7 @@ def format_message(key: str): if annotate: return f" {msg}" - # italicised RST - no whitespace between astrisk and text + # italicised RST - no whitespace between asterisk and text return f"\n\n*{msg.strip()}*" # define print order diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py index 2c9daff2e75..c7b71e28199 100644 --- a/cloudinit/distros/__init__.py +++ b/cloudinit/distros/__init__.py @@ -582,7 +582,7 @@ def update_hostname(self, hostname, fqdn, prev_hostname_fn): ) return - # Remove duplicates (incase the previous config filename) + # Remove duplicates (in case the previous config filename) # is the same as the system config filename, don't bother # doing it twice update_files = set([f for f in update_files if f]) diff --git a/cloudinit/mergers/__init__.py b/cloudinit/mergers/__init__.py index 8161c161774..98261581bdd 100644 --- a/cloudinit/mergers/__init__.py +++ b/cloudinit/mergers/__init__.py @@ -26,7 +26,7 @@ def _handle_unknown(self, _meth_wanted, value, _merge_with): # object and a object to merge_with. # # If not found the merge will be given to a '_handle_unknown' - # function which can decide what to do wit the 2 values. + # function which can decide what to do with the 2 values. def merge(self, source, merge_with): type_name = type_utils.obj_name(source) type_name = type_name.lower() diff --git a/cloudinit/sources/helpers/netlink.py b/cloudinit/sources/helpers/netlink.py index 544ca70ed0c..62e281a48d0 100644 --- a/cloudinit/sources/helpers/netlink.py +++ b/cloudinit/sources/helpers/netlink.py @@ -113,7 +113,7 @@ def read_netlink_socket(netlink_socket, timeout=None): """ assert netlink_socket is not None, "netlink socket is none" read_set, _, _ = select.select([netlink_socket], [], [], timeout) - # Incase of timeout,read_set doesn't contain netlink socket. + # In case of timeout,read_set doesn't contain netlink socket. # just return from this function if netlink_socket not in read_set: return None diff --git a/cloudinit/stages.py b/cloudinit/stages.py index 84bc0ce07a0..50fbd8e463c 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -956,7 +956,7 @@ def _consume_userdata(self, frequency=PER_INSTANCE): Consume the userdata and run the part handlers """ - # Ensure datasource fetched before activation (just incase) + # Ensure datasource fetched before activation (just in case) user_data_msg = self.datasource.get_userdata(True) # This keeps track of all the active handlers diff --git a/cloudinit/user_data.py b/cloudinit/user_data.py index e99ad9a183a..01e561b2c84 100644 --- a/cloudinit/user_data.py +++ b/cloudinit/user_data.py @@ -361,7 +361,7 @@ def is_skippable(part): return False -# Coverts a raw string into a mime message +# Converts a raw string into a mime message def convert_string(raw_data, content_type=NOT_MULTIPART_TYPE): """convert a string (more likely bytes) or a message into a mime message.""" diff --git a/cloudinit/util.py b/cloudinit/util.py index c1996184b05..f6efb851a29 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -995,7 +995,7 @@ def load_yaml(blob, default=None, allowed=(dict,)): LOG.debug("loaded blob returned None, returning default.") converted = default elif not isinstance(converted, allowed): - # Yes this will just be caught, but thats ok for now... + # Yes this will just be caught, but that's ok for now... raise TypeError( "Yaml load allows %s root types, but got %s instead" % (allowed, type_utils.obj_name(converted)) @@ -1294,7 +1294,7 @@ def get_fqdn_from_hosts(hostname, filename="/etc/hosts"): @performance.timed("Resolving URL") def is_resolvable(url) -> bool: """determine if a url's network address is resolvable, return a boolean - This also attempts to be resilent against dns redirection. + This also attempts to be resilient against dns redirection. Note, that normal nsswitch resolution is used here. So in order to avoid any utilization of 'search' entries in /etc/resolv.conf @@ -1867,7 +1867,7 @@ def load_json(text, root_types=(dict,)): def get_non_exist_parent_dir(path): """Get the last directory in a path that does not exist. - Example: when path=/usr/a/b and /usr/a does not exis but /usr does, + Example: when path=/usr/a/b and /usr/a does not exist but /usr does, return /usr/a """ p_path = os.path.dirname(path) diff --git a/doc/rtd/explanation/exported_errors.rst b/doc/rtd/explanation/exported_errors.rst index 5febf99ef1a..d1ebc8c3235 100644 --- a/doc/rtd/explanation/exported_errors.rst +++ b/doc/rtd/explanation/exported_errors.rst @@ -33,7 +33,7 @@ cloud-init state information is made visible under a top level aggregate key "Failed at merging in cloud config part from p-01: empty cloud config", "No template found in /etc/cloud/templates for template source.deb822", "No template found in /etc/cloud/templates for template sources.list", - "No template found, not rendering /etc/apt/soures.list.d/ubuntu.source" + "No template found, not rendering /etc/apt/sources.list.d/ubuntu.source" ] }, "status": "done" @@ -74,7 +74,7 @@ occurred. "WARNING": [ "No template found in /etc/cloud/templates for template source.deb822", "No template found in /etc/cloud/templates for template sources.list", - "No template found, not rendering /etc/apt/soures.list.d/ubuntu.source" + "No template found, not rendering /etc/apt/sources.list.d/ubuntu.source" ] }, "datasource": "", @@ -94,7 +94,7 @@ occurred. "Failed at merging in cloud config part from p-01: empty cloud config", "No template found in /etc/cloud/templates for template source.deb822", "No template found in /etc/cloud/templates for template sources.list", - "No template found, not rendering /etc/apt/soures.list.d/ubuntu.source" + "No template found, not rendering /etc/apt/sources.list.d/ubuntu.source" ] }, "status": "done" diff --git a/templates/chrony.conf.freebsd.tmpl b/templates/chrony.conf.freebsd.tmpl index a9dd394e823..434ba234c13 100644 --- a/templates/chrony.conf.freebsd.tmpl +++ b/templates/chrony.conf.freebsd.tmpl @@ -126,7 +126,7 @@ ntsdumpdir /var/db/chrony # gain/loss measurements. # # 2. On Linux, if you use the RTC support and start chronyd with -# '-r -s' on bootup, measurements from the last boot will still be +# '-r -s' on boot up, measurements from the last boot will still be # useful (the real time clock is used to 'flywheel' chronyd between # boots). # diff --git a/tests/integration_tests/datasources/test_caching.py b/tests/integration_tests/datasources/test_caching.py index 16e2f003427..e597f660c29 100644 --- a/tests/integration_tests/datasources/test_caching.py +++ b/tests/integration_tests/datasources/test_caching.py @@ -50,7 +50,7 @@ def test_no_cache_network_only(client: IntegrationInstance): - Metadata is fetched in network timeframe only - Because `check_instance_id` is not defined, no cached datasource is found in the init-local phase, but the cache is used in the - remaining phases due to existance of /run/cloud-init/.instance-id + remaining phases due to existence of /run/cloud-init/.instance-id - Because `check_if_fallback_is_allowed` is not defined, cloud-init does NOT fall back to the pickled datasource, and will instead delete the cache during the init-local phase diff --git a/tests/integration_tests/modules/test_apt_functionality.py b/tests/integration_tests/modules/test_apt_functionality.py index c7878cdd6d9..2cf40210e17 100644 --- a/tests/integration_tests/modules/test_apt_functionality.py +++ b/tests/integration_tests/modules/test_apt_functionality.py @@ -624,7 +624,7 @@ def test_install_missing_deps(session_cloud: IntegrationCloud): # specify a ppa in our user data, and `apt update` can fail if no ppa # has been uploaded for the release being tested. This isn't uncommon # for the devel release and newer releases in general. - # Ignoring apt update errors seems preferrable to playing whack-a-mole + # Ignoring apt update errors seems preferable to playing whack-a-mole # with ppas that may or may not be available. verify_clean_boot( minimal_client, diff --git a/tests/integration_tests/modules/test_cli.py b/tests/integration_tests/modules/test_cli.py index 65448dda507..f03f0964374 100644 --- a/tests/integration_tests/modules/test_cli.py +++ b/tests/integration_tests/modules/test_cli.py @@ -121,7 +121,7 @@ def test_invalid_userdata_schema(client: IntegrationInstance): @pytest.mark.user_data(FAILING_USER_DATA) def test_failing_userdata_modules_exit_codes(client: IntegrationInstance): - """Test failing in modules representd in exit status. + """Test failing in modules represented in exit status. To ensure we don't miss any errors or warnings if a service happens to be restarted, any further module invocations will exit with error diff --git a/tests/integration_tests/modules/test_disk_setup.py b/tests/integration_tests/modules/test_disk_setup.py index ce7b4cc816d..7bcca8c61fb 100644 --- a/tests/integration_tests/modules/test_disk_setup.py +++ b/tests/integration_tests/modules/test_disk_setup.py @@ -267,6 +267,6 @@ def test_required_mounts(create_disk, client: IntegrationInstance): deps = client.execute( f"systemctl list-dependencies --all {service}".split() ) - assert "var.mount" in deps, "Exepected 'var.mount' to be a dependency" + assert "var.mount" in deps, "Expected 'var.mount' to be a dependency" verify_clean_boot(client) diff --git a/tests/integration_tests/reaper.py b/tests/integration_tests/reaper.py index 545ceefbca5..878d712a211 100644 --- a/tests/integration_tests/reaper.py +++ b/tests/integration_tests/reaper.py @@ -41,7 +41,7 @@ def __init__(self, timeout: float = 30.0): self.exit_reaper: Final[threading.Event] = threading.Event() # List of instances which temporarily escaped death - # The primary porpose of the reaper is to coax these instance towards + # The primary purpose of the reaper is to coax these instance towards # eventual demise and report their insubordination on shutdown. self.undead_ledger: Final[List[IntegrationInstance]] = [] diff --git a/tests/unittests/config/test_apt_configure_sources_list_v3.py b/tests/unittests/config/test_apt_configure_sources_list_v3.py index cdb26c3bace..69c66e3154c 100644 --- a/tests/unittests/config/test_apt_configure_sources_list_v3.py +++ b/tests/unittests/config/test_apt_configure_sources_list_v3.py @@ -255,7 +255,7 @@ def test_apt_v3_empty_cfg_source_list_by_distro( def test_apt_v3_source_list_ubuntu_snappy(self, mocker): """test_apt_v3_source_list_ubuntu_snappy - without custom sources or - parms""" + params""" cfg = {"apt": {}} mycloud = get_cloud() diff --git a/tests/unittests/config/test_apt_key.py b/tests/unittests/config/test_apt_key.py index 6325bca5147..cd3561f7bc7 100644 --- a/tests/unittests/config/test_apt_key.py +++ b/tests/unittests/config/test_apt_key.py @@ -141,6 +141,6 @@ def test_apt_key_list_fail_no_keys_file(self, m_listdir, m_gpg, *args): @mock.patch.object(cc_apt_configure.os, "listdir", return_value=()) @mock.patch.object(cc_apt_configure.os.path, "isfile", return_value=False) def test_apt_key_list_fail_bad_key_file(self, m_isfile, m_listdir, m_gpg): - """Ensure bad gpg key doesn't throw exeption.""" + """Ensure bad gpg key doesn't throw exception.""" m_gpg.list_keys = mock.Mock(side_effect=subp.ProcessExecutionError) assert not cc_apt_configure.apt_key("list", m_gpg) diff --git a/tests/unittests/config/test_cc_apt_configure.py b/tests/unittests/config/test_cc_apt_configure.py index 3651355e98f..7217c9ec07b 100644 --- a/tests/unittests/config/test_cc_apt_configure.py +++ b/tests/unittests/config/test_cc_apt_configure.py @@ -194,7 +194,7 @@ def test_schema_validation(self, config, error_msg): else: with pytest.raises(SchemaValidationError, match=error_msg): validate_cloudconfig_schema(config, schema, strict=True) - # Note apt['primary'] and apt['security'] have same defition + # Note apt['primary'] and apt['security'] have same definition # Avoid test setup duplicates by running same test using 'security' if isinstance(config.get("apt"), dict) and config["apt"].get( "primary" diff --git a/tests/unittests/config/test_cc_landscape.py b/tests/unittests/config/test_cc_landscape.py index 47a89b98409..559702a33a8 100644 --- a/tests/unittests/config/test_cc_landscape.py +++ b/tests/unittests/config/test_cc_landscape.py @@ -29,7 +29,7 @@ def test_skip_empty_landscape_cloudconfig(self, m_subp): assert mycloud.distro.install_packages.called is False def test_handler_error_on_invalid_landscape_type(self, m_subp): - """Raise an error when landscape configuraiton option is invalid.""" + """Raise an error when landscape configuration option is invalid.""" mycloud = get_cloud("ubuntu") cfg = {"landscape": "wrongtype"} with pytest.raises(RuntimeError) as exc: diff --git a/tests/unittests/config/test_cc_ntp.py b/tests/unittests/config/test_cc_ntp.py index c28da73a213..35f7d140c9c 100644 --- a/tests/unittests/config/test_cc_ntp.py +++ b/tests/unittests/config/test_cc_ntp.py @@ -543,7 +543,7 @@ def test_snappy_system_picks_timesyncd(self, m_which): @mock.patch("cloudinit.config.cc_ntp.subp.which") def test_ntp_distro_searches_all_preferred_clients(self, m_which): - """Test select_ntp_client search all distro perferred clients""" + """Test select_ntp_client search all distro preferred clients""" # nothing is installed m_which.return_value = None for distro in cc_ntp.distros: diff --git a/tests/unittests/config/test_cc_zypper_add_repo.py b/tests/unittests/config/test_cc_zypper_add_repo.py index aab273f63dc..b30c382a904 100644 --- a/tests/unittests/config/test_cc_zypper_add_repo.py +++ b/tests/unittests/config/test_cc_zypper_add_repo.py @@ -118,7 +118,7 @@ def test_config_write_skip_configdir(self, tmp_path): for item in contents.split("\n"): if item not in expected: assert item is None - # Not finding teh right path for mocking :( + # Not finding the right path for mocking :( # assert mock_logging.warning.called def test_empty_config_section_no_new_data(self, tmp_path): diff --git a/tests/unittests/conftest.py b/tests/unittests/conftest.py index af0ed8913ef..a5ebef25dcd 100644 --- a/tests/unittests/conftest.py +++ b/tests/unittests/conftest.py @@ -198,7 +198,7 @@ def disable_root_logger_setup(): @pytest.fixture def clear_deprecation_log(): """Clear any deprecation warnings before and after running tests.""" - # Since deprecations are de-duped, the existance (or non-existance) of + # Since deprecations are de-duped, the existence (or non-existence) of # a deprecation warning in a previous test can cause the next test to # fail. setattr(lifecycle.deprecate, "log", set()) diff --git a/tests/unittests/distros/test_create_users.py b/tests/unittests/distros/test_create_users.py index 69b844b6ea0..095924b106b 100644 --- a/tests/unittests/distros/test_create_users.py +++ b/tests/unittests/distros/test_create_users.py @@ -516,7 +516,7 @@ def test_snappy_only_new_group_added( def test_create_groups_with_whitespace_string( self, m_is_group, m_subp, dist, mocker ): - # groups supported as a comma delimeted string even with white space + # groups supported as a comma delimited string even with white space mocker.patch( "cloudinit.distros.util.system_is_snappy", return_value=False ) @@ -534,7 +534,7 @@ def test_create_groups_with_whitespace_string( def test_snappy_create_groups_with_whitespace_string( self, m_is_group, m_subp, dist, mocker ): - # groups supported as a comma delimeted string even with white space + # groups supported as a comma delimited string even with white space mocker.patch( "cloudinit.distros.util.system_is_snappy", return_value=True ) diff --git a/tests/unittests/net/test_dhcp.py b/tests/unittests/net/test_dhcp.py index c467c324895..76fddeb6107 100644 --- a/tests/unittests/net/test_dhcp.py +++ b/tests/unittests/net/test_dhcp.py @@ -1154,7 +1154,7 @@ def test_get_newest_lease_file_from_distro_notfound(self, *_): """ Test the case when no leases were found """ - # Any Distro would suffice for the absense test, choose Centos then. + # Any Distro would suffice for the absence test, choose Centos then. assert None is IscDhclient.get_newest_lease_file_from_distro( centos.Distro ) diff --git a/tests/unittests/net/test_init.py b/tests/unittests/net/test_init.py index 7bbaae1e392..6aed3ecfa18 100644 --- a/tests/unittests/net/test_init.py +++ b/tests/unittests/net/test_init.py @@ -43,7 +43,7 @@ def test_sys_dev_path_without_path(self): class TestReadSysNet: @pytest.fixture(autouse=True) def setup(self, tmpdir_factory): - # We mock invididual numbered tmpdirs here because these tests write + # We mock individual numbered tmpdirs here because these tests write # to the sysfs directory and stale test artifacts break later tests. mock_sysfs = f"{tmpdir_factory.mktemp('sysfs', numbered=True)}/" with mock.patch( @@ -638,7 +638,7 @@ def test_get_devicelist_empty_without_sys_net(self): assert [] == net.get_devicelist() def test_get_devicelist_empty_with_no_devices_in_sys_net(self): - """get_devicelist returns empty directoty listing for SYS_CLASS_NET.""" + """get_devicelist returns empty directory listing for SYS_CLASS_NET.""" assert [] == net.get_devicelist() def test_get_devicelist_lists_any_subdirectories_in_sys_net(self): diff --git a/tests/unittests/sources/test_altcloud.py b/tests/unittests/sources/test_altcloud.py index 74a8d336b3b..0a42602c6ab 100644 --- a/tests/unittests/sources/test_altcloud.py +++ b/tests/unittests/sources/test_altcloud.py @@ -49,7 +49,7 @@ def _remove_user_data_files(mount_dir, dc_file=True, non_dc_file=True): deltacloud_user_data_file = mount_dir + "/deltacloud-user-data.txt" user_data_file = mount_dir + "/user-data.txt" - # Ignore any failures removeing files that are already gone. + # Ignore any failures removing files that are already gone. if dc_file: try: os.remove(deltacloud_user_data_file) diff --git a/tests/unittests/sources/test_azure.py b/tests/unittests/sources/test_azure.py index d7f0adb4ab4..d2924b001f6 100644 --- a/tests/unittests/sources/test_azure.py +++ b/tests/unittests/sources/test_azure.py @@ -1725,7 +1725,7 @@ def test_password_given(self, get_ds): # default user should be updated username and should not be locked. assert defuser["name"] == "myuser" assert not defuser["lock_passwd"] - # passwd is crypt formated string $id$salt$encrypted + # passwd is crypt formatted string $id$salt$encrypted # encrypting plaintext with salt value of everything up to final '$' # should equal that after the '$' assert passlib.hash.sha512_crypt.verify( diff --git a/tests/unittests/sources/test_configdrive.py b/tests/unittests/sources/test_configdrive.py index b072f3f23b8..43ea8be3d4d 100644 --- a/tests/unittests/sources/test_configdrive.py +++ b/tests/unittests/sources/test_configdrive.py @@ -964,7 +964,7 @@ def test_bond_conversion(self, tmp_path): ) words = eni_rendering.split() - # 'eth0' and 'eth1' are the ids. because their mac adresses + # 'eth0' and 'eth1' are the ids. because their mac addresses # map to other names, we should not see them in the ENI assert "eth0" not in words assert "eth1" not in words diff --git a/tests/unittests/sources/test_ec2.py b/tests/unittests/sources/test_ec2.py index 62bc9e95ba1..ba0aba735c3 100644 --- a/tests/unittests/sources/test_ec2.py +++ b/tests/unittests/sources/test_ec2.py @@ -297,7 +297,7 @@ def disable_is_resolvable(): def _register_ssh_keys(rfunc, base_url, keys_data): r"""handle ssh key inconsistencies. - public-keys in the ec2 metadata is inconsistently formated compared + public-keys in the ec2 metadata is inconsistently formatted compared to other entries. Given keys_data of {name1: pubkey1, name2: pubkey2} diff --git a/tests/unittests/sources/test_init.py b/tests/unittests/sources/test_init.py index f4a6cc6b1e7..9fa82bcbb60 100644 --- a/tests/unittests/sources/test_init.py +++ b/tests/unittests/sources/test_init.py @@ -284,7 +284,7 @@ def test_get_hostname_without_metadata_uses_system_hostname( with mock.patch("cloudinit.sources.util.get_hostname") as m_gethost: with mock.patch(mock_fqdn) as m_fqdn: m_gethost.return_value = "systemhostname.domain.com" - m_fqdn.return_value = None # No maching fqdn in /etc/hosts + m_fqdn.return_value = None # No matching fqdn in /etc/hosts assert "systemhostname" == datasource.get_hostname().hostname assert ( "systemhostname.domain.com" diff --git a/tests/unittests/sources/test_lxd.py b/tests/unittests/sources/test_lxd.py index f1996e2b480..226ed842938 100644 --- a/tests/unittests/sources/test_lxd.py +++ b/tests/unittests/sources/test_lxd.py @@ -312,7 +312,7 @@ def test_subplatform(self, lxd_ds): assert "LXD socket API v. 1.0 (/dev/lxd/sock)" == lxd_ds.subplatform def test__get_data(self, lxd_ds): - """get_data calls read_metadata, setting appropiate instance attrs.""" + """get_data calls read_metadata, setting appropriate instance attrs.""" assert UNSET == lxd_ds._crawled_metadata assert UNSET == lxd_ds._network_config assert None is lxd_ds.userdata_raw diff --git a/tests/unittests/sources/test_openstack.py b/tests/unittests/sources/test_openstack.py index 85582716cd8..47794217ad8 100644 --- a/tests/unittests/sources/test_openstack.py +++ b/tests/unittests/sources/test_openstack.py @@ -529,7 +529,7 @@ def cvj(self, data): return convert_vendordata(data) def test_vd_load_none(self): - # non-existant vendor-data should return none + # non-existent vendor-data should return none assert self.cvj(None) is None def test_vd_load_string(self): @@ -741,7 +741,7 @@ def fake_dmi_read(dmi_key): if dmi_key == "system-product-name": return "HVM domU" # Nothing 'openstackish' if dmi_key == "chassis-asset-tag": - return "" # Nothin 'openstackish' + return "" # Nothing 'openstackish' assert False, "Unexpected dmi read of %s" % dmi_key m_dmi.side_effect = fake_dmi_read diff --git a/tests/unittests/sources/test_oracle.py b/tests/unittests/sources/test_oracle.py index 14d7ad29a21..4b39f215566 100644 --- a/tests/unittests/sources/test_oracle.py +++ b/tests/unittests/sources/test_oracle.py @@ -1533,7 +1533,7 @@ def test_missing_mac_skipped( oracle_ds, caplog, ): - """If no intefaces by mac found, then _network_config not setted and + """If no interfaces by mac found, then _network_config not set and correct logs. """ vnics_data = json.loads(OPC_VM_SECONDARY_VNIC_RESPONSE) diff --git a/tests/unittests/sources/test_smartos.py b/tests/unittests/sources/test_smartos.py index dc58e0ac5d2..3e76a639e0d 100644 --- a/tests/unittests/sources/test_smartos.py +++ b/tests/unittests/sources/test_smartos.py @@ -691,7 +691,7 @@ def test_default_ephemeral(self, ds): assert isinstance(cfg["fs_setup"], list) def test_override_disk_aliases(self, paths): - # Test to make sure that the built-in DS is overriden + # Test to make sure that the built-in DS is overridden builtin = DataSourceSmartOS.BUILTIN_DS_CONFIG mydscfg = {"disk_aliases": {"FOO": "/dev/bar"}} diff --git a/tests/unittests/sources/test_vmware.py b/tests/unittests/sources/test_vmware.py index dacc0a5a060..e4bd639b04d 100644 --- a/tests/unittests/sources/test_vmware.py +++ b/tests/unittests/sources/test_vmware.py @@ -1062,7 +1062,7 @@ def test_get_imc_data_cust_script_disabled(self, caplog, DS, tmpdir): """ ) util.write_file(conf_file, conf_content) - # Prepare the custom sript + # Prepare the custom script customscript = os.path.join(tmpdir, "test-script") util.write_file(customscript, "This is the post cust script") diff --git a/tests/unittests/sources/test_wsl.py b/tests/unittests/sources/test_wsl.py index 9c062706086..a5300ff8af0 100644 --- a/tests/unittests/sources/test_wsl.py +++ b/tests/unittests/sources/test_wsl.py @@ -29,11 +29,7 @@ "mountpoint": "/", "opts": "rw,relatime,...", }, - "sysfs": { - "fstype": "sysfs", - "mountpoint": "/sys", - "opts": "rw,nosuid...", - }, + "sysfs": {"fstype": "sysfs", "mountpoint": "/sys", "opts": "rw,nosuid..."}, "C:\\": { "fstype": "9p", "mountpoint": "/mnt/c", @@ -396,14 +392,12 @@ def setup(self, mocker, tmpdir): def test_metadata_id_default(self, tmpdir, paths): """ - Validates that instance-id is properly set, indepedent of the existence - of user-data. + Validates that instance-id is properly set, independent of the + existence of user-data. """ ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) ds.get_data() @@ -411,22 +405,18 @@ def test_metadata_id_default(self, tmpdir, paths): def test_metadata_id(self, tmpdir, paths): """ - Validates that instance-id is properly set, indepedent of the existence - of user-data. + Validates that instance-id is properly set, independent of the + existence of user-data. """ SAMPLE_ID = "Nice-ID" metadata_path = tmpdir.join( ".cloud-init", f"{INSTANCE_NAME}.meta-data" ) metadata_path.dirpath().mkdir() - metadata_path.write( - f'{{"instance-id":"{SAMPLE_ID}"}}', - ) + metadata_path.write(f'{{"instance-id":"{SAMPLE_ID}"}}') ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) ds.get_data() @@ -440,9 +430,7 @@ def test_get_data_cc(self, m_lsb_release, paths, tmpdir): data_path.write("#cloud-config\nwrite_files:\n- path: /etc/wsl.conf") ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is True @@ -463,9 +451,7 @@ def test_get_data_sh(self, m_lsb_release, tmpdir, paths): data_path.dirpath().mkdir() data_path.write(f"#!/bin/sh\n{COMMAND}\n") ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is True @@ -492,9 +478,7 @@ def test_get_data_jinja(self, m_lsb_release, paths, tmpdir): ) ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is True @@ -528,9 +512,7 @@ def test_get_data_x( agent_path.write(AGENT_SAMPLE) ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is with_agent_data @@ -577,9 +559,7 @@ def test_data_precedence(self, m_get_linux_dist, tmpdir, paths): # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) # Assert user data is properly loaded @@ -628,15 +608,11 @@ def test_interaction_with_pro(self, m_get_linux_dist, tmpdir, paths): ) SAMPLE_ID = "Nice-ID" agent_metadata_path = ubuntu_pro_tmp.join(f"{INSTANCE_NAME}.meta-data") - agent_metadata_path.write( - f'{{"instance-id":"{SAMPLE_ID}"}}', - ) + agent_metadata_path.write(f'{{"instance-id":"{SAMPLE_ID}"}}') # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) # Assert agent combines with existing user data @@ -657,7 +633,7 @@ def test_interaction_with_pro(self, m_get_linux_dist, tmpdir, paths): @mock.patch("cloudinit.util.get_linux_distro") def test_landscape_vs_local_user(self, m_get_linux_dist, tmpdir, paths): - """Validates the precendence of Landscape-provided over local data""" + """Validates the precedence of Landscape-provided over local data""" m_get_linux_dist.return_value = SAMPLE_LINUX_DISTRO @@ -677,9 +653,7 @@ def test_landscape_vs_local_user(self, m_get_linux_dist, tmpdir, paths): # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is True @@ -694,7 +668,7 @@ def test_landscape_vs_local_user(self, m_get_linux_dist, tmpdir, paths): and "landscapetest" in userdata and "ubuntu_pro" not in userdata and "package_update" not in userdata - ), "Landscape data should have overriden user provided data" + ), "Landscape data should have overridden user provided data" @mock.patch("cloudinit.util.get_linux_distro") def test_landscape_provided_data(self, m_get_linux_dist, tmpdir, paths): @@ -733,9 +707,7 @@ def test_landscape_provided_data(self, m_get_linux_dist, tmpdir, paths): # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) # Assert Landscape and Agent combine, with Agent taking precedence @@ -749,12 +721,12 @@ def test_landscape_provided_data(self, m_get_linux_dist, tmpdir, paths): assert "ubuntu_pro" in userdata, "Agent data should be present" assert "package_update" in userdata, ( - "package_update entry should not be overriden by agent data" + "package_update entry should not be overridden by agent data" " nor ignored" ) assert ( "landscapetest" not in userdata and "agenttest" in userdata - ), "Landscape account name should have been overriden by agent data" + ), "Landscape account name should have been overridden by agent data" # Make sure we have tags from Landscape data, not agent's assert ( "tag_aiml" in userdata and "tag_dev" in userdata @@ -791,9 +763,7 @@ def test_landscape_empty_data(self, m_get_linux_dist, tmpdir, paths): # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) # Assert Landscape and Agent combine, with Agent taking precedence @@ -840,9 +810,7 @@ def test_landscape_shell_script(self, m_get_linux_dist, tmpdir, paths): # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) # Assert Landscape and Agent combine, with Agent taking precedence @@ -899,9 +867,7 @@ def test_with_landscape_no_tags(self, m_get_linux_dist, tmpdir, paths): # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is True @@ -948,9 +914,7 @@ def test_with_no_tags_at_all(self, m_get_linux_dist, tmpdir, paths): # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is True @@ -996,9 +960,7 @@ def test_with_no_client_subkey(self, m_get_linux_dist, tmpdir, paths): ) # Run the datasource ds = wsl.DataSourceWSL( - sys_cfg=SAMPLE_CFG, - distro=get_distro("ubuntu"), - paths=paths, + sys_cfg=SAMPLE_CFG, distro=get_distro("ubuntu"), paths=paths ) assert ds.get_data() is True diff --git a/tests/unittests/test_all_stages.py b/tests/unittests/test_all_stages.py index 1b66e6955ba..a39e318a6f4 100644 --- a/tests/unittests/test_all_stages.py +++ b/tests/unittests/test_all_stages.py @@ -32,7 +32,7 @@ class Timeout: TimeoutError is raised on successful timeout. Create a signal handler and use signal.alarm to verify that the - timeout occured. + timeout occurred. """ def handle_timeout(self, *_): diff --git a/tests/unittests/test_builtin_handlers.py b/tests/unittests/test_builtin_handlers.py index 95bdf45146d..14edb44cde2 100644 --- a/tests/unittests/test_builtin_handlers.py +++ b/tests/unittests/test_builtin_handlers.py @@ -351,7 +351,7 @@ def test_convert_instance_data_decodes_decode_paths(self): class TestRenderJinjaPayload: @skipUnlessJinja() def test_render_jinja_payload_logs_jinja_vars_on_debug(self, caplog): - """When debug is True, log jinja varables available.""" + """When debug is True, log jinja variables available.""" payload = ( "## template: jinja\n#!/bin/sh\necho hi from {{ v1.hostname }}" ) diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py index 63d415b6384..b9ae4d7380e 100644 --- a/tests/unittests/test_ds_identify.py +++ b/tests/unittests/test_ds_identify.py @@ -377,10 +377,7 @@ def write_mock(data): "ret": 1, "err": "No dmidecode program. ERROR.", }, - { - "name": "is_disabled", - "ret": 1, - }, + {"name": "is_disabled", "ret": 1}, { "name": "get_kenv_field", "ret": 1, @@ -535,8 +532,8 @@ def test_wb_print_variables(self, tmp_path): # maas datasource uses check_config() and the existence of a "MAAS" # key to identify itself (which is a very poor identifier - clouds # should have stricter identifiers). Since the MAAS datasource is - # at the begining of the list, this is particularly troublesome and - # more concerning than NoCloud false positives, for example. + # at the beginning of the list, this is particularly troublesome + # and more concerning than NoCloud false positives, for example. pytest.param("LXD-kvm-not-MAAS-2", True, id="mass_not_detected_2"), # Don't detect incorrect config when invalid datasource_list # provided @@ -1268,11 +1265,7 @@ def test_path_env_gets_set_from_main(self, tmp_path): 'PATH="/mycust/path"; main; r=$?; echo ' + pre + "$PATH; exit $r;" ) ret = self._check_via_dict( - cust, - rootd, - RC_FOUND, - func=".", - args=[os.path.join(rootd, mpp)], + cust, rootd, RC_FOUND, func=".", args=[os.path.join(rootd, mpp)] ) match = [ line for line in ret.stdout.splitlines() if line.startswith(pre) @@ -1424,13 +1417,7 @@ def test_no_userprofile(self, tmp_path): variable. """ data = copy.deepcopy(VALID_CFG["WSL-supported"]) - data["mocks"].append( - { - "name": "WSL_run_cmd", - "ret": 0, - "RET": "\r\n", - }, - ) + data["mocks"].append({"name": "WSL_run_cmd", "ret": 0, "RET": "\r\n"}) self._check_via_dict(data, str(tmp_path), RC_NOT_FOUND) def test_no_cloudinitdir_in_userprofile(self, tmp_path): @@ -1438,11 +1425,7 @@ def test_no_cloudinitdir_in_userprofile(self, tmp_path): data = copy.deepcopy(VALID_CFG["WSL-supported"]) userprofile = str(tmp_path) data["mocks"].append( - { - "name": "WSL_profile_dir", - "ret": 0, - "RET": userprofile, - }, + {"name": "WSL_profile_dir", "ret": 0, "RET": userprofile} ) self._check_via_dict(data, str(tmp_path), RC_NOT_FOUND) @@ -1451,11 +1434,7 @@ def test_empty_cloudinitdir(self, tmp_path): data = copy.deepcopy(VALID_CFG["WSL-supported"]) userprofile = str(tmp_path) data["mocks"].append( - { - "name": "WSL_profile_dir", - "ret": 0, - "RET": userprofile, - }, + {"name": "WSL_profile_dir", "ret": 0, "RET": userprofile} ) cloudinitdir = os.path.join(userprofile, ".cloud-init") os.mkdir(cloudinitdir) @@ -1468,15 +1447,11 @@ def test_found_fail_due_instance_name_parsing(self, tmp_path): data = copy.deepcopy(VALID_CFG["WSL-supported-debian"]) userprofile = str(tmp_path) data["mocks"].append( - { - "name": "WSL_profile_dir", - "ret": 0, - "RET": userprofile, - }, + {"name": "WSL_profile_dir", "ret": 0, "RET": userprofile} ) # Forcing WSL_linux2win_path to return a path we'll fail to parse - # (missing one / in the begining of the path). + # (missing one / in the beginning of the path). for i, m in enumerate(data["mocks"]): if m["name"] == "WSL_linux2win_path": data["mocks"][i]["RET"] = "/wsl.localhost/cant-findme" @@ -1493,11 +1468,7 @@ def test_found_via_userdata_version_codename(self, tmp_path): data = copy.deepcopy(VALID_CFG["WSL-supported-debian"]) userprofile = str(tmp_path) data["mocks"].append( - { - "name": "WSL_profile_dir", - "ret": 0, - "RET": userprofile, - }, + {"name": "WSL_profile_dir", "ret": 0, "RET": userprofile} ) cloudinitdir = os.path.join(userprofile, ".cloud-init") os.mkdir(cloudinitdir) @@ -1515,11 +1486,7 @@ def test_found_via_userdata(self, tmp_path): data = copy.deepcopy(VALID_CFG["WSL-supported"]) userprofile = str(tmp_path) data["mocks"].append( - { - "name": "WSL_profile_dir", - "ret": 0, - "RET": userprofile, - }, + {"name": "WSL_profile_dir", "ret": 0, "RET": userprofile} ) cloudinitdir = os.path.join(userprofile, ".cloud-init") os.mkdir(cloudinitdir) @@ -1637,9 +1604,7 @@ def _print_run_output(rc, out, err, cfg, files): }, "Azure-dmi-detection": { "ds": "Azure", - "files": { - P_CHASSIS_ASSET_TAG: "7783-7084-3265-9085-8269-3286-77\n", - }, + "files": {P_CHASSIS_ASSET_TAG: "7783-7084-3265-9085-8269-3286-77\n"}, }, "Azure-seed-detection": { "ds": "Azure", @@ -1648,10 +1613,7 @@ def _print_run_output(rc, out, err, cfg, files): os.path.join(P_SEED_DIR, "azure", "ovf-env.xml"): "present\n", }, }, - "CloudCIX": { - "ds": "CloudCIX", - "files": {P_PRODUCT_NAME: "CloudCIX\n"}, - }, + "CloudCIX": {"ds": "CloudCIX", "files": {P_PRODUCT_NAME: "CloudCIX\n"}}, "Azure-parse-invalid": { "ds": "Azure", "files": { @@ -1672,9 +1634,7 @@ def _print_run_output(rc, out, err, cfg, files): "Ec2-hvm-swap-endianness": { "ds": "Ec2", "mocks": [{"name": "detect_virt", "RET": "kvm", "ret": 0}], - "files": { - P_PRODUCT_UUID: "AB232AEC-54BE-4843-8D24-8C819F88453E\n", - }, + "files": {P_PRODUCT_UUID: "AB232AEC-54BE-4843-8D24-8C819F88453E\n"}, }, "Ec2-hvm-env": { "ds": "Ec2", @@ -1904,9 +1864,7 @@ def _print_run_output(rc, out, err, cfg, files): "/run/systemd/somefile": "", }, # /dev/lxd/sock does not exist and KVM virt-type - "mocks": [ - {"name": "is_socket_file", "ret": 1}, - ], + "mocks": [{"name": "is_socket_file", "ret": 1}], "env_vars": IS_KVM_QEMU_ENV, "no_mocks": [ "dscheck_LXD", @@ -1938,9 +1896,7 @@ def _print_run_output(rc, out, err, cfg, files): ), }, ], - "files": { - "dev/vdb": "pretend iso content for cidata\n", - }, + "files": {"dev/vdb": "pretend iso content for cidata\n"}, }, "NoCloud-cfg": { "ds": "NoCloud", @@ -1975,9 +1931,7 @@ def _print_run_output(rc, out, err, cfg, files): ), }, ], - "files": { - "/dev/vtdb": "pretend iso content for cidata\n", - }, + "files": {"/dev/vtdb": "pretend iso content for cidata\n"}, }, "NoCloudUpper": { "ds": "NoCloud", @@ -1998,9 +1952,7 @@ def _print_run_output(rc, out, err, cfg, files): ), }, ], - "files": { - "dev/vdb": "pretend iso content for cidata\n", - }, + "files": {"dev/vdb": "pretend iso content for cidata\n"}, }, "NoCloud-fatboot": { "ds": "NoCloud", @@ -2023,9 +1975,7 @@ def _print_run_output(rc, out, err, cfg, files): ), }, ], - "files": { - "dev/vdb": "pretend iso content for cidata\n", - }, + "files": {"dev/vdb": "pretend iso content for cidata\n"}, }, "NoCloud-seed": { "ds": "NoCloud", @@ -2132,9 +2082,7 @@ def _print_run_output(rc, out, err, cfg, files): }, "OVF-seed": { "ds": "OVF", - "files": { - os.path.join(P_SEED_DIR, "ovf", "ovf-env.xml"): "present\n", - }, + "files": {os.path.join(P_SEED_DIR, "ovf", "ovf-env.xml"): "present\n"}, }, "OVF": { "ds": "OVF", @@ -2202,7 +2150,7 @@ def _print_run_output(rc, out, err, cfg, files): }, ] ), - }, + } ], }, "ConfigDriveUpper": { @@ -2231,7 +2179,7 @@ def _print_run_output(rc, out, err, cfg, files): }, ] ), - }, + } ], }, "ConfigDrive-seed": { @@ -2268,7 +2216,7 @@ def _print_run_output(rc, out, err, cfg, files): {"DEVNAME": "vdb", "TYPE": "vfat", "LABEL": "CLOUDMD"}, ] ), - }, + } ], }, "RbxCloudLower": { @@ -2293,13 +2241,10 @@ def _print_run_output(rc, out, err, cfg, files): {"DEVNAME": "vdb", "TYPE": "vfat", "LABEL": "cloudmd"}, ] ), - }, + } ], }, - "Hetzner": { - "ds": "Hetzner", - "files": {P_SYS_VENDOR: "Hetzner\n"}, - }, + "Hetzner": {"ds": "Hetzner", "files": {P_SYS_VENDOR: "Hetzner\n"}}, "Hetzner-kenv": { "ds": "Hetzner", "mocks": [ @@ -2318,10 +2263,7 @@ def _print_run_output(rc, out, err, cfg, files): "ds": "Hetzner", "mocks": [{"name": "dmi_decode", "ret": 0, "RET": "Hetzner"}], }, - "NWCS": { - "ds": "NWCS", - "files": {P_SYS_VENDOR: "NWCS\n"}, - }, + "NWCS": {"ds": "NWCS", "files": {P_SYS_VENDOR: "NWCS\n"}}, "NWCS-kenv": { "ds": "NWCS", "mocks": [ @@ -2427,9 +2369,7 @@ def _print_run_output(rc, out, err, cfg, files): }, "Oracle": { "ds": "Oracle", - "files": { - P_CHASSIS_ASSET_TAG: ds_oracle.CHASSIS_ASSET_TAG + "\n", - }, + "files": {P_CHASSIS_ASSET_TAG: ds_oracle.CHASSIS_ASSET_TAG + "\n"}, }, "SmartOS-bhyve": { "ds": "SmartOS", @@ -2488,19 +2428,14 @@ def _print_run_output(rc, out, err, cfg, files): "ds": "Ec2", "files": {P_CHASSIS_ASSET_TAG: "123456.zstack.io\n"}, }, - "Ec2-E24Cloud": { - "ds": "Ec2", - "files": {P_SYS_VENDOR: "e24cloud\n"}, - }, + "Ec2-E24Cloud": {"ds": "Ec2", "files": {P_SYS_VENDOR: "e24cloud\n"}}, "Ec2-E24Cloud-negative": { "ds": "Ec2", "files": {P_SYS_VENDOR: "e24cloudyday\n"}, }, "VMware-NoValidTransports": { "ds": "VMware", - "mocks": [ - MOCK_VIRT_IS_VMWARE, - ], + "mocks": [MOCK_VIRT_IS_VMWARE], }, "VMware-vmware-customization": { "ds": "VMware", @@ -2612,109 +2547,49 @@ def _print_run_output(rc, out, err, cfg, files): "VMware-EnvVar-NoData": { "ds": "VMware", "mocks": [ - { - "name": "vmware_has_envvar_vmx_guestinfo", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_metadata", - "ret": 1, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_has_envvar_vmx_guestinfo", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_metadata", "ret": 1}, + {"name": "vmware_has_envvar_vmx_guestinfo_userdata", "ret": 1}, + {"name": "vmware_has_envvar_vmx_guestinfo_vendordata", "ret": 1}, MOCK_VIRT_IS_VMWARE, ], }, "VMware-EnvVar-NoVirtID": { "ds": "VMware", "mocks": [ - { - "name": "vmware_has_envvar_vmx_guestinfo", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_metadata", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_has_envvar_vmx_guestinfo", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_metadata", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_userdata", "ret": 1}, + {"name": "vmware_has_envvar_vmx_guestinfo_vendordata", "ret": 1}, ], }, "VMware-EnvVar-Metadata": { "ds": "VMware", "mocks": [ - { - "name": "vmware_has_envvar_vmx_guestinfo", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_metadata", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_has_envvar_vmx_guestinfo", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_metadata", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_userdata", "ret": 1}, + {"name": "vmware_has_envvar_vmx_guestinfo_vendordata", "ret": 1}, MOCK_VIRT_IS_VMWARE, ], }, "VMware-EnvVar-Userdata": { "ds": "VMware", "mocks": [ - { - "name": "vmware_has_envvar_vmx_guestinfo", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_metadata", - "ret": 1, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_userdata", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_has_envvar_vmx_guestinfo", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_metadata", "ret": 1}, + {"name": "vmware_has_envvar_vmx_guestinfo_userdata", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_vendordata", "ret": 1}, MOCK_VIRT_IS_VMWARE, ], }, "VMware-EnvVar-Vendordata": { "ds": "VMware", "mocks": [ - { - "name": "vmware_has_envvar_vmx_guestinfo", - "ret": 0, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_metadata", - "ret": 1, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_has_envvar_vmx_guestinfo_vendordata", - "ret": 0, - }, + {"name": "vmware_has_envvar_vmx_guestinfo", "ret": 0}, + {"name": "vmware_has_envvar_vmx_guestinfo_metadata", "ret": 1}, + {"name": "vmware_has_envvar_vmx_guestinfo_userdata", "ret": 1}, + {"name": "vmware_has_envvar_vmx_guestinfo_vendordata", "ret": 0}, MOCK_VIRT_IS_VMWARE, ], }, @@ -2731,18 +2606,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 1, "out": "/usr/bin/vmtoolsd", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_guestinfo_metadata", "ret": 1}, + {"name": "vmware_guestinfo_userdata", "ret": 1}, + {"name": "vmware_guestinfo_vendordata", "ret": 1}, MOCK_VIRT_IS_VMWARE, ], }, @@ -2760,18 +2626,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 0, "out": "/usr/bin/vmtoolsd", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_guestinfo_metadata", "ret": 1}, + {"name": "vmware_guestinfo_userdata", "ret": 1}, + {"name": "vmware_guestinfo_vendordata", "ret": 1}, MOCK_VIRT_IS_VMWARE, ], }, @@ -2783,19 +2640,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 0, "out": "/usr/bin/vmware-rpctool", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 0, - "out": "---", - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_guestinfo_metadata", "ret": 0, "out": "---"}, + {"name": "vmware_guestinfo_userdata", "ret": 1}, + {"name": "vmware_guestinfo_vendordata", "ret": 1}, ], }, "VMware-GuestInfo-Metadata": { @@ -2811,19 +2658,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 0, "out": "/usr/bin/vmtoolsd", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 0, - "out": "---", - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_guestinfo_metadata", "ret": 0, "out": "---"}, + {"name": "vmware_guestinfo_userdata", "ret": 1}, + {"name": "vmware_guestinfo_vendordata", "ret": 1}, MOCK_VIRT_IS_VMWARE, ], }, @@ -2840,19 +2677,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 1, "out": "/usr/bin/vmtoolsd", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 0, - "out": "---", - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_guestinfo_metadata", "ret": 1}, + {"name": "vmware_guestinfo_userdata", "ret": 0, "out": "---"}, + {"name": "vmware_guestinfo_vendordata", "ret": 1}, MOCK_VIRT_IS_VMWARE, ], }, @@ -2869,19 +2696,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 0, "out": "/usr/bin/vmtoolsd", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 0, - "out": "---", - }, + {"name": "vmware_guestinfo_metadata", "ret": 1}, + {"name": "vmware_guestinfo_userdata", "ret": 1}, + {"name": "vmware_guestinfo_vendordata", "ret": 0, "out": "---"}, MOCK_VIRT_IS_VMWARE, ], }, @@ -2899,19 +2716,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 0, "out": "/usr/bin/vmtoolsd", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 0, - "out": "---", - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_guestinfo_metadata", "ret": 0, "out": "---"}, + {"name": "vmware_guestinfo_userdata", "ret": 1}, + {"name": "vmware_guestinfo_vendordata", "ret": 1}, { "name": "blkid", "ret": 0, @@ -2952,19 +2759,9 @@ def _print_run_output(rc, out, err, cfg, files): "ret": 0, "out": "/usr/bin/vmtoolsd", }, - { - "name": "vmware_guestinfo_metadata", - "ret": 0, - "out": "---", - }, - { - "name": "vmware_guestinfo_userdata", - "ret": 1, - }, - { - "name": "vmware_guestinfo_vendordata", - "ret": 1, - }, + {"name": "vmware_guestinfo_metadata", "ret": 0, "out": "---"}, + {"name": "vmware_guestinfo_userdata", "ret": 1}, + {"name": "vmware_guestinfo_vendordata", "ret": 1}, { "name": "blkid", "ret": 0, @@ -3012,25 +2809,17 @@ def _print_run_output(rc, out, err, cfg, files): P_SYS_VENDOR: "3DS Outscale\n", }, }, - "Not-WSL": { - "ds": "WSL", - "mocks": [ - MOCK_VIRT_IS_KVM, - ], - }, + "Not-WSL": {"ds": "WSL", "mocks": [MOCK_VIRT_IS_KVM]}, "WSL-no-host-mounts": { "ds": "WSL", - "mocks": [ - MOCK_VIRT_IS_WSL, - MOCK_UNAME_IS_WSL, - ], + "mocks": [MOCK_VIRT_IS_WSL, MOCK_UNAME_IS_WSL], "files": { "proc/mounts": ( "/dev/sdd / ext4 rw,errors=remount-ro,data=ordered 0 0\n" "cgroup2 /sys/fs/cgroup cgroup2 rw,nosuid,nodev,noexec0 0\n" "snapfuse /snap/core22/1033 fuse.snapfuse ro,nodev,user_id=0," "group_id=0,allow_other 0 0" - ), + ) }, }, "WSL-supported": { diff --git a/tests/unittests/test_netinfo.py b/tests/unittests/test_netinfo.py index b5195531a17..90f78356a9d 100644 --- a/tests/unittests/test_netinfo.py +++ b/tests/unittests/test_netinfo.py @@ -97,7 +97,7 @@ def test_netdev_iproute_pformat(self, m_subp, m_which, resource, is_json): @mock.patch("cloudinit.netinfo.subp.subp") def test_netdev_warn_on_missing_commands(self, m_subp, m_which, caplog): """netdev_pformat warns when missing both ip and 'netstat'.""" - m_which.return_value = None # Niether ip nor netstat found + m_which.return_value = None # Neither ip nor netstat found content = netdev_pformat() assert "\n" == content log = caplog.records[0] @@ -254,7 +254,7 @@ def subp_iproute_selector(*args, **kwargs): @mock.patch("cloudinit.netinfo.subp.subp") def test_route_warn_on_missing_commands(self, m_subp, m_which, caplog): """route_pformat warns when missing both ip and 'netstat'.""" - m_which.return_value = None # Niether ip nor netstat found + m_which.return_value = None # Neither ip nor netstat found content = route_pformat() assert "\n" == content log = caplog.records[0] diff --git a/tests/unittests/test_upgrade.py b/tests/unittests/test_upgrade.py index ac2545e22b2..85209409ffc 100644 --- a/tests/unittests/test_upgrade.py +++ b/tests/unittests/test_upgrade.py @@ -240,7 +240,7 @@ def test_all_ds_init_vs_unpickle_attributes( if getattr(ds.__class__.__bases__[0], "dsname", None) == ds.dsname: # We are a subclass in a different boot mode (Local/Net) and - # share a common parent with class atttributes + # share a common parent with class attributes class_attrs.update(ds.__class__.__bases__[0].__dict__) # Determine new instance attributes created by __init__ diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py index 2651e2ff619..4cda0066ae1 100644 --- a/tests/unittests/test_util.py +++ b/tests/unittests/test_util.py @@ -561,7 +561,7 @@ def test_read_conf_d_no_permissions( logging warnings. Note: This is used in cmd, therefore want to keep the invariant of - not outputing to the console and log file permission errors. + not outputting to the console and log file permission errors. """ confs = [] for i in range(2): @@ -604,7 +604,7 @@ def test_read_conf_with_confd_no_permissions( sys output is empty and the user is informed via logging warnings. Note: This is used in cmd, therefore want to keep the invariant of - not outputing to the console and log file permission errors. + not outputting to the console and log file permission errors. """ conf_fn = tmpdir.join("conf.cfg") if create_confd: @@ -1845,7 +1845,7 @@ def test_basic_usage(self): assert 0o644 == stat.S_IMODE(file_stat.st_mode) def test_dir_is_created_if_required(self): - """Verifiy that directories are created is required.""" + """Verify that directories are created is required.""" dirname = os.path.join(self.tmp, "subdir") path = os.path.join(dirname, "NewFile.txt") contents = "Hey there" @@ -1856,7 +1856,7 @@ def test_dir_is_created_if_required(self): assert os.path.isfile(path) def test_dir_ownership(self): - """Verifiy that directories is created with appropriate ownership.""" + """Verify that directories is created with appropriate ownership.""" dirname = os.path.join(self.tmp, "subdir", "subdir2") path = os.path.join(dirname, "NewFile.txt") contents = "Hey there" diff --git a/tools/mock-meta.py b/tools/mock-meta.py index f8fcd776284..1023e117a3c 100755 --- a/tools/mock-meta.py +++ b/tools/mock-meta.py @@ -56,7 +56,7 @@ "root", ] -DEV_PREFIX = "v" # This seems to vary alot depending on images... +DEV_PREFIX = "v" # This seems to vary a lot depending on images... DEV_MAPPINGS = { "ephemeral0": "%sda2" % (DEV_PREFIX), "root": "/dev/%sda1" % (DEV_PREFIX), diff --git a/tox.ini b/tox.ini index d3d877d4410..4e801689577 100644 --- a/tox.ini +++ b/tox.ini @@ -171,7 +171,7 @@ commands = coverage report -i # dependencies will generally be older than what is found in pip. # To obtain these versions, check the versions of these libraries -# in the oldest support Ubuntu distro. Theses versions are from bionic. +# in the oldest support Ubuntu distro. These versions are from bionic. deps = jinja2==2.10.1 oauthlib==3.1.0