Skip to content

Commit 40ed6e4

Browse files
committed
try fix win shell tests for coverage
1 parent 54e9d28 commit 40ed6e4

File tree

4 files changed

+27
-27
lines changed

4 files changed

+27
-27
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ jobs:
659659
- name: Run Powershell Tab Completion Tests
660660
run: |
661661
just test ./tests/verify_environment.py
662+
call .venv\Scripts\activate; cmd /c "pytest --cov-append ./tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_powershell"
662663
just test-powershell
663664
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
664665
shell: powershell
@@ -727,6 +728,7 @@ jobs:
727728
- name: Run Powershell Tab Completion Tests
728729
run: |
729730
just test ./tests/verify_environment.py
731+
call .venv\Scripts\activate; cmd /c "pytest --cov-append ./tests/shellcompletion/test_shell_resolution.py::TestShellResolution::test_pwsh"
730732
just test-pwsh
731733
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
732734
shell: powershell

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,14 @@ command_line = "-m pytest --cov=django_typer"
143143

144144
[tool.coverage.paths]
145145
source = [
146-
"django_typer"
146+
"src/django_typer"
147147
]
148148

149149
[tool.pyright]
150150
exclude = ["tests/**/*"]
151151
include = [
152-
"src/django_typer"
152+
"src/django_typer",
153+
"*/site-packages/django_typer"
153154
]
154155

155156
[tool.ruff]

src/django_typer/apps.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,25 @@ def check_traceback_config(app_configs, **kwargs) -> t.List[CheckMessage]:
3030
warnings: t.List[CheckMessage] = []
3131
if use_rich_tracebacks():
3232
tb_config = traceback_config()
33-
try:
34-
from rich import traceback # pyright: ignore[reportMissingImports]
33+
from rich import traceback # pyright: ignore[reportMissingImports]
3534

36-
expected = {
37-
"no_install",
38-
"short",
39-
*inspect.signature(traceback.install).parameters.keys(),
40-
}
41-
unexpected = set(tb_config.keys()) - expected
42-
if unexpected:
43-
warnings.append(
44-
CheckWarning(
45-
"DT_RICH_TRACEBACK_CONFIG",
46-
hint="Unexpected parameters encountered: {keys}.".format(
47-
keys=", ".join(unexpected)
48-
),
49-
obj=settings.SETTINGS_MODULE,
50-
id="django_typer.W001",
51-
)
35+
expected = {
36+
"no_install",
37+
"short",
38+
*inspect.signature(traceback.install).parameters.keys(),
39+
}
40+
unexpected = set(tb_config.keys()) - expected
41+
if unexpected:
42+
warnings.append(
43+
CheckWarning(
44+
"DT_RICH_TRACEBACK_CONFIG",
45+
hint="Unexpected parameters encountered: {keys}.".format(
46+
keys=", ".join(unexpected)
47+
),
48+
obj=settings.SETTINGS_MODULE,
49+
id="django_typer.W001",
5250
)
53-
except ImportError:
54-
pass
51+
)
5552
return warnings
5653

5754

tests/test_tracebacks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def test_default_traceback(self):
1919
]
2020
self.assertIn("Traceback (most recent call last)", result)
2121
self.assertIn("Exception: This is a test exception", result)
22-
if rich_installed:
22+
if self.rich_installed:
2323
self.assertIn("────────", result)
2424
# locals should not be present
2525
self.assertNotIn("name = 'me'", result)
@@ -54,7 +54,7 @@ def test_tb_command_overrides(self):
5454
)[1]
5555
self.assertIn("Traceback (most recent call last)", result)
5656
self.assertIn("Exception: This is a test exception", result)
57-
if rich_installed:
57+
if self.rich_installed:
5858
self.assertIn("────────", result)
5959
# locals should be present
6060
self.assertIn("name = 'me'", result)
@@ -114,7 +114,7 @@ def test_traceback_set_to_false(self):
114114
@override_settings(DT_RICH_TRACEBACK_CONFIG=True)
115115
def test_traceback_set_to_true(self):
116116
self.assertEqual(traceback_config(), {"show_locals": False})
117-
self.assertIs(use_rich_tracebacks(), rich_installed)
117+
self.assertIs(use_rich_tracebacks(), self.rich_installed)
118118

119119
@override_settings(DT_RICH_TRACEBACK_CONFIG=None)
120120
def test_traceback_set_to_none(self):
@@ -156,7 +156,7 @@ def test_traceback_no_locals_short_false(self):
156156
)[1]
157157
self.assertIn("Traceback (most recent call last)", result)
158158
self.assertIn("Exception: This is a test exception", result)
159-
if rich_installed:
159+
if self.rich_installed:
160160
self.assertIn("────────", result)
161161
self.assertGreater(len(re.findall(r"\.py:\d+", result) or []), 0)
162162

@@ -199,7 +199,7 @@ def test_colored_traceback(self):
199199
result = run_command(
200200
"test_command1", "--force-color", "delete", "Brian", "--throw"
201201
)[1]
202-
if rich_installed:
202+
if self.rich_installed:
203203
self.assertIn("\x1b", result)
204204

205205
result = run_command(

0 commit comments

Comments
 (0)