Update tests for stats chart without heading
This commit is contained in:
1 parent
86c00ae3f9
commit
bce8084306
2 files changed
+6
-17
No files matched your search
+1
-3
@@ -23,8 +23,7 @@ TIMESTAMPS = {"website": "2026-11-01T09:00:00Z", "scripts": "2026-11-05T14:30:00
|
||||
# scripts: Python 2000
|
||||
# Total 4000 -> Python 50.0% (25 blocks), HTML 37.5% (18), JavaScript 12.5% (6)
|
||||
STATS = (
|
||||
"## 📊 Languages\n"
|
||||
+ "█" * 25
|
||||
"█" * 25
|
||||
+ " Python 50.0%\\\n"
|
||||
+ "█" * 18
|
||||
+ " HTML 37.5%\\\n"
|
||||
@@ -104,7 +103,6 @@ def test_excluded_file_in_a_skipped_repo_does_not_lower_other_repos(gitea, monke
|
||||
assert pushed_readme(gitea) == (
|
||||
"# Hi there\n\n"
|
||||
"<!--LANG_STATS_START-->\n"
|
||||
"## 📊 Languages\n"
|
||||
+ "█" * 37
|
||||
+ " Python 75.0%\\\n"
|
||||
+ "█" * 12
|
||||
|
||||
+5
-14
@@ -174,33 +174,24 @@ def test_network_error_on_an_excluded_file_is_ignored(gitea, monkeypatch):
|
||||
|
||||
def test_markdown_lists_languages_largest_first_with_bars_and_percentages():
|
||||
# Python 75% -> 75/2 = 37 bar blocks; JavaScript 25% -> 25/2 = 12 blocks.
|
||||
# Lines are joined with a backslash (a markdown line break); the heading is
|
||||
# followed by a single newline and the last line has no trailing break
|
||||
# (regression tests for 95aaf91 and 57a5188).
|
||||
# Lines are joined with a backslash (a markdown line break) and the last
|
||||
# line has no trailing break (regression test for 57a5188).
|
||||
assert generate_markdown({"JavaScript": 250, "Python": 750}) == (
|
||||
"## 📊 Languages\n"
|
||||
+ "█" * 37
|
||||
+ " Python 75.0%\\\n"
|
||||
+ "█" * 12
|
||||
+ " JavaScript 25.0%"
|
||||
"█" * 37 + " Python 75.0%\\\n" + "█" * 12 + " JavaScript 25.0%"
|
||||
)
|
||||
|
||||
|
||||
def test_markdown_percentages_are_rounded_to_one_decimal():
|
||||
# Python 2/3 = 66.67% -> 66.7, 33 blocks; Lua 1/3 = 33.33% -> 33.3, 16 blocks.
|
||||
assert generate_markdown({"Python": 2, "Lua": 1}) == (
|
||||
"## 📊 Languages\n" + "█" * 33 + " Python 66.7%\\\n" + "█" * 16 + " Lua 33.3%"
|
||||
"█" * 33 + " Python 66.7%\\\n" + "█" * 16 + " Lua 33.3%"
|
||||
)
|
||||
|
||||
|
||||
def test_markdown_leaves_out_languages_with_zero_bytes():
|
||||
# e.g. every HTML byte came from excluded files
|
||||
assert generate_markdown({"Python": 750, "JavaScript": 250, "HTML": 0}) == (
|
||||
"## 📊 Languages\n"
|
||||
+ "█" * 37
|
||||
+ " Python 75.0%\\\n"
|
||||
+ "█" * 12
|
||||
+ " JavaScript 25.0%"
|
||||
"█" * 37 + " Python 75.0%\\\n" + "█" * 12 + " JavaScript 25.0%"
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user