Skip to content

Commit 671d01f

Browse files
committed
fix coverage scripts
1 parent d196b13 commit 671d01f

4 files changed

Lines changed: 78 additions & 23 deletions

File tree

CHANGES.md

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

33
## [1.2.3] - 2026-02-07
44

5-
Check dependencies.
5+
Update dependencies and coverage configuration.
66

77
### Changed
88

99
- Update dependencies.
10+
- Fix `test_cli.py`for coverage count.
1011
- Use `__all__` in project `__init__.py` files.
1112

1213
## [1.2.2] - 2025-10-11

pyproject.toml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ sciine = "asciinema_scene.sciine:cli"
3030

3131
[dependency-groups]
3232
dev = [
33-
"pytest>=8.4.2",
34-
"pytest-cov>=6.2.1",
35-
"coverage>=7.10.7",
33+
"pytest>=8.4.2,<9",
34+
"pytest-cov>=7.0.0",
35+
"coverage>=7.13.3",
3636
"deptry>=0.23.0",
3737
"mypy>=1.18.2",
3838
"mypy-extensions>=1.1.0",
3939
"typing-extensions>=4.15.0",
4040
"tox>=4.31.0",
4141
"tox-gh-actions>=3.4.0",
42-
"ruff>=0.14.0",
43-
"isort>=6.1.0",
42+
"ruff>=0.15.0",
43+
"isort>=7.0.0",
4444
]
4545

4646
[build-system]
@@ -110,13 +110,18 @@ lint.ignore = [
110110
[tool.ruff.lint.per-file-ignores]
111111
"tests/*" = ["S101"]
112112

113-
[tool.coverage.report]
114-
skip_empty = true
115-
116113
[tool.coverage.run]
114+
parallel = true
117115
branch = true
118116
source = ["asciinema_scene"]
119117

118+
[tool.coverage.report]
119+
skip_empty = true
120+
exclude_also = [
121+
"if TYPE_CHECKING:",
122+
'if __name__ == "__main__":'
123+
]
124+
120125
[tool.pytest.ini_options]
121126
minversion = "8.0"
122127
testpaths = ["tests"]

tests/test_cli.py

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import importlib.metadata
2+
import os
23
import re
34
import shlex
45
import subprocess
56
import sys
67
import time
78
from importlib import resources as rso
89

10+
import pytest
911
from click.testing import CliRunner
1012

1113
from asciinema_scene.sciine import cli
@@ -21,15 +23,26 @@
2123

2224

2325
def my_invoke(command: str, input_content: str):
24-
cmd = "sciine " + command
2526
if sys.platform == "win32":
26-
args = cmd
27+
args = [command]
2728
else:
28-
args = shlex.split(cmd)
29+
args = shlex.split(command)
30+
sciine_executable = os.path.join(sys.prefix, "bin", "sciine")
31+
coverage_command_prefix = [
32+
sys.executable,
33+
"-m",
34+
"coverage",
35+
"run",
36+
sciine_executable,
37+
]
38+
# full_command_args = shlex.split(command)
39+
cmd_to_execute = coverage_command_prefix + args
40+
env = os.environ.copy()
2941
proc = subprocess.Popen(
30-
args,
42+
cmd_to_execute,
3143
stdin=subprocess.PIPE,
3244
stdout=subprocess.PIPE,
45+
env=env,
3346
)
3447
proc.stdin.write(input_content.encode())
3548
proc.stdin.close()
@@ -71,6 +84,7 @@ def test_cli_help():
7184
assert re.search(text, result.output) is not None
7285

7386

87+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
7488
def test_cli_cut():
7589
code, output = my_invoke("cut -e 3.0", SHORT_FILE_CONTENT)
7690
assert code == 0
@@ -79,6 +93,7 @@ def test_cli_cut():
7993
assert "Duration: 3.023" in output2
8094

8195

96+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
8297
def test_cli_copy():
8398
code, output = my_invoke("copy -e 1.0", SHORT_FILE_CONTENT)
8499
assert code == 0
@@ -87,12 +102,14 @@ def test_cli_copy():
87102
assert "Duration: 1.163" in output2
88103

89104

105+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
90106
def test_cli_header():
91107
code, output = my_invoke("header", SHORT_FILE_CONTENT)
92108
assert code == 0
93109
assert "/bin/bash" in output
94110

95111

112+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
96113
def test_cli_include():
97114
code = output = None
98115
for file in rso.files("tests.files").iterdir():
@@ -109,6 +126,7 @@ def test_cli_include():
109126
assert "Duration: 12.271986" in output2
110127

111128

129+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
112130
def test_cli_insert():
113131
code, output = my_invoke("insert 1.0 5.0 message", SHORT_FILE_CONTENT)
114132
assert code == 0
@@ -117,6 +135,7 @@ def test_cli_insert():
117135
assert "Duration: 11.135993" in output2
118136

119137

138+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
120139
def test_cli_delete():
121140
code, output = my_invoke("delete 1.16", SHORT_FILE_CONTENT)
122141
assert code == 0
@@ -125,6 +144,7 @@ def test_cli_delete():
125144
assert "Duration: 5.835392" in output2
126145

127146

147+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
128148
def test_cli_replace():
129149
code, output = my_invoke("replace 1.16 abc", SHORT_FILE_CONTENT)
130150
assert code == 0
@@ -136,6 +156,7 @@ def test_cli_replace():
136156
assert "abc" in output3.strip()
137157

138158

159+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
139160
def test_cli_insert_o():
140161
code, output = my_invoke("insert 1.0 5.0 message o", SHORT_FILE_CONTENT)
141162
assert code == 0
@@ -144,6 +165,7 @@ def test_cli_insert_o():
144165
assert "Duration: 11.135993" in output2
145166

146167

168+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
147169
def test_cli_maximum():
148170
code, output = my_invoke("maximum 0.1", SHORT_FILE_CONTENT)
149171
assert code == 0
@@ -152,6 +174,7 @@ def test_cli_maximum():
152174
assert "Duration: 2.000" in output2
153175

154176

177+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
155178
def test_cli_minimum():
156179
code, output = my_invoke("minimum 10.0", SHORT_FILE_CONTENT)
157180
assert code == 0
@@ -160,6 +183,7 @@ def test_cli_minimum():
160183
assert "Duration: 210.000" in output2
161184

162185

186+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
163187
def test_cli_quantize():
164188
code, output = my_invoke("quantize 0.1 3.0 20.0", SHORT_FILE_CONTENT)
165189
assert code == 0
@@ -168,57 +192,66 @@ def test_cli_quantize():
168192
assert "Duration: 400.000" in output2
169193

170194

195+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
171196
def test_cli_show_1():
172197
code, output = my_invoke("show", SHORT_FILE_CONTENT)
173198
assert code == 0
174199
assert f"0.000│ 0.89│ 'e'{CR}" in output
175200

176201

202+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
177203
def test_cli_show_2():
178204
code, output = my_invoke("show --precise", SHORT_FILE_CONTENT)
179205
assert code == 0
180206
assert f"0.000000│ 0.894038│ 'e'{CR}" in output
181207

182208

209+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
183210
def test_cli_show_3():
184211
code, output = my_invoke("show --text", SHORT_FILE_CONTENT)
185212
assert code == 0
186213
assert "0.000│ 0.89│ e" in output
187214

188215

216+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
189217
def test_cli_show_4():
190218
code, output = my_invoke("show --text --precise", SHORT_FILE_CONTENT)
191219
assert code == 0
192220
assert f"0.000000│ 0.894038│ e{CR}" in output
193221

194222

223+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
195224
def test_cli_show_5():
196225
code, output = my_invoke("show --lines 2", SHORT_FILE_CONTENT)
197226
assert code == 0
198227
assert f"0.000│ 0.89│ 'e'{CR}" in output
199228

200229

230+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
201231
def test_cli_show_6():
202232
code, output = my_invoke("show -s 0.0", SHORT_FILE_CONTENT)
203233
assert code == 0
204234
assert f"0.000│ 0.89│ 'e'{CR}" in output
205235
assert len(output.strip().split(CR)) == 22
206236

207237

238+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
208239
def test_cli_show_7():
209240
code, output = my_invoke("show -s 1.0", SHORT_FILE_CONTENT)
210241
assert code == 0
211242
assert f"0.000│ 0.89│ 'e'{CR}" not in output
212243
assert len(output.strip().split(CR)) == 19
213244

214245

246+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
215247
def test_cli_show_8():
216248
code, output = my_invoke("show -s 1.0 -e 2.0", SHORT_FILE_CONTENT)
217249
assert code == 0
218250
assert f"0.000│ 0.89│ 'e'{CR}" not in output
219251
assert len(output.strip().split(CR)) == 3
220252

221253

254+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
222255
def test_cli_speed():
223256
code, output = my_invoke("speed 1.0", SHORT_FILE_CONTENT)
224257
assert code == 0
@@ -228,6 +261,7 @@ def test_cli_speed():
228261
assert "Duration: 6.135993" in output2
229262

230263

264+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
231265
def test_cli_text_delete():
232266
code, output = my_invoke("text-delete -s 1.0 {server}", BACK_FILE_CONTENT)
233267
assert code == 0
@@ -237,6 +271,7 @@ def test_cli_text_delete():
237271
assert "Frames: 6" in output2
238272

239273

274+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
240275
def test_cli_text_replace():
241276
code, output = my_invoke("text-replace -s 1.0 {server} box", BACK_FILE_CONTENT)
242277
assert code == 0
@@ -245,25 +280,39 @@ def test_cli_text_replace():
245280
assert result_cast.count("box") == 19
246281

247282

283+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
248284
def test_cli_text_merge():
249285
code, output = my_invoke("text-merge nothing", BACK_FILE_CONTENT)
250286
assert code == 0
251287
result_cast = output
252288
assert result_cast.count("server") == 25
253289

254290

291+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
255292
def test_cli_status():
256293
code, output = my_invoke("status", SHORT_FILE_CONTENT)
257294
assert code == 0
258295
assert "Duration: 6.135993" in output
259296

260297

298+
@pytest.mark.skipif(sys.platform == "win32", reason="not for windows")
261299
def test_timeout():
262-
command = "status"
300+
sciine_executable = os.path.join(sys.prefix, "bin", "sciine")
301+
coverage_command_prefix = [
302+
sys.executable,
303+
"-m",
304+
"coverage",
305+
"run",
306+
sciine_executable,
307+
]
308+
cmd_to_execute = coverage_command_prefix
309+
cmd_to_execute.append("status")
310+
env = os.environ.copy()
263311
proc = subprocess.Popen(
264-
shlex.split("sciine " + command),
312+
cmd_to_execute,
265313
stdin=subprocess.PIPE,
266314
stdout=subprocess.PIPE,
315+
env=env,
267316
)
268317
time.sleep(2)
269318
proc.stdin.close()

uv.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)