Skip to content

Commit bd7ad6a

Browse files
authored
Test and code improvements (#19396)
* some unittests * wip * wip * dead test * new test
1 parent e6d0877 commit bd7ad6a

File tree

111 files changed

+499
-498
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+499
-498
lines changed

conan/api/output.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,17 @@ def set_output_level(cls, level):
135135
@classmethod
136136
def valid_log_levels(cls):
137137
return {"quiet": LEVEL_QUIET, # -vquiet 80
138-
"error": LEVEL_ERROR, # -verror 70
139-
"warning": LEVEL_WARNING, # -vwaring 60
140-
"notice": LEVEL_NOTICE, # -vnotice 50
141-
"status": LEVEL_STATUS, # -vstatus 40
142-
None: LEVEL_VERBOSE, # -v 30
143-
"verbose": LEVEL_VERBOSE, # -vverbose 30
144-
"debug": LEVEL_DEBUG, # -vdebug 20
145-
"v": LEVEL_DEBUG, # -vv 20
146-
"trace": LEVEL_TRACE, # -vtrace 10
147-
"vv": LEVEL_TRACE # -vvv 10
148-
}
138+
"error": LEVEL_ERROR, # -verror 70
139+
"warning": LEVEL_WARNING, # -vwaring 60
140+
"notice": LEVEL_NOTICE, # -vnotice 50
141+
"status": LEVEL_STATUS, # -vstatus 40
142+
None: LEVEL_VERBOSE, # -v 30
143+
"verbose": LEVEL_VERBOSE, # -vverbose 30
144+
"debug": LEVEL_DEBUG, # -vdebug 20
145+
"v": LEVEL_DEBUG, # -vv 20
146+
"trace": LEVEL_TRACE, # -vtrace 10
147+
"vv": LEVEL_TRACE # -vvv 10
148+
}
149149

150150
@classmethod
151151
def define_log_level(cls, v):

conan/cli/args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def common_graph_args(subparser):
133133
subparser.add_argument("--requires", action="append",
134134
help='Directly provide requires instead of a conanfile')
135135
subparser.add_argument("--tool-requires", action='append',
136-
help='Directly provide tool-requires instead of a conanfile')
136+
help='Directly provide tool-requires instead of a conanfile')
137137
add_reference_args(subparser)
138138
add_lockfile_args(subparser)
139139

conan/cli/commands/cache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from conan.api.conan_api import ConanAPI
44
from conan.api.model import ListPattern, MultiPackagesList
5-
from conan.api.output import cli_out_write, ConanOutput
5+
from conan.api.output import cli_out_write
66
from conan.cli import make_abs_path
77
from conan.cli.command import conan_command, conan_subcommand, OnceArgument
88
from conan.cli.commands.list import print_list_text, print_list_json
@@ -125,6 +125,7 @@ def print_list_check_integrity_json(data):
125125
myjson = json.dumps(results, indent=4)
126126
cli_out_write(myjson)
127127

128+
128129
@conan_subcommand(formatters={"text": lambda _: (),
129130
"json": print_list_check_integrity_json})
130131
def cache_check_integrity(conan_api: ConanAPI, parser, subparser, *args):

conan/cli/commands/remove.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def confirmation(message):
103103
result.add_ref(ref)
104104
result.recipe_dict(ref).update(ref_dict) # it doesn't contain "packages"
105105
else:
106-
if not packages: # weird, there is inner package-ids but without prevs
106+
if not packages: # weird, there is inner package-ids but without prevs
107107
ConanOutput().info(f"No binaries to remove for '{ref.repr_notime()}'")
108108
continue
109109
for pref, pkg_id_info in packages.items():

conan/cli/commands/report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from conan.cli.command import conan_command, conan_subcommand
66

77

8-
98
@conan_command(group="Security")
109
def report(conan_api: ConanAPI, parser, *args):
1110
"""
@@ -40,7 +39,7 @@ def report_diff(conan_api, parser, subparser, *args):
4039
subparser.add_argument("-nr", "--new-reference", help=ref_help.format(type="New"), required=True)
4140

4241
subparser.add_argument("-r", "--remote", action="append", default=None,
43-
help='Look in the specified remote or remotes server')
42+
help='Look in the specified remote or remotes server')
4443

4544
args = parser.parse_args(*args)
4645

conan/cli/commands/workspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def _install_build(conan_api: ConanAPI, parser, subparser, build, *args):
193193
ws_pkg = all_editables.get(ref)
194194
is_editable = package["binary"] in ("Editable", "EditableBuild")
195195
if ws_pkg is None:
196-
if is_editable or package["binary"] == "Build": # Build external to Workspace
196+
if is_editable or package["binary"] == "Build": # Build extern to Workspace
197197
cmd = f'install {package["build_args"]} {profile_args}'
198198
ConanOutput().box(f"Workspace building external {ref}")
199199
ConanOutput().info(f"Command: {cmd}\n")

conan/cli/formatters/audit/vulnerabilities.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def wrap_and_indent(txt, limit=80, indent=2):
142142
"through patches applied in the recipe.\nTo verify if a patch has been applied, check the recipe in Conan Center.\n",
143143
fg=Color.BRIGHT_YELLOW)
144144

145-
if total_vulns > 0 or not "error" in result:
145+
if total_vulns > 0 or "error" not in result:
146146
cli_out_write("\nVulnerability information provided by JFrog Catalog. Check "
147147
"https://audit.conan.io/jfrogcuration for more information.\n",
148148
fg=Color.BRIGHT_GREEN)
@@ -326,7 +326,8 @@ def html_vuln_formatter(result):
326326
for ref, pkg_info in result["data"].items():
327327
edges = pkg_info.get("vulnerabilities", {}).get("edges", [])
328328
if not edges:
329-
description = "No vulnerabilities found." if not "error" in pkg_info else pkg_info["error"].get("details", "")
329+
description = "No vulnerabilities found." if "error" not in pkg_info \
330+
else pkg_info["error"].get("details", "")
330331
vulns.append({
331332
"package": ref,
332333
"vuln_id": "-",

conan/internal/api/config/config_installer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _process_download(config, cache_folder, requester):
177177
raise ConanException("Error while installing config from %s\n%s" % (config.uri, str(e)))
178178

179179

180-
class _ConfigOrigin(object):
180+
class _ConfigOrigin:
181181
def __init__(self, uri, config_type, verify_ssl, args, source_folder, target_folder):
182182
if config_type:
183183
self.type = config_type

conan/internal/api/detect/detect_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,8 @@ def _cc_compiler(compiler_exe="cc"):
488488
compiler = "clang" if "clang" in out else "gcc"
489489
# clang and gcc have version after a space, first try to find that to skip extra numbers
490490
# that might appear in the first line of the output before the version
491-
# There might also be a leading parenthesis that contains build information, so we try to skip it
491+
# There might also be a leading parenthesis that contains build information,
492+
# so we try to skip it
492493
installed_version = re.search(r"(?:\(.*\))? ([0-9]+(\.[0-9]+)*)", out)
493494
# Fallback to the first number we find optionally followed by other version fields
494495
installed_version = installed_version or re.search(r"([0-9]+(\.[0-9]+)*)", out)
@@ -532,7 +533,7 @@ def detect_intel_compiler(compiler_exe="icx"):
532533
try:
533534
ret, out = detect_runner(f'"{compiler_exe}" --version')
534535
if ret != 0:
535-
return None, None
536+
return None, None, None
536537
compiler = "intel-cc"
537538
installed_version = re.search(r"(202[0-9]+(\.[0-9])?)", out).group()
538539
if installed_version:

conan/internal/api/profile/profile_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def __init__(self, text):
221221
raise ConanException("Error while parsing line %i: '%s'" % (counter, line))
222222

223223

224-
class _ProfileValueParser(object):
224+
class _ProfileValueParser:
225225
""" parses a "pure" or "effective" profile, with no includes, no variables,
226226
as the one in the lockfiles, or once these things have been processed by ProfileParser
227227
"""

0 commit comments

Comments
 (0)