Skip to content

Commit 2446be0

Browse files
committed
Fix: version test.
1 parent d8ce6ac commit 2446be0

File tree

8 files changed

+22
-58
lines changed

8 files changed

+22
-58
lines changed

samples/v1/output.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Code generated by cmdcomp "2.1.0". DO NOT EDIT.
3+
# Code generated by cmdcomp "$CMDCOMP_VERSION". DO NOT EDIT.
44
# For more information about cmdcomp, please refer to https://github.com/yassun7010/cmdcomp .
55
#
66

samples/v1/output.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/zsh
22
#
3-
# Code generated by cmdcomp "2.1.0". DO NOT EDIT.
3+
# Code generated by cmdcomp "$CMDCOMP_VERSION". DO NOT EDIT.
44
# For more information about cmdcomp, please refer to https://github.com/yassun7010/cmdcomp .
55
#
66

samples/v2/output.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Code generated by cmdcomp "2.1.0". DO NOT EDIT.
3+
# Code generated by cmdcomp "$CMDCOMP_VERSION". DO NOT EDIT.
44
# For more information about cmdcomp, please refer to https://github.com/yassun7010/cmdcomp .
55
#
66

samples/v2/output.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/zsh
22
#
3-
# Code generated by cmdcomp "2.1.0". DO NOT EDIT.
3+
# Code generated by cmdcomp "$CMDCOMP_VERSION". DO NOT EDIT.
44
# For more information about cmdcomp, please refer to https://github.com/yassun7010/cmdcomp .
55
#
66

tests/test_cmdcomp.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import re
22

33
import pytest
4-
from pytest import CaptureFixture
54

6-
from cmdcomp import __version__
75
from cmdcomp.app import App
86
from cmdcomp.shell import ShellType
97
from tests.conftest import SAMPLES_DIR
@@ -15,7 +13,7 @@
1513
class TestApplication:
1614
def test_application(
1715
self,
18-
capsys: CaptureFixture,
16+
capsys: pytest.CaptureFixture,
1917
version: str,
2018
config_format: str,
2119
shell: ShellType,
@@ -29,14 +27,15 @@ def test_application(
2927
]
3028
)
3129

32-
assert capsys.readouterr().out == re.sub(
33-
r'\n# Code generated by cmdcomp ".*"\. DO NOT EDIT\.\n',
34-
f'\n# Code generated by cmdcomp "{__version__}". DO NOT EDIT.\n',
35-
open(SAMPLES_DIR / version / f"output.{str(shell.value)}").read(),
30+
assert mask_version(
31+
capsys.readouterr().out,
32+
) == mask_version(
33+
open(SAMPLES_DIR / version / f"output.{shell.value}").read(),
3634
)
3735

3836
def test_output_file_to_samples(
3937
self,
38+
capsys: pytest.CaptureFixture,
4039
version: str,
4140
config_format: str,
4241
shell: ShellType,
@@ -47,7 +46,17 @@ def test_output_file_to_samples(
4746
str(SAMPLES_DIR / version / f"config.cmdcomp.{config_format}"),
4847
"--shell-type",
4948
shell.value,
50-
"--output",
51-
str(SAMPLES_DIR / version / f"output.{shell.value}"),
5249
]
5350
)
51+
52+
with open(SAMPLES_DIR / version / f"output.{shell.value}", "w") as file:
53+
file.write(mask_version(capsys.readouterr().out))
54+
55+
56+
def mask_version(output: str) -> str:
57+
return re.sub(
58+
r'\n# Code generated by cmdcomp ".*"',
59+
r'\n# Code generated by cmdcomp "$CMDCOMP_VERSION"',
60+
output,
61+
count=1,
62+
)

tests/v2/__init__.py

Whitespace-only changes.

tests/v2/test_completion.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/v2/test_config.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)