Method: pylint.testutils.configuration_test.get_expected_or_default
Calls: 42, Exceptions: 0, Paths: 2Back
Path 1: 38 calls (0.9)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/functional/toml/toml_with_unknown_option.toml' (2) '/Users/andrehora/Document...
'result.json' (26) '2.out' (4) '4.out' (4) '1.out' (2) '0.out' (1) '8.out' (1)
'{}' (26) '' (12)
'{\n "functional_append": {\n "disable": ["logging-not-lazy", "logging-format-interpolation"]\n },\n "jobs": 10,\n "reports": true\n}\n' (5) '{...
1def get_expected_or_default(
2 tested_configuration_file: str | Path,
3 suffix: str,
4 default: str,
5) -> str:
6 """Return the expected value from the file if it exists, or the given default."""
7 expected = default
8 path = Path(tested_configuration_file)
9 expected_result_path = path.parent / f"{path.stem}.{suffix}"
10 if expected_result_path.exists():
11 with open(expected_result_path, encoding="utf8") as f:
12 expected = f.read()
13 # logging is helpful to realize your file is not taken into
14 # account after a misspelling of the file name. The output of the
15 # program is checked during the test so printing messes with the result.
16 logging.info("%s exists.", expected_result_path)
17 else:
18 logging.info("%s not found, using '%s'.", expected_result_path, default)
19 return expected
Path 2: 4 calls (0.1)
'/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests/config/functional/toml/toml_without_pylint.toml' (1) '/Users/andrehora/Documents/git...
'result.json' (4)
'{}' (4)
'{}' (4)
1def get_expected_or_default(
2 tested_configuration_file: str | Path,
3 suffix: str,
4 default: str,
5) -> str:
6 """Return the expected value from the file if it exists, or the given default."""
7 expected = default
8 path = Path(tested_configuration_file)
9 expected_result_path = path.parent / f"{path.stem}.{suffix}"
10 if expected_result_path.exists():
11 with open(expected_result_path, encoding="utf8") as f:
12 expected = f.read()
13 # logging is helpful to realize your file is not taken into
14 # account after a misspelling of the file name. The output of the
15 # program is checked during the test so printing messes with the result.
16 logging.info("%s exists.", expected_result_path)
17 else:
18 logging.info("%s not found, using '%s'.", expected_result_path, default)
19 return expected