From 4d85b5ad6fd8d09d4fced69ee5b6e99128039910 Mon Sep 17 00:00:00 2001 From: Jacopo Rota Date: Tue, 1 Dec 2026 13:28:58 +0100 Subject: [PATCH 1/2] modernize project --- README | 2 + maas/__init__.py | 4 +- maas/client/bones/__init__.py | 8 ++- maas/client/bones/testing/__init__.py | 9 ++- maas/client/errors.py | 2 +- maas/client/flesh/__init__.py | 1 - maas/client/flesh/tests/test_controllers.py | 4 +- maas/client/flesh/tests/test_devices.py | 4 +- maas/client/flesh/tests/test_machines.py | 4 +- maas/client/flesh/tests/test_nodes.py | 4 +- maas/client/flesh/tests/test_profiles.py | 6 +- maas/client/flesh/tests/test_shell.py | 1 - maas/client/flesh/tests/testing/__init__.py | 10 +--- maas/client/testing/__init__.py | 1 - maas/client/utils/creds.py | 1 - maas/client/utils/profiles.py | 16 ++--- maas/client/utils/tests/test.py | 8 +-- maas/client/utils/tests/test_async.py | 1 - maas/client/utils/tests/test_diff.py | 8 +-- maas/client/viscera/__init__.py | 1 - maas/client/viscera/machines.py | 1 - maas/client/viscera/testing/__init__.py | 2 +- maas/client/viscera/tests/test.py | 16 ++--- .../viscera/tests/test_bcache_cache_sets.py | 8 +-- maas/client/viscera/tests/test_bcaches.py | 12 ++-- .../viscera/tests/test_block_devices.py | 20 +++---- .../viscera/tests/test_boot_resources.py | 22 +++---- .../tests/test_boot_source_selections.py | 6 +- .../client/viscera/tests/test_boot_sources.py | 2 +- maas/client/viscera/tests/test_events.py | 1 - maas/client/viscera/tests/test_files.py | 2 +- maas/client/viscera/tests/test_interfaces.py | 60 +++++++++---------- maas/client/viscera/tests/test_ipranges.py | 2 +- maas/client/viscera/tests/test_machines.py | 4 +- maas/client/viscera/tests/test_vlans.py | 2 +- setup.py | 9 --- tox.ini | 27 +++++++-- 37 files changed, 139 insertions(+), 152 deletions(-) diff --git a/README b/README index 3b292a58..b8f80abc 100644 --- a/README +++ b/README @@ -37,6 +37,8 @@ It's pretty easy to start hacking on _python-libmaas_: $ make develop $ make test +The unit tests can also be run directly with `python3 -m tox -e py3`. + Installing [IPython][] is generally a good idea too: $ bin/pip install -UI IPython diff --git a/maas/__init__.py b/maas/__init__.py index 5284146e..b36383a6 100644 --- a/maas/__init__.py +++ b/maas/__init__.py @@ -1 +1,3 @@ -__import__("pkg_resources").declare_namespace(__name__) +from pkgutil import extend_path + +__path__ = extend_path(__path__, __name__) diff --git a/maas/client/bones/__init__.py b/maas/client/bones/__init__.py index 7b5b8d31..1db80d25 100644 --- a/maas/client/bones/__init__.py +++ b/maas/client/bones/__init__.py @@ -337,9 +337,11 @@ def __init__(self, request, response, content, call): desc = "%s -> %s (%s)" % ( desc_for_request, desc_for_response, - desc_for_content - if len(desc_for_content) <= 50 - else (desc_for_content[:49] + "…"), + ( + desc_for_content + if len(desc_for_content) <= 50 + else (desc_for_content[:49] + "…") + ), ) super(CallError, self).__init__(desc) self.request = request diff --git a/maas/client/bones/testing/__init__.py b/maas/client/bones/testing/__init__.py index 9577e755..fd972ebf 100644 --- a/maas/client/bones/testing/__init__.py +++ b/maas/client/bones/testing/__init__.py @@ -5,13 +5,12 @@ import http import http.server import json +from importlib.resources import files from operator import itemgetter -from pathlib import Path import re import threading import fixtures -from pkg_resources import resource_filename, resource_listdir def list_api_descriptions(): @@ -21,13 +20,13 @@ def list_api_descriptions(): must match "apiXX.json" where "XX" denotes the major and minor version number of the API. """ - for filename in resource_listdir(__name__, "."): + for resource in files(__package__).iterdir(): + filename = resource.name match = re.match(r"api(\d)(\d)[.]json", filename) if match is not None: version = tuple(map(int, match.groups())) - path = resource_filename(__name__, filename) name = "%d.%d" % version - yield name, version, Path(path) + yield name, version, resource def load_api_descriptions(): diff --git a/maas/client/errors.py b/maas/client/errors.py index 963339ff..e0698fdb 100644 --- a/maas/client/errors.py +++ b/maas/client/errors.py @@ -1,4 +1,4 @@ -""" Custom errors for libmaas """ +"""Custom errors for libmaas""" __all__ = ["MAASException", "OperationNotAllowed"] diff --git a/maas/client/flesh/__init__.py b/maas/client/flesh/__init__.py index 7c1fa644..5cee77e2 100644 --- a/maas/client/flesh/__init__.py +++ b/maas/client/flesh/__init__.py @@ -28,7 +28,6 @@ from ..utils.auth import try_getpass from ..utils.profiles import Profile, ProfileStore - PROG_DESCRIPTION = """\ MAAS provides complete automation of your physical servers for amazing data center operational efficiency. diff --git a/maas/client/flesh/tests/test_controllers.py b/maas/client/flesh/tests/test_controllers.py index e5e7e411..f0a21ff1 100644 --- a/maas/client/flesh/tests/test_controllers.py +++ b/maas/client/flesh/tests/test_controllers.py @@ -73,7 +73,7 @@ def test_returns_table_with_controllers(self): output = yaml.safe_load( cmd.execute(origin, options, target=tabular.RenderTarget.yaml) ) - self.assertEquals( + self.assertEqual( [ {"name": "hostname", "title": "Hostname"}, {"name": "node_type", "title": "Type"}, @@ -93,7 +93,7 @@ def test_returns_table_with_controllers(self): } for controller in racks + regions } - self.assertEquals( + self.assertEqual( sorted(controller_output.values(), key=itemgetter("hostname")), output["data"], ) diff --git a/maas/client/flesh/tests/test_devices.py b/maas/client/flesh/tests/test_devices.py index 2b355725..c8b54624 100644 --- a/maas/client/flesh/tests/test_devices.py +++ b/maas/client/flesh/tests/test_devices.py @@ -52,7 +52,7 @@ def test_returns_table_with_devices(self): output = yaml.safe_load( cmd.execute(origin, options, target=tabular.RenderTarget.yaml) ) - self.assertEquals( + self.assertEqual( [ {"name": "hostname", "title": "Hostname"}, {"name": "owner", "title": "Owner"}, @@ -76,7 +76,7 @@ def test_returns_table_with_devices(self): ], key=itemgetter("hostname"), ) - self.assertEquals(devices_output, output["data"]) + self.assertEqual(devices_output, output["data"]) def test_calls_handler_with_hostnames(self): origin = make_origin() diff --git a/maas/client/flesh/tests/test_machines.py b/maas/client/flesh/tests/test_machines.py index 6e3c9412..51247d8f 100644 --- a/maas/client/flesh/tests/test_machines.py +++ b/maas/client/flesh/tests/test_machines.py @@ -60,7 +60,7 @@ def test_returns_table_with_machines(self): output = yaml.safe_load( cmd.execute(origin, options, target=tabular.RenderTarget.yaml) ) - self.assertEquals( + self.assertEqual( [ {"name": "hostname", "title": "Hostname"}, {"name": "power", "title": "Power"}, @@ -91,7 +91,7 @@ def test_returns_table_with_machines(self): ], key=itemgetter("hostname"), ) - self.assertEquals(machines_output, output["data"]) + self.assertEqual(machines_output, output["data"]) def test_calls_handler_with_hostnames(self): origin = make_origin() diff --git a/maas/client/flesh/tests/test_nodes.py b/maas/client/flesh/tests/test_nodes.py index 5dce2604..ccb5e720 100644 --- a/maas/client/flesh/tests/test_nodes.py +++ b/maas/client/flesh/tests/test_nodes.py @@ -51,7 +51,7 @@ def test_returns_table_with_nodes(self): output = yaml.safe_load( cmd.execute(origin, options, target=tabular.RenderTarget.yaml) ) - self.assertEquals( + self.assertEqual( [ {"name": "hostname", "title": "Hostname"}, {"name": "node_type", "title": "Type"}, @@ -65,7 +65,7 @@ def test_returns_table_with_nodes(self): ], key=itemgetter("hostname"), ) - self.assertEquals(nodes_output, output["data"]) + self.assertEqual(nodes_output, output["data"]) def test_calls_handler_with_hostnames(self): origin = make_origin() diff --git a/maas/client/flesh/tests/test_profiles.py b/maas/client/flesh/tests/test_profiles.py index d71e7270..b07b34ac 100644 --- a/maas/client/flesh/tests/test_profiles.py +++ b/maas/client/flesh/tests/test_profiles.py @@ -51,8 +51,7 @@ def test_print_whats_next(self): profile = make_profile() stdout = self.patch(sys, "stdout", StringIO()) profiles.cmd_login.print_whats_next(profile) - expected = dedent( - """\ + expected = dedent("""\ Congratulations! You are logged in to the MAAS server at {profile.url} with the profile name {profile.name}. @@ -61,7 +60,6 @@ def test_print_whats_next(self): maas help - """ - ).format(profile=profile) + """).format(profile=profile) observed = stdout.getvalue() self.assertDocTestMatches(expected, observed) diff --git a/maas/client/flesh/tests/test_shell.py b/maas/client/flesh/tests/test_shell.py index 43787148..987902cd 100644 --- a/maas/client/flesh/tests/test_shell.py +++ b/maas/client/flesh/tests/test_shell.py @@ -54,7 +54,6 @@ def test_offers_profile_name_option_when_profiles_exist(self): self.assertThat(options.profile_name, Equals(profile_name)) # Other profile names are not permitted. - self.patch(subparser, "error").side_effect = Exception profile_name = make_name_without_spaces("foo") error = capture_parse_error(subparser, "--profile-name", profile_name) self.assertThat( diff --git a/maas/client/flesh/tests/testing/__init__.py b/maas/client/flesh/tests/testing/__init__.py index 2a2dfbfd..52c59c66 100644 --- a/maas/client/flesh/tests/testing/__init__.py +++ b/maas/client/flesh/tests/testing/__init__.py @@ -10,14 +10,10 @@ def capture_parse_error(parser, *args): - """Capture the `ArgumentError` arising from parsing the given arguments. - - `argparse` is hard to test (and to introspect, and extend... but it is - good at what it does) so we have to use a pseudo-private method here. - """ - namespace = argparse.Namespace() + """Capture `argparse.ArgumentError` using the public parsing API.""" + parser.exit_on_error = False try: - parser._parse_known_args(list(args), namespace) + parser.parse_args(args) except argparse.ArgumentError as error: return error else: diff --git a/maas/client/testing/__init__.py b/maas/client/testing/__init__.py index 4e740acd..32860fc7 100644 --- a/maas/client/testing/__init__.py +++ b/maas/client/testing/__init__.py @@ -32,7 +32,6 @@ from ..utils.maas_async import Asynchronous - random_letters = map(random.choice, repeat(string.ascii_letters + string.digits)) random_letters_with_spaces = map( diff --git a/maas/client/utils/creds.py b/maas/client/utils/creds.py index 38dc8383..96bb2cfd 100644 --- a/maas/client/utils/creds.py +++ b/maas/client/utils/creds.py @@ -28,7 +28,6 @@ from collections import namedtuple import typing - CredentialsBase = namedtuple( "CredentialsBase", ("consumer_key", "token_key", "token_secret") ) diff --git a/maas/client/utils/profiles.py b/maas/client/utils/profiles.py index 8da4aff2..12d45936 100644 --- a/maas/client/utils/profiles.py +++ b/maas/client/utils/profiles.py @@ -136,17 +136,13 @@ def schema_create(conn): :param conn: A connection to an SQLite3 database. """ - conn.execute( - dedent( - """\ + conn.execute(dedent("""\ CREATE TABLE IF NOT EXISTS profiles (id INTEGER PRIMARY KEY, name TEXT NOT NULL UNIQUE, data BLOB NOT NULL, selected BOOLEAN NOT NULL DEFAULT FALSE) - """ - ) - ) + """)) # Partial indexes are only available in >=3.8.0 and expressions in indexes # are only available in >=3.9.0 (https://www.sqlite.org/partialindex.html # & https://www.sqlite.org/expridx.html). Don't bother with any kind of @@ -154,15 +150,11 @@ def schema_create(conn): if sqlite3.sqlite_version_info >= (3, 9, 0): # This index is for data integrity -- ensuring that only one profile # is the default ("selected") profile -- and speed a distant second. - conn.execute( - dedent( - """\ + conn.execute(dedent("""\ CREATE UNIQUE INDEX IF NOT EXISTS only_one_profile_selected ON profiles (selected IS NOT NULL) WHERE selected - """ - ) - ) + """)) def schema_import(conn, dbpath): diff --git a/maas/client/utils/tests/test.py b/maas/client/utils/tests/test.py index acd8e271..e250463a 100644 --- a/maas/client/utils/tests/test.py +++ b/maas/client/utils/tests/test.py @@ -368,8 +368,7 @@ def test_unwrapping(self): "Title over two lines", "Paragraph over\ntwo lines\n\n" "Another paragraph\nover two lines", ), - utils.parse_docstring( - """ + utils.parse_docstring(""" Title over two lines @@ -378,8 +377,7 @@ def test_unwrapping(self): Another paragraph over two lines - """ - ), + """), ) def test_gets_docstring_from_function(self): @@ -550,4 +548,4 @@ class TestRemoveNone(TestCase): def test_removes_all_None_values(self): data = {"None": None, "another_None": None, "keep": "value"} - self.assertEquals({"keep": "value"}, utils.remove_None(data)) + self.assertEqual({"keep": "value"}, utils.remove_None(data)) diff --git a/maas/client/utils/tests/test_async.py b/maas/client/utils/tests/test_async.py index 6bf464ee..71ac58f8 100644 --- a/maas/client/utils/tests/test_async.py +++ b/maas/client/utils/tests/test_async.py @@ -22,7 +22,6 @@ from .. import maas_async from ...testing import TestCase - IsAwaitable = MatchesPredicate(isawaitable, "%s is not awaitable") diff --git a/maas/client/utils/tests/test_diff.py b/maas/client/utils/tests/test_diff.py index 8b30c01e..c26b4ca8 100644 --- a/maas/client/utils/tests/test_diff.py +++ b/maas/client/utils/tests/test_diff.py @@ -26,13 +26,13 @@ class TestCalculateDictDiff(TestCase): def test_calcs_no_difference(self): orig_data = {"key1": "value1", "key2": "value2"} new_data = copy.deepcopy(orig_data) - self.assertEquals({}, calculate_dict_diff(orig_data, new_data)) + self.assertEqual({}, calculate_dict_diff(orig_data, new_data)) def test_calcs_changed_value(self): orig_data = {"key1": "value1", "key2": "value2"} new_data = copy.deepcopy(orig_data) new_data["key2"] = "new_value" - self.assertEquals( + self.assertEqual( {"key2": "new_value"}, calculate_dict_diff(orig_data, new_data) ) @@ -40,13 +40,13 @@ def test_calcs_deleted_value(self): orig_data = {"key1": "value1", "key2": "value2"} new_data = copy.deepcopy(orig_data) del new_data["key2"] - self.assertEquals({"key2": ""}, calculate_dict_diff(orig_data, new_data)) + self.assertEqual({"key2": ""}, calculate_dict_diff(orig_data, new_data)) def test_calcs_changes_and_deleted(self): orig_data = {"key1": "value1", "key2": "value2"} new_data = copy.deepcopy(orig_data) new_data["key1"] = "new_value" del new_data["key2"] - self.assertEquals( + self.assertEqual( {"key1": "new_value", "key2": ""}, calculate_dict_diff(orig_data, new_data) ) diff --git a/maas/client/viscera/__init__.py b/maas/client/viscera/__init__.py index 40edd6fc..fe627225 100644 --- a/maas/client/viscera/__init__.py +++ b/maas/client/viscera/__init__.py @@ -35,7 +35,6 @@ from ..utils import get_all_subclasses, vars_class from ..utils.maas_async import Asynchronous - undefined = object() diff --git a/maas/client/viscera/machines.py b/maas/client/viscera/machines.py index f9ac96dc..db4dad54 100644 --- a/maas/client/viscera/machines.py +++ b/maas/client/viscera/machines.py @@ -29,7 +29,6 @@ from ..utils import remove_None from ..utils.diff import calculate_dict_diff - FabricParam = typing.Union[str, int, Fabric] InterfaceParam = typing.Union[str, int, Interface] SubnetParam = typing.Union[str, int, Subnet] diff --git a/maas/client/viscera/testing/__init__.py b/maas/client/viscera/testing/__init__.py index f11ed71e..85ff4c0c 100644 --- a/maas/client/viscera/testing/__init__.py +++ b/maas/client/viscera/testing/__init__.py @@ -1,4 +1,4 @@ -""" Testing framework for maas.client.viscera """ +"""Testing framework for maas.client.viscera""" __all__ = ["bind"] diff --git a/maas/client/viscera/tests/test.py b/maas/client/viscera/tests/test.py index 62611720..cf100802 100644 --- a/maas/client/viscera/tests/test.py +++ b/maas/client/viscera/tests/test.py @@ -480,7 +480,7 @@ def test__can_access_pk_attributes_when_unloaded(self): object_pk = randint(0, 20) object_a = object_type(object_pk) self.assertFalse(object_a.loaded) - self.assertEquals(object_pk, object_a.pk) + self.assertEqual(object_pk, object_a.pk) def test__can_access_alt_pk_attributes_when_unloaded(self): object_type = type( @@ -495,7 +495,7 @@ def test__can_access_alt_pk_attributes_when_unloaded(self): object_alt_pk = randint(0, 20) object_a = object_type({"alt_pk_d": object_alt_pk, "__incomplete__": True}) self.assertFalse(object_a.loaded) - self.assertEquals(object_alt_pk, object_a.alt_pk) + self.assertEqual(object_alt_pk, object_a.alt_pk) def test__can_access_attributes_when_loaded(self): object_type = type( @@ -507,7 +507,7 @@ def test__can_access_attributes_when_loaded(self): object_name = make_name("name") object_a = object_type({"pk_d": object_pk, "name": object_name}) self.assertTrue(object_a.loaded) - self.assertEquals(object_name, object_a.name) + self.assertEqual(object_name, object_a.name) def test__equal_when_data_matches(self): data = {"key": make_name("value")} @@ -1210,7 +1210,7 @@ def test__init__requires_str_or_Object_class(self): ObjectFieldRelatedSet("name", ObjectSet) def test_datum_to_value_returns_empty_list_on_None(self): - self.assertEquals( + self.assertEqual( ObjectFieldRelatedSet("name", "class").datum_to_value(object(), None), [] ) @@ -1232,7 +1232,7 @@ def test_datum_to_value_converts_to_set_of_bound_class(self): field = ObjectFieldRelatedSet("related_ids", "RelObjectSet") rel_ids = range(5) rel_object_set = field.datum_to_value(instance, rel_ids) - self.assertEquals(5, len(rel_object_set)) + self.assertEqual(5, len(rel_object_set)) self.assertIsInstance(rel_object_set[0], rel_object_type) self.assertFalse(rel_object_set[0].loaded) self.assertThat( @@ -1253,7 +1253,7 @@ def test_datum_to_value_uses_reverse_name(self): field = ObjectFieldRelatedSet("related_ids", "RelObjectSet", reverse="reverse") rel_ids = range(5) rel_object_set = field.datum_to_value(instance, rel_ids) - self.assertEquals(5, len(rel_object_set)) + self.assertEqual(5, len(rel_object_set)) self.assertIsInstance(rel_object_set[0], rel_object_type) self.assertFalse(rel_object_set[0].loaded) self.assertThat( @@ -1273,7 +1273,7 @@ def test_datum_to_value_doesnt_include_reverse(self): field = ObjectFieldRelatedSet("related_ids", "RelObjectSet", reverse=None) rel_ids = range(5) rel_object_set = field.datum_to_value(instance, rel_ids) - self.assertEquals(5, len(rel_object_set)) + self.assertEqual(5, len(rel_object_set)) self.assertIsInstance(rel_object_set[0], rel_object_type) self.assertFalse(rel_object_set[0].loaded) self.assertThat(rel_object_set[0]._data, Equals({"pk_d": rel_ids[0]})) @@ -1297,7 +1297,7 @@ def test_datum_to_value_wraps_managed_create(self): rel_ids = range(5) rel_object_set = field.datum_to_value(instance, rel_ids) rel_object_set.create() - self.assertEquals( + self.assertEqual( "RelObjectSet.Managed#InstObject", type(rel_object_set).__name__ ) self.assertThat(create_mock.call_args_list, Equals([call(instance)])) diff --git a/maas/client/viscera/tests/test_bcache_cache_sets.py b/maas/client/viscera/tests/test_bcache_cache_sets.py index f7bba667..4f4fb00a 100644 --- a/maas/client/viscera/tests/test_bcache_cache_sets.py +++ b/maas/client/viscera/tests/test_bcache_cache_sets.py @@ -36,7 +36,7 @@ def test__read_bad_node_type(self): error = self.assertRaises( TypeError, BcacheCacheSets.read, random.randint(0, 100) ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__read_with_system_id(self): BcacheCacheSets = make_origin().BcacheCacheSets @@ -87,7 +87,7 @@ def test__create_bad_node_type(self): random.randint(0, 100), origin.BlockDevice({}), ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__create_bad_cache_device_type(self): BcacheCacheSets = make_origin().BcacheCacheSets @@ -97,7 +97,7 @@ def test__create_bad_cache_device_type(self): make_string_without_spaces(), random.randint(0, 100), ) - self.assertEquals( + self.assertEqual( "cache_device must be a BlockDevice or Partition, not int", str(error) ) @@ -141,7 +141,7 @@ def test__read_bad_node_type(self): random.randint(0, 100), random.randint(0, 100), ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__read_with_system_id(self): BcacheCacheSet = make_origin().BcacheCacheSet diff --git a/maas/client/viscera/tests/test_bcaches.py b/maas/client/viscera/tests/test_bcaches.py index 10271ce9..98c5732f 100644 --- a/maas/client/viscera/tests/test_bcaches.py +++ b/maas/client/viscera/tests/test_bcaches.py @@ -92,7 +92,7 @@ def test__get_by_name(self): def test__read_bad_node_type(self): Bcaches = make_origin().Bcaches error = self.assertRaises(TypeError, Bcaches.read, random.randint(0, 100)) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__read_with_system_id(self): Bcaches = make_origin().Bcaches @@ -158,7 +158,7 @@ def test__create_bad_node_type(self): random.randint(0, 100), CacheMode.WRITETHROUGH, ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__create_bad_cache_device_type(self): Bcaches = make_origin().Bcaches @@ -171,7 +171,7 @@ def test__create_bad_cache_device_type(self): random.randint(0, 100), CacheMode.WRITETHROUGH, ) - self.assertEquals( + self.assertEqual( "backing_device must be a BlockDevice or Partition, not int", str(error) ) @@ -187,7 +187,7 @@ def test__create_bad_cache_set_type(self): make_string_without_spaces(), CacheMode.WRITETHROUGH, ) - self.assertEquals( + self.assertEqual( "cache_set must be a BcacheCacheSet or int, not str", str(error) ) @@ -203,7 +203,7 @@ def test__create_bad_cache_mode_type(self): random.randint(0, 100), "writethrough", ) - self.assertEquals("cache_mode must be a CacheMode, not str", str(error)) + self.assertEqual("cache_mode must be a CacheMode, not str", str(error)) def test__create_with_block_device(self): origin = make_origin() @@ -257,7 +257,7 @@ def test__read_bad_node_type(self): error = self.assertRaises( TypeError, Bcache.read, random.randint(0, 100), random.randint(0, 100) ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__read_with_system_id(self): Bcache = make_origin().Bcache diff --git a/maas/client/viscera/tests/test_block_devices.py b/maas/client/viscera/tests/test_block_devices.py index 3775a2c3..2e54edaa 100644 --- a/maas/client/viscera/tests/test_block_devices.py +++ b/maas/client/viscera/tests/test_block_devices.py @@ -63,7 +63,7 @@ def test__get_by_name(self): def test__read_bad_node_type(self): BlockDevices = make_origin().BlockDevices error = self.assertRaises(TypeError, BlockDevices.read, random.randint(0, 100)) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__read_with_system_id(self): BlockDevices = make_origin().BlockDevices @@ -114,7 +114,7 @@ def test__create_bad_node_type(self): size=(4096 * 1024), block_size=512, ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__create_missing_size(self): BlockDevices = make_origin().BlockDevices @@ -127,7 +127,7 @@ def test__create_missing_size(self): serial="QEMU0001", block_size=512, ) - self.assertEquals("size must be provided and greater than zero.", str(error)) + self.assertEqual("size must be provided and greater than zero.", str(error)) def test__create_negative_size(self): BlockDevices = make_origin().BlockDevices @@ -141,7 +141,7 @@ def test__create_negative_size(self): size=-1, block_size=512, ) - self.assertEquals("size must be provided and greater than zero.", str(error)) + self.assertEqual("size must be provided and greater than zero.", str(error)) def test__create_missing_block_size(self): BlockDevices = make_origin().BlockDevices @@ -155,7 +155,7 @@ def test__create_missing_block_size(self): size=(4096 * 1024), block_size=None, ) - self.assertEquals( + self.assertEqual( "block_size must be provided and greater than zero.", str(error) ) @@ -171,7 +171,7 @@ def test__create_negative_block_size(self): size=(4096 * 1024), block_size=-1, ) - self.assertEquals( + self.assertEqual( "block_size must be provided and greater than zero.", str(error) ) @@ -185,7 +185,7 @@ def test__create_model_requires_serial(self): model="QEMU", size=(4096 * 1024), ) - self.assertEquals("serial must be provided when model is provided.", str(error)) + self.assertEqual("serial must be provided when model is provided.", str(error)) def test__create_serial_requires_model(self): BlockDevices = make_origin().BlockDevices @@ -197,7 +197,7 @@ def test__create_serial_requires_model(self): serial="QEMU0001", size=(4096 * 1024), ) - self.assertEquals("model must be provided when serial is provided.", str(error)) + self.assertEqual("model must be provided when serial is provided.", str(error)) def test__create_requires_model_and_serial_or_id_path(self): BlockDevices = make_origin().BlockDevices @@ -208,7 +208,7 @@ def test__create_requires_model_and_serial_or_id_path(self): "sda", size=(4096 * 1024), ) - self.assertEquals( + self.assertEqual( "Either model/serial is provided or id_path must be provided.", str(error) ) @@ -278,7 +278,7 @@ def test__read_bad_node_type(self): error = self.assertRaises( TypeError, BlockDevice.read, random.randint(0, 100), random.randint(0, 100) ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__read_with_system_id(self): BlockDevice = make_origin().BlockDevice diff --git a/maas/client/viscera/tests/test_boot_resources.py b/maas/client/viscera/tests/test_boot_resources.py index 796f6862..acd8ed84 100644 --- a/maas/client/viscera/tests/test_boot_resources.py +++ b/maas/client/viscera/tests/test_boot_resources.py @@ -153,21 +153,21 @@ def test__read(self): ] resources = BootResources.read() - self.assertEquals(2, len(resources)) + self.assertEqual(2, len(resources)) def test__start_import(self): BootResources = make_origin().BootResources import_action = getattr(BootResources._handler, "import") import_action.return_value = sentinel.result - self.assertEquals(sentinel.result, BootResources.start_import()) + self.assertEqual(sentinel.result, BootResources.start_import()) import_action.assert_called_once_with() def test__stop_import(self): BootResources = make_origin().BootResources BootResources._handler.stop_import.return_value = sentinel.result - self.assertEquals(sentinel.result, BootResources.stop_import()) + self.assertEqual(sentinel.result, BootResources.stop_import()) BootResources._handler.stop_import.assert_called_once_with() def test__create_raises_ValueError_when_name_missing_slash(self): @@ -175,7 +175,7 @@ def test__create_raises_ValueError_when_name_missing_slash(self): buf = io.BytesIO(b"") error = self.assertRaises(ValueError, BootResources.create, "", "", buf) - self.assertEquals("name must be in format os/release; missing '/'", str(error)) + self.assertEqual("name must be in format os/release; missing '/'", str(error)) def test__create_raises_ValueError_when_architecture_missing_slash(self): BootResources = make_origin().BootResources @@ -184,7 +184,7 @@ def test__create_raises_ValueError_when_architecture_missing_slash(self): error = self.assertRaises( ValueError, BootResources.create, "os/release", "", buf ) - self.assertEquals( + self.assertEqual( "architecture must be in format arch/subarch; missing '/'", str(error) ) @@ -196,7 +196,7 @@ def test__create_raises_ValueError_when_content_cannot_be_read(self): error = self.assertRaises( ValueError, BootResources.create, "os/release", "arch/subarch", buf ) - self.assertEquals("content must be readable", str(error)) + self.assertEqual("content must be readable", str(error)) def test__create_raises_ValueError_when_content_cannot_seek(self): BootResources = make_origin().BootResources @@ -206,7 +206,7 @@ def test__create_raises_ValueError_when_content_cannot_seek(self): error = self.assertRaises( ValueError, BootResources.create, "os/release", "arch/subarch", buf ) - self.assertEquals("content must be seekable", str(error)) + self.assertEqual("content must be seekable", str(error)) def test__create_raises_ValueError_when_chunk_size_is_zero(self): BootResources = make_origin().BootResources @@ -220,7 +220,7 @@ def test__create_raises_ValueError_when_chunk_size_is_zero(self): buf, chunk_size=0, ) - self.assertEquals("chunk_size must be greater than 0, not 0", str(error)) + self.assertEqual("chunk_size must be greater than 0, not 0", str(error)) def test__create_raises_ValueError_when_chunk_size_is_less_than_zero(self): BootResources = make_origin().BootResources @@ -234,7 +234,7 @@ def test__create_raises_ValueError_when_chunk_size_is_less_than_zero(self): buf, chunk_size=-1, ) - self.assertEquals("chunk_size must be greater than 0, not -1", str(error)) + self.assertEqual("chunk_size must be greater than 0, not -1", str(error)) def test__create_calls_create_on_handler_does_nothing_if_complete(self): resource_id = random.randint(0, 100) @@ -432,14 +432,14 @@ def test__create_uploads_in_chunks_and_reloads_resource(self): ) for i in range(0, len(data), chunk_size) ] - self.assertEquals(calls, put.call_args_list) + self.assertEqual(calls, put.call_args_list) # Check that progress handler was called on each chunk. calls = [ call(len(data[: chunk_size + i]) / len(data)) for i in range(0, len(data), chunk_size) ] - self.assertEquals(calls, progress_handler.call_args_list) + self.assertEqual(calls, progress_handler.call_args_list) def test__create_raises_CallError_on_chunk_upload_failure(self): resource_id = random.randint(0, 100) diff --git a/maas/client/viscera/tests/test_boot_source_selections.py b/maas/client/viscera/tests/test_boot_source_selections.py index 54370f75..615e6dc0 100644 --- a/maas/client/viscera/tests/test_boot_source_selections.py +++ b/maas/client/viscera/tests/test_boot_source_selections.py @@ -134,12 +134,12 @@ def test__read(self): ] selections = BootSourceSelections.read(source) - self.assertEquals(2, len(selections)) - self.assertEquals( + self.assertEqual(2, len(selections)) + self.assertEqual( origin.BootSource(source.id, {"bootsourceselection": selections[0]}), selections[0].boot_source, ) - self.assertEquals( + self.assertEqual( origin.BootSource(source.id, {"bootsourceselection": selections[1]}), selections[1].boot_source, ) diff --git a/maas/client/viscera/tests/test_boot_sources.py b/maas/client/viscera/tests/test_boot_sources.py index 943afc19..37d25c89 100644 --- a/maas/client/viscera/tests/test_boot_sources.py +++ b/maas/client/viscera/tests/test_boot_sources.py @@ -87,7 +87,7 @@ def test__read(self): ] sources = BootSources.read() - self.assertEquals(2, len(sources)) + self.assertEqual(2, len(sources)) def test__create_calls_create_with_keyring_filename(self): source_id = random.randint(0, 100) diff --git a/maas/client/viscera/tests/test_events.py b/maas/client/viscera/tests/test_events.py index db9512df..cc7e1142 100644 --- a/maas/client/viscera/tests/test_events.py +++ b/maas/client/viscera/tests/test_events.py @@ -12,7 +12,6 @@ from ...testing import make_mac_address, make_name_without_spaces, make_range, TestCase from ..testing import bind - event_ids = count(1) diff --git a/maas/client/viscera/tests/test_files.py b/maas/client/viscera/tests/test_files.py index 887ad34b..37709ff8 100644 --- a/maas/client/viscera/tests/test_files.py +++ b/maas/client/viscera/tests/test_files.py @@ -27,7 +27,7 @@ def test__read(self): origin.Files._handler.read.return_value = data resources = origin.Files.read() - self.assertEquals(2, len(resources)) + self.assertEqual(2, len(resources)) self.assertThat(resources, IsInstance(origin.Files)) self.assertThat(resources, AllMatch(IsInstance(origin.File))) self.assertThat( diff --git a/maas/client/viscera/tests/test_interfaces.py b/maas/client/viscera/tests/test_interfaces.py index 2eeabd87..5adc8281 100644 --- a/maas/client/viscera/tests/test_interfaces.py +++ b/maas/client/viscera/tests/test_interfaces.py @@ -54,7 +54,7 @@ class TestInterfaces(TestCase): def test__read_bad_node_type(self): Interfaces = make_origin().Interfaces error = self.assertRaises(TypeError, Interfaces.read, random.randint(0, 100)) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__read_with_system_id(self): Interfaces = make_origin().Interfaces @@ -95,7 +95,7 @@ def test__read_with_Node(self): def test__create_bad_node_type(self): Interfaces = make_origin().Interfaces error = self.assertRaises(TypeError, Interfaces.create, random.randint(0, 100)) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__create_bad_vlan_type(self): Interfaces = make_origin().Interfaces @@ -105,7 +105,7 @@ def test__create_bad_vlan_type(self): make_string_without_spaces(), vlan=make_string_without_spaces(), ) - self.assertEquals("vlan must be a Vlan or int, not str", str(error)) + self.assertEqual("vlan must be a Vlan or int, not str", str(error)) def test__create_bad_interface_type_type(self): Interfaces = make_origin().Interfaces @@ -115,16 +115,14 @@ def test__create_bad_interface_type_type(self): make_string_without_spaces(), interface_type=make_string_without_spaces(), ) - self.assertEquals( - "interface_type must be an InterfaceType, not str", str(error) - ) + self.assertEqual("interface_type must be an InterfaceType, not str", str(error)) def test__create_physical_requires_mac_address(self): Interfaces = make_origin().Interfaces error = self.assertRaises( ValueError, Interfaces.create, make_string_without_spaces() ) - self.assertEquals("mac_address required for physical interface", str(error)) + self.assertEqual("mac_address required for physical interface", str(error)) def test__create_physical_with_all_values(self): origin = make_origin() @@ -220,7 +218,7 @@ def test__create_bond_fails_with_parent(self): name=make_string_without_spaces(), parent=make_string_without_spaces(), ) - self.assertEquals("use parents not parent for bond interface", str(error)) + self.assertEqual("use parents not parent for bond interface", str(error)) def test__create_bond_fails_parents_not_iterable(self): Interfaces = make_origin().Interfaces @@ -232,7 +230,7 @@ def test__create_bond_fails_parents_not_iterable(self): name=make_string_without_spaces(), parents=random.randint(1, 20), ) - self.assertEquals("parents must be a iterable, not int", str(error)) + self.assertEqual("parents must be a iterable, not int", str(error)) def test__create_bond_fails_parents_is_not_Interface_or_int(self): Interfaces = make_origin().Interfaces @@ -244,7 +242,7 @@ def test__create_bond_fails_parents_is_not_Interface_or_int(self): name=make_string_without_spaces(), parents=[make_string_without_spaces()], ) - self.assertEquals("parent[0] must be an Interface or int, not str", str(error)) + self.assertEqual("parent[0] must be an Interface or int, not str", str(error)) def test__create_bond_fails_name_missing(self): Interfaces = make_origin().Interfaces @@ -255,7 +253,7 @@ def test__create_bond_fails_name_missing(self): InterfaceType.BOND, parents=[random.randint(1, 20)], ) - self.assertEquals("name is required for bond interface", str(error)) + self.assertEqual("name is required for bond interface", str(error)) def test__create_bond_with_all_values(self): origin = make_origin() @@ -395,7 +393,7 @@ def test__create_vlan_fails_with_parents(self): InterfaceType.VLAN, parents=[make_string_without_spaces()], ) - self.assertEquals("use parent not parents for VLAN interface", str(error)) + self.assertEqual("use parent not parents for VLAN interface", str(error)) def test__create_vlan_fails_without_parent(self): Interfaces = make_origin().Interfaces @@ -405,7 +403,7 @@ def test__create_vlan_fails_without_parent(self): make_string_without_spaces(), InterfaceType.VLAN, ) - self.assertEquals("parent is required for VLAN interface", str(error)) + self.assertEqual("parent is required for VLAN interface", str(error)) def test__create_vlan_fails_parent_wrong_type(self): Interfaces = make_origin().Interfaces @@ -416,7 +414,7 @@ def test__create_vlan_fails_parent_wrong_type(self): InterfaceType.VLAN, parent=make_string_without_spaces(), ) - self.assertEquals("parent must be an Interface or int, not str", str(error)) + self.assertEqual("parent must be an Interface or int, not str", str(error)) def test__create_vlan_fails_without_vlan(self): Interfaces = make_origin().Interfaces @@ -427,7 +425,7 @@ def test__create_vlan_fails_without_vlan(self): InterfaceType.VLAN, parent=random.randint(1, 10), ) - self.assertEquals("vlan is required for VLAN interface", str(error)) + self.assertEqual("vlan is required for VLAN interface", str(error)) def test__create_vlan_with_all_values(self): origin = make_origin() @@ -517,7 +515,7 @@ def test__create_bridge_fails_with_parents(self): InterfaceType.BRIDGE, parents=[make_string_without_spaces()], ) - self.assertEquals("use parent not parents for bridge interface", str(error)) + self.assertEqual("use parent not parents for bridge interface", str(error)) def test__create_bridge_fails_without_parent(self): Interfaces = make_origin().Interfaces @@ -527,7 +525,7 @@ def test__create_bridge_fails_without_parent(self): make_string_without_spaces(), InterfaceType.BRIDGE, ) - self.assertEquals("parent is required for bridge interface", str(error)) + self.assertEqual("parent is required for bridge interface", str(error)) def test__create_bridge_fails_parent_wrong_type(self): Interfaces = make_origin().Interfaces @@ -538,7 +536,7 @@ def test__create_bridge_fails_parent_wrong_type(self): InterfaceType.BRIDGE, parent=make_string_without_spaces(), ) - self.assertEquals("parent must be an Interface or int, not str", str(error)) + self.assertEqual("parent must be an Interface or int, not str", str(error)) def test__create_bridge_fails_missing_name(self): Interfaces = make_origin().Interfaces @@ -549,7 +547,7 @@ def test__create_bridge_fails_missing_name(self): InterfaceType.BRIDGE, parent=random.randint(1, 10), ) - self.assertEquals("name is required for bridge interface", str(error)) + self.assertEqual("name is required for bridge interface", str(error)) def test__create_bridge_with_all_values(self): origin = make_origin() @@ -664,7 +662,7 @@ def test__create_unknown_fails(self): make_string_without_spaces(), InterfaceType.UNKNOWN, ) - self.assertEquals( + self.assertEqual( "cannot create an interface of type: %s" % InterfaceType.UNKNOWN, str(error) ) @@ -679,7 +677,7 @@ def test__by_name(self): {"system_id": system_id, "id": random.randint(0, 100), "name": "eth1"} ) interfaces = Interfaces([eth0_Interface, eth1_Interface]) - self.assertEquals( + self.assertEqual( {"eth0": eth0_Interface, "eth1": eth1_Interface}, interfaces.by_name ) @@ -695,7 +693,7 @@ def test__get_by_name(self): ) interfaces = Interfaces([eth0_Interface, eth1_Interface]) eth0 = interfaces.get_by_name("eth0") - self.assertEquals(eth0, eth0_Interface) + self.assertEqual(eth0, eth0_Interface) class TestInterface(TestCase): @@ -741,7 +739,7 @@ def test__interface_read_TypeError(self): error = self.assertRaises( TypeError, Interface.read, random.randint(0, 100), random.randint(0, 100) ) - self.assertEquals("node must be a Node or str, not int", str(error)) + self.assertEqual("node must be a Node or str, not int", str(error)) def test__interface_save_tags(self): Interface = make_origin().Interface @@ -952,7 +950,7 @@ def test__interface_disconnect(self): Interface._handler.disconnect.assert_called_once_with( system_id=system_id, id=interface_data["id"] ) - self.assertEquals([], list(interface.links)) + self.assertEqual([], list(interface.links)) def test__interface_links_create_raises_TypeError_no_Interface(self): origin = make_origin() @@ -960,7 +958,7 @@ def test__interface_links_create_raises_TypeError_no_Interface(self): error = self.assertRaises( TypeError, InterfaceLinks.create, random.randint(0, 1000), LinkMode.AUTO ) - self.assertEquals("interface must be an Interface, not int", str(error)) + self.assertEqual("interface must be an Interface, not int", str(error)) def test__interface_links_create_raises_TypeError_no_LinkMode(self): origin = make_origin() @@ -971,7 +969,7 @@ def test__interface_links_create_raises_TypeError_no_LinkMode(self): error = self.assertRaises( TypeError, InterfaceLinks.create, interface, LinkMode.AUTO.value ) - self.assertEquals("mode must be a LinkMode, not str", str(error)) + self.assertEqual("mode must be a LinkMode, not str", str(error)) def test__interface_links_create_raises_TypeError_no_Subnet(self): origin = make_origin() @@ -986,7 +984,7 @@ def test__interface_links_create_raises_TypeError_no_Subnet(self): LinkMode.AUTO, subnet=make_string_without_spaces(), ) - self.assertEquals("subnet must be a Subnet or int, not str", str(error)) + self.assertEqual("subnet must be a Subnet or int, not str", str(error)) def test__interface_links_create_raises_ValueError_AUTO_no_Subnet(self): origin = make_origin() @@ -997,7 +995,7 @@ def test__interface_links_create_raises_ValueError_AUTO_no_Subnet(self): error = self.assertRaises( ValueError, InterfaceLinks.create, interface, LinkMode.AUTO ) - self.assertEquals("subnet is required for %s" % LinkMode.AUTO, str(error)) + self.assertEqual("subnet is required for %s" % LinkMode.AUTO, str(error)) def test__interface_links_create_raises_ValueError_STATIC_no_Subnet(self): origin = make_origin() @@ -1008,7 +1006,7 @@ def test__interface_links_create_raises_ValueError_STATIC_no_Subnet(self): error = self.assertRaises( ValueError, InterfaceLinks.create, interface, LinkMode.STATIC ) - self.assertEquals("subnet is required for %s" % LinkMode.STATIC, str(error)) + self.assertEqual("subnet is required for %s" % LinkMode.STATIC, str(error)) def test__interface_links_create_raises_ValueError_LINK_UP_gateway(self): origin = make_origin() @@ -1023,7 +1021,7 @@ def test__interface_links_create_raises_ValueError_LINK_UP_gateway(self): LinkMode.LINK_UP, default_gateway=True, ) - self.assertEquals( + self.assertEqual( "cannot set as default_gateway for %s" % LinkMode.LINK_UP, str(error) ) @@ -1040,7 +1038,7 @@ def test__interface_links_create_raises_ValueError_DHCP_gateway(self): LinkMode.DHCP, default_gateway=True, ) - self.assertEquals( + self.assertEqual( "cannot set as default_gateway for %s" % LinkMode.DHCP, str(error) ) diff --git a/maas/client/viscera/tests/test_ipranges.py b/maas/client/viscera/tests/test_ipranges.py index 5732da9f..dbdf360f 100644 --- a/maas/client/viscera/tests/test_ipranges.py +++ b/maas/client/viscera/tests/test_ipranges.py @@ -51,7 +51,7 @@ def test__ipranges_create_requires_IPRangeType(self): type=make_string_without_spaces(), comment=comment, ) - self.assertEquals("type must be an IPRangeType, not str", str(error)) + self.assertEqual("type must be an IPRangeType, not str", str(error)) def test__ipranges_read(self): """IPRanges.read() returns a list of IPRanges.""" diff --git a/maas/client/viscera/tests/test_machines.py b/maas/client/viscera/tests/test_machines.py index 62d97ad5..6a8e11f0 100644 --- a/maas/client/viscera/tests/test_machines.py +++ b/maas/client/viscera/tests/test_machines.py @@ -754,7 +754,7 @@ def test__query_power_state(self): machine._handler.query_power_state.return_value = query_data result = machine.query_power_state() self.assertIsInstance(result, PowerState) - self.assertEquals(PowerState.ON, result) + self.assertEqual(PowerState.ON, result) self.assertEqual(PowerState.ON, machine.power_state) def test__get_details(self): @@ -778,7 +778,7 @@ def test__get_details(self): machine.system_id, return_value=return_val ) data = machine.get_details() - self.assertItemsEqual(["lldp", "lshw"], data.keys()) + self.assertCountEqual(["lldp", "lshw"], data.keys()) lldp = ElementTree.fromstring(data["lldp"]) lshw = ElementTree.fromstring(data["lshw"]) assert IsInstance(lldp, ElementTree) diff --git a/maas/client/viscera/tests/test_vlans.py b/maas/client/viscera/tests/test_vlans.py index 750e7081..729b26a0 100644 --- a/maas/client/viscera/tests/test_vlans.py +++ b/maas/client/viscera/tests/test_vlans.py @@ -220,7 +220,7 @@ def test__vlan_update_relay_vlan_with_object(self): self.assertThat(vlan.relay_vlan.id, Equals(relay_vlan.id)) def test__vlan_update_relay_vlan_with_integer_id(self): - self.skip("see https://github.com/canonical/python-libmaas/issues/180") + self.skipTest("see https://github.com/canonical/python-libmaas/issues/180") origin = make_origin() Vlan = origin.Vlan Vlan._handler.params = ["fabric_id", "vid"] diff --git a/setup.py b/setup.py index 071f10e9..804321de 100644 --- a/setup.py +++ b/setup.py @@ -60,15 +60,6 @@ def read(filename): "PyYAML >= 3.11", "terminaltables >= 2.1.0", ], - test_suite="maas.client", - tests_require=[ - "django >= 2.2.4, < 3.0", - "fixtures >= 1.0.0", - "setuptools", - "testscenarios", - "testtools", - "Twisted<23.0.0", - ], description="A client API library specially for MAAS.", long_description=read('README'), long_description_content_type='text/markdown', diff --git a/tox.ini b/tox.ini index 485859e4..a53ba121 100644 --- a/tox.ini +++ b/tox.ini @@ -2,10 +2,27 @@ envlist = py3, lint, imports [testenv:py3] -commands = coverage run setup.py test {posargs} +commands = coverage run -m testtools.run discover -s maas -t . {posargs} sitepackages = False -deps = coverage - +skip_install = True +setenv = PYTHONPATH={toxinidir} +deps = + aiohttp >= 2.0.0 + argcomplete >= 1.0 + colorclass >= 1.2.0 + macaroonbakery >= 1.1.3 + oauthlib >= 1.0.3 + packaging >= 21.3 + pymongo >= 3.5.1 + pytz >= 2014.10 + PyYAML >= 3.11 + terminaltables >= 2.1.0 + coverage + Django >= 5.2, < 6 + fixtures + testscenarios + testtools + Twisted<23.0.0 [testenv:integrate] commands = {envpython} -m integrate {posargs} sitepackages = False @@ -19,13 +36,13 @@ deps = commands = black maas sitepackages = False skip_install = True -deps = black +deps = black==26.10.1 [testenv:lint] commands = black --check maas sitepackages = False skip_install = True -deps = black +deps = black==26.10.1 [testenv:imports] commands = {toxinidir}/scripts/check-imports From 5dc8b05a45f6898a1625887572ad5ebd208c8e44 Mon Sep 17 00:00:00 2001 From: Jacopo Rota Date: Tue, 1 Dec 2026 13:33:28 +0100 Subject: [PATCH 2/2] modernize project --- .github/workflows/ci.yml | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca33b927..863640e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,48 +10,51 @@ on: jobs: lint: - runs-on: ubuntu-20.04 + runs-on: ubuntu-26.04 steps: - name: Repository checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: - python-version: "3.6" + python-version: "3.10" - name: Install dependencies run: | - pip install --upgrade pip tox + python -m pip install --upgrade pip tox - name: Lint run: | tox -e lint test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-26.04 strategy: matrix: python-version: - - "3.6" - - "3.7" - - "3.8" - - "3.9" - "3.10" + - "3.11" + - "3.12" + - "3.13" + - "3.14" steps: - name: Repository checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v7 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - pip install --upgrade pip tox codecov + python -m pip install --upgrade pip tox - name: Test - run: | - tox -e py3 - codecov + run: tox -e py3 + + - name: Upload coverage + uses: codecov/codecov-action@v7 + with: + fail_ci_if_error: false