4
4
from pathlib import Path
5
5
from typing import TYPE_CHECKING
6
6
7
+ import pytest
7
8
from click .testing import CliRunner
8
9
9
10
from deptry .cli import deptry
11
+ from tests .functional .utils import Project
10
12
from tests .utils import get_issues_report , stylize
11
13
12
14
if TYPE_CHECKING :
13
15
from tests .utils import PoetryVenvFactory
14
16
15
17
18
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
16
19
def test_cli_returns_error (poetry_venv_factory : PoetryVenvFactory ) -> None :
17
- with poetry_venv_factory ("example_project" ) as virtual_env :
20
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
18
21
issue_report = f"{ uuid .uuid4 ()} .json"
19
22
result = virtual_env .run (f"deptry . -o { issue_report } " )
20
23
@@ -71,8 +74,9 @@ def test_cli_returns_error(poetry_venv_factory: PoetryVenvFactory) -> None:
71
74
]
72
75
73
76
77
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
74
78
def test_cli_ignore_notebooks (poetry_venv_factory : PoetryVenvFactory ) -> None :
75
- with poetry_venv_factory ("example_project" ) as virtual_env :
79
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
76
80
issue_report = f"{ uuid .uuid4 ()} .json"
77
81
result = virtual_env .run (f"deptry . --ignore-notebooks -o { issue_report } " )
78
82
@@ -141,22 +145,25 @@ def test_cli_ignore_notebooks(poetry_venv_factory: PoetryVenvFactory) -> None:
141
145
]
142
146
143
147
148
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
144
149
def test_cli_ignore_flags (poetry_venv_factory : PoetryVenvFactory ) -> None :
145
- with poetry_venv_factory ("example_project" ) as virtual_env :
150
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
146
151
result = virtual_env .run ("deptry . --per-rule-ignores DEP002=isort|pkginfo|requests -im white -id black" )
147
152
148
153
assert result .returncode == 0
149
154
150
155
156
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
151
157
def test_cli_ignore_flag (poetry_venv_factory : PoetryVenvFactory ) -> None :
152
- with poetry_venv_factory ("example_project" ) as virtual_env :
158
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
153
159
result = virtual_env .run ("deptry . --ignore DEP001,DEP002,DEP003,DEP004" )
154
160
155
161
assert result .returncode == 0
156
162
157
163
164
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
158
165
def test_cli_exclude (poetry_venv_factory : PoetryVenvFactory ) -> None :
159
- with poetry_venv_factory ("example_project" ) as virtual_env :
166
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
160
167
issue_report = f"{ uuid .uuid4 ()} .json"
161
168
result = virtual_env .run (f"deptry . --exclude src/notebook.ipynb -o { issue_report } " )
162
169
@@ -225,8 +232,9 @@ def test_cli_exclude(poetry_venv_factory: PoetryVenvFactory) -> None:
225
232
]
226
233
227
234
235
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
228
236
def test_cli_extend_exclude (poetry_venv_factory : PoetryVenvFactory ) -> None :
229
- with poetry_venv_factory ("example_project" ) as virtual_env :
237
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
230
238
issue_report = f"{ uuid .uuid4 ()} .json"
231
239
result = virtual_env .run (f"deptry . -ee src/notebook.ipynb -o { issue_report } " )
232
240
@@ -295,8 +303,9 @@ def test_cli_extend_exclude(poetry_venv_factory: PoetryVenvFactory) -> None:
295
303
]
296
304
297
305
306
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
298
307
def test_cli_known_first_party (poetry_venv_factory : PoetryVenvFactory ) -> None :
299
- with poetry_venv_factory ("example_project" ) as virtual_env :
308
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
300
309
issue_report = f"{ uuid .uuid4 ()} .json"
301
310
result = virtual_env .run (f"deptry . --known-first-party white -o { issue_report } " )
302
311
@@ -341,8 +350,9 @@ def test_cli_known_first_party(poetry_venv_factory: PoetryVenvFactory) -> None:
341
350
]
342
351
343
352
353
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
344
354
def test_cli_not_verbose (poetry_venv_factory : PoetryVenvFactory ) -> None :
345
- with poetry_venv_factory ("example_project" ) as virtual_env :
355
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
346
356
issue_report = f"{ uuid .uuid4 ()} .json"
347
357
result = virtual_env .run (f"deptry . -o { issue_report } " )
348
358
@@ -400,8 +410,9 @@ def test_cli_not_verbose(poetry_venv_factory: PoetryVenvFactory) -> None:
400
410
]
401
411
402
412
413
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
403
414
def test_cli_verbose (poetry_venv_factory : PoetryVenvFactory ) -> None :
404
- with poetry_venv_factory ("example_project" ) as virtual_env :
415
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
405
416
issue_report = f"{ uuid .uuid4 ()} .json"
406
417
result = virtual_env .run (f"deptry . --verbose -o { issue_report } " )
407
418
@@ -459,8 +470,9 @@ def test_cli_verbose(poetry_venv_factory: PoetryVenvFactory) -> None:
459
470
]
460
471
461
472
473
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
462
474
def test_cli_with_no_ansi (poetry_venv_factory : PoetryVenvFactory ) -> None :
463
- with poetry_venv_factory ("example_project" ) as virtual_env :
475
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
464
476
result = virtual_env .run ("deptry . --no-ansi" )
465
477
466
478
expected_output = [
@@ -480,8 +492,9 @@ def test_cli_with_no_ansi(poetry_venv_factory: PoetryVenvFactory) -> None:
480
492
assert result .stderr == "\n " .join (expected_output )
481
493
482
494
495
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
483
496
def test_cli_with_not_json_output (poetry_venv_factory : PoetryVenvFactory ) -> None :
484
- with poetry_venv_factory ("example_project" ) as virtual_env :
497
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
485
498
json_files_count = len (list (Path ().glob ("*.json" )))
486
499
487
500
result = virtual_env .run ("deptry ." )
@@ -521,8 +534,9 @@ def test_cli_with_not_json_output(poetry_venv_factory: PoetryVenvFactory) -> Non
521
534
assert result .stderr == "\n " .join (expected_output )
522
535
523
536
537
+ @pytest .mark .xdist_group (name = Project .EXAMPLE )
524
538
def test_cli_with_json_output (poetry_venv_factory : PoetryVenvFactory ) -> None :
525
- with poetry_venv_factory ("example_project" ) as virtual_env :
539
+ with poetry_venv_factory (Project . EXAMPLE ) as virtual_env :
526
540
issue_report = f"{ uuid .uuid4 ()} .json"
527
541
result = virtual_env .run (f"deptry . -o { issue_report } " )
528
542
0 commit comments