3
3
4
4
import pytest
5
5
6
+ from tests .lib .path import Path
6
7
7
- def test_basic_list (script , data ):
8
- """
9
- Test default behavior of list command without format specifier.
10
8
11
- """
9
+ @pytest .fixture (scope = "session" )
10
+ def simple_script (tmpdir_factory , script_factory , shared_data ):
11
+ tmpdir = Path (tmpdir_factory .mktemp ("pip_test_package" ))
12
+ script = script_factory (tmpdir .joinpath ("workspace" ))
12
13
script .pip (
13
- 'install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' ,
14
+ 'install' , '-f' , shared_data .find_links , '--no-index' , 'simple==1.0' ,
14
15
'simple2==3.0' ,
15
16
)
16
- result = script .pip ('list' )
17
+ return script
18
+
19
+
20
+ def test_basic_list (simple_script ):
21
+ """
22
+ Test default behavior of list command without format specifier.
23
+
24
+ """
25
+ result = simple_script .pip ('list' )
17
26
assert 'simple 1.0' in result .stdout , str (result )
18
27
assert 'simple2 3.0' in result .stdout , str (result )
19
28
20
29
21
- def test_verbose_flag (script , data ):
30
+ def test_verbose_flag (simple_script ):
22
31
"""
23
32
Test the list command with the '-v' option
24
33
"""
25
- script .pip (
26
- 'install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' ,
27
- 'simple2==3.0' ,
28
- )
29
- result = script .pip ('list' , '-v' , '--format=columns' )
34
+ result = simple_script .pip ('list' , '-v' , '--format=columns' )
30
35
assert 'Package' in result .stdout , str (result )
31
36
assert 'Version' in result .stdout , str (result )
32
37
assert 'Location' in result .stdout , str (result )
@@ -35,38 +40,30 @@ def test_verbose_flag(script, data):
35
40
assert 'simple2 3.0' in result .stdout , str (result )
36
41
37
42
38
- def test_columns_flag (script , data ):
43
+ def test_columns_flag (simple_script ):
39
44
"""
40
45
Test the list command with the '--format=columns' option
41
46
"""
42
- script .pip (
43
- 'install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' ,
44
- 'simple2==3.0' ,
45
- )
46
- result = script .pip ('list' , '--format=columns' )
47
+ result = simple_script .pip ('list' , '--format=columns' )
47
48
assert 'Package' in result .stdout , str (result )
48
49
assert 'Version' in result .stdout , str (result )
49
50
assert 'simple (1.0)' not in result .stdout , str (result )
50
51
assert 'simple 1.0' in result .stdout , str (result )
51
52
assert 'simple2 3.0' in result .stdout , str (result )
52
53
53
54
54
- def test_format_priority (script , data ):
55
+ def test_format_priority (simple_script ):
55
56
"""
56
57
Test that latest format has priority over previous ones.
57
58
"""
58
- script .pip (
59
- 'install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' ,
60
- 'simple2==3.0' ,
61
- )
62
- result = script .pip ('list' , '--format=columns' , '--format=freeze' ,
63
- expect_stderr = True )
59
+ result = simple_script .pip ('list' , '--format=columns' , '--format=freeze' ,
60
+ expect_stderr = True )
64
61
assert 'simple==1.0' in result .stdout , str (result )
65
62
assert 'simple2==3.0' in result .stdout , str (result )
66
63
assert 'simple 1.0' not in result .stdout , str (result )
67
64
assert 'simple2 3.0' not in result .stdout , str (result )
68
65
69
- result = script .pip ('list' , '--format=freeze' , '--format=columns' )
66
+ result = simple_script .pip ('list' , '--format=freeze' , '--format=columns' )
70
67
assert 'Package' in result .stdout , str (result )
71
68
assert 'Version' in result .stdout , str (result )
72
69
assert 'simple==1.0' not in result .stdout , str (result )
@@ -75,23 +72,21 @@ def test_format_priority(script, data):
75
72
assert 'simple2 3.0' in result .stdout , str (result )
76
73
77
74
78
- def test_local_flag (script , data ):
75
+ def test_local_flag (simple_script ):
79
76
"""
80
77
Test the behavior of --local flag in the list command
81
78
82
79
"""
83
- script .pip ('install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' )
84
- result = script .pip ('list' , '--local' , '--format=json' )
80
+ result = simple_script .pip ('list' , '--local' , '--format=json' )
85
81
assert {"name" : "simple" , "version" : "1.0" } in json .loads (result .stdout )
86
82
87
83
88
- def test_local_columns_flag (script , data ):
84
+ def test_local_columns_flag (simple_script ):
89
85
"""
90
86
Test the behavior of --local --format=columns flags in the list command
91
87
92
88
"""
93
- script .pip ('install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' )
94
- result = script .pip ('list' , '--local' , '--format=columns' )
89
+ result = simple_script .pip ('list' , '--local' , '--format=columns' )
95
90
assert 'Package' in result .stdout
96
91
assert 'Version' in result .stdout
97
92
assert 'simple (1.0)' not in result .stdout
@@ -479,30 +474,22 @@ def test_not_required_flag(script, data):
479
474
assert 'TopoRequires3 ' not in result .stdout
480
475
481
476
482
- def test_list_freeze (script , data ):
477
+ def test_list_freeze (simple_script ):
483
478
"""
484
479
Test freeze formatting of list command
485
480
486
481
"""
487
- script .pip (
488
- 'install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' ,
489
- 'simple2==3.0' ,
490
- )
491
- result = script .pip ('list' , '--format=freeze' )
482
+ result = simple_script .pip ('list' , '--format=freeze' )
492
483
assert 'simple==1.0' in result .stdout , str (result )
493
484
assert 'simple2==3.0' in result .stdout , str (result )
494
485
495
486
496
- def test_list_json (script , data ):
487
+ def test_list_json (simple_script ):
497
488
"""
498
489
Test json formatting of list command
499
490
500
491
"""
501
- script .pip (
502
- 'install' , '-f' , data .find_links , '--no-index' , 'simple==1.0' ,
503
- 'simple2==3.0' ,
504
- )
505
- result = script .pip ('list' , '--format=json' )
492
+ result = simple_script .pip ('list' , '--format=json' )
506
493
data = json .loads (result .stdout )
507
494
assert {'name' : 'simple' , 'version' : '1.0' } in data
508
495
assert {'name' : 'simple2' , 'version' : '3.0' } in data
0 commit comments