1 |
commit: a52b27e86680331abdc12f48ea50bc7d1080445f |
2 |
Author: David Palao <david.palao <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri Sep 9 18:35:17 2022 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 25 19:07:52 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a52b27e8 |
7 |
|
8 |
chore(style): some minor stylistic issues |
9 |
|
10 |
* replaced printf-style string with f-string, and |
11 |
* code passed through pylint and black |
12 |
|
13 |
Signed-off-by: David Palao <david.palao <AT> gmail.com> |
14 |
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org> |
15 |
|
16 |
lib/portage/dbapi/bintree.py | 6 +-- |
17 |
lib/portage/tests/dbapi/test_bintree.py | 68 +++++++++++++++++++++------------ |
18 |
2 files changed, 47 insertions(+), 27 deletions(-) |
19 |
|
20 |
diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py |
21 |
index 28b3c481b..cea9378d5 100644 |
22 |
--- a/lib/portage/dbapi/bintree.py |
23 |
+++ b/lib/portage/dbapi/bintree.py |
24 |
@@ -866,9 +866,9 @@ class binarytree: |
25 |
if not self._binrepos_conf: |
26 |
writemsg( |
27 |
_( |
28 |
- "!!! %s is missing (or PORTAGE_BINHOST is unset), but use is requested.\n" |
29 |
- ) |
30 |
- % (config_path,), |
31 |
+ f"!!! {config_path} is missing (or PORTAGE_BINHOST is unset), " |
32 |
+ "but use is requested.\n" |
33 |
+ ), |
34 |
noiselevel=-1, |
35 |
) |
36 |
else: |
37 |
|
38 |
diff --git a/lib/portage/tests/dbapi/test_bintree.py b/lib/portage/tests/dbapi/test_bintree.py |
39 |
index d0bfa306e..881d8ff48 100644 |
40 |
--- a/lib/portage/tests/dbapi/test_bintree.py |
41 |
+++ b/lib/portage/tests/dbapi/test_bintree.py |
42 |
@@ -30,25 +30,44 @@ class BinarytreeTestCase(TestCase): |
43 |
# Quite smoky test. What would it be a better testing strategy? |
44 |
# Not sure yet... |
45 |
required_attrs_no_multi_instance = { |
46 |
- "pkgdir", "_multi_instance", "dbapi", "update_ents", |
47 |
- "move_slot_ent", "populated", "tree", "_binrepos_conf", |
48 |
- "_remote_has_index", "_remotepkgs", "_additional_pkgs", |
49 |
- "invalids", "settings", "_pkg_paths", "_populating", |
50 |
- "_all_directory", "_pkgindex_version", "_pkgindex_hashes", |
51 |
- "_pkgindex_file", "_pkgindex_keys", "_pkgindex_aux_keys", |
52 |
- "_pkgindex_use_evaluated_keys", "_pkgindex_header", |
53 |
- "_pkgindex_header_keys", "_pkgindex_default_pkg_data", |
54 |
- "_pkgindex_inherited_keys", "_pkgindex_default_header_data", |
55 |
- "_pkgindex_translated_keys", "_pkgindex_allowed_pkg_keys", |
56 |
+ "pkgdir", |
57 |
+ "_multi_instance", |
58 |
+ "dbapi", |
59 |
+ "update_ents", |
60 |
+ "move_slot_ent", |
61 |
+ "populated", |
62 |
+ "tree", |
63 |
+ "_binrepos_conf", |
64 |
+ "_remote_has_index", |
65 |
+ "_remotepkgs", |
66 |
+ "_additional_pkgs", |
67 |
+ "invalids", |
68 |
+ "settings", |
69 |
+ "_pkg_paths", |
70 |
+ "_populating", |
71 |
+ "_all_directory", |
72 |
+ "_pkgindex_version", |
73 |
+ "_pkgindex_hashes", |
74 |
+ "_pkgindex_file", |
75 |
+ "_pkgindex_keys", |
76 |
+ "_pkgindex_aux_keys", |
77 |
+ "_pkgindex_use_evaluated_keys", |
78 |
+ "_pkgindex_header", |
79 |
+ "_pkgindex_header_keys", |
80 |
+ "_pkgindex_default_pkg_data", |
81 |
+ "_pkgindex_inherited_keys", |
82 |
+ "_pkgindex_default_header_data", |
83 |
+ "_pkgindex_translated_keys", |
84 |
+ "_pkgindex_allowed_pkg_keys", |
85 |
} |
86 |
no_multi_instance_settings = MagicMock() |
87 |
no_multi_instance_settings.features = "" |
88 |
no_multi_instance_bt = binarytree( |
89 |
- pkgdir="/tmp", settings=no_multi_instance_settings) |
90 |
+ pkgdir="/tmp", settings=no_multi_instance_settings |
91 |
+ ) |
92 |
multi_instance_settings = MagicMock() |
93 |
multi_instance_settings.features = "binpkg-multi-instance" |
94 |
- multi_instance_bt = binarytree( |
95 |
- pkgdir="/tmp", settings=multi_instance_settings) |
96 |
+ multi_instance_bt = binarytree(pkgdir="/tmp", settings=multi_instance_settings) |
97 |
for attr in required_attrs_no_multi_instance: |
98 |
getattr(no_multi_instance_bt, attr) |
99 |
getattr(multi_instance_bt, attr) |
100 |
@@ -57,8 +76,7 @@ class BinarytreeTestCase(TestCase): |
101 |
getattr(multi_instance_bt, "_allocate_filename") |
102 |
|
103 |
@patch("portage.dbapi.bintree.binarytree._populate_local") |
104 |
- def test_populate_without_updates_repos_nor_getbinspkgs( |
105 |
- self, ppopulate_local): |
106 |
+ def test_populate_without_updates_repos_nor_getbinspkgs(self, ppopulate_local): |
107 |
bt = binarytree(pkgdir="/tmp", settings=MagicMock()) |
108 |
ppopulate_local.return_value = {} |
109 |
bt.populate() |
110 |
@@ -67,8 +85,7 @@ class BinarytreeTestCase(TestCase): |
111 |
self.assertTrue(bt.populated) |
112 |
|
113 |
@patch("portage.dbapi.bintree.binarytree._populate_local") |
114 |
- def test_populate_calls_twice_populate_local_if_updates( |
115 |
- self, ppopulate_local): |
116 |
+ def test_populate_calls_twice_populate_local_if_updates(self, ppopulate_local): |
117 |
bt = binarytree(pkgdir="/tmp", settings=MagicMock()) |
118 |
bt.populate() |
119 |
self.assertIn(call(reindex=True), ppopulate_local.mock_calls) |
120 |
@@ -77,8 +94,7 @@ class BinarytreeTestCase(TestCase): |
121 |
|
122 |
@patch("portage.dbapi.bintree.binarytree._populate_additional") |
123 |
@patch("portage.dbapi.bintree.binarytree._populate_local") |
124 |
- def test_populate_with_repos( |
125 |
- self, ppopulate_local, ppopulate_additional): |
126 |
+ def test_populate_with_repos(self, ppopulate_local, ppopulate_additional): |
127 |
repos = ("one", "two") |
128 |
bt = binarytree(pkgdir="/tmp", settings=MagicMock()) |
129 |
bt.populate(add_repos=repos) |
130 |
@@ -88,7 +104,8 @@ class BinarytreeTestCase(TestCase): |
131 |
@patch("portage.dbapi.bintree.binarytree._populate_remote") |
132 |
@patch("portage.dbapi.bintree.binarytree._populate_local") |
133 |
def test_populate_with_getbinpkgs( |
134 |
- self, ppopulate_local, ppopulate_remote, pBinRepoConfigLoader): |
135 |
+ self, ppopulate_local, ppopulate_remote, pBinRepoConfigLoader |
136 |
+ ): |
137 |
refresh = "something" |
138 |
settings = MagicMock() |
139 |
settings.__getitem__.return_value = "/some/path" |
140 |
@@ -101,8 +118,8 @@ class BinarytreeTestCase(TestCase): |
141 |
@patch("portage.dbapi.bintree.binarytree._populate_remote") |
142 |
@patch("portage.dbapi.bintree.binarytree._populate_local") |
143 |
def test_populate_with_getbinpkgs_and_not_BinRepoConfigLoader( |
144 |
- self, ppopulate_local, ppopulate_remote, pBinRepoConfigLoader, |
145 |
- pwritemsg): |
146 |
+ self, ppopulate_local, ppopulate_remote, pBinRepoConfigLoader, pwritemsg |
147 |
+ ): |
148 |
refresh = "something" |
149 |
settings = MagicMock() |
150 |
portage_root = "/some/path" |
151 |
@@ -113,6 +130,9 @@ class BinarytreeTestCase(TestCase): |
152 |
bt.populate(getbinpkgs=True, getbinpkg_refresh=refresh) |
153 |
ppopulate_remote.assert_not_called() |
154 |
pwritemsg.assert_called_once_with( |
155 |
- _(f"!!! {conf_file} is missing (or PORTAGE_BINHOST is unset)" |
156 |
- ", but use is requested.\n"), noiselevel=-1 |
157 |
+ _( |
158 |
+ f"!!! {conf_file} is missing (or PORTAGE_BINHOST is unset)" |
159 |
+ ", but use is requested.\n" |
160 |
+ ), |
161 |
+ noiselevel=-1, |
162 |
) |