|
12 | 12 | ('input_s', 'argv', 'expected_retval', 'output'), |
13 | 13 | ( |
14 | 14 |
|
15 | | - (b'', [], PASS, b''), |
16 | | - (b'\n', [], PASS, b'\n'), |
17 | | - (b'# intentionally empty\n', [], PASS, b'# intentionally empty\n'), |
18 | | - (b'foo\n# comment at end\n', [], PASS, b'foo\n# comment at end\n'), |
19 | | - (b'foo\nbar\n', [], FAIL, b'bar\nfoo\n'), |
20 | | - (b'bar\nfoo\n', [], PASS, b'bar\nfoo\n'), |
21 | | - (b'a\nc\nb\n', [], FAIL, b'a\nb\nc\n'), |
22 | | - (b'a\nc\nb', [], FAIL, b'a\nb\nc\n'), |
23 | | - (b'a\nb\nc', [], FAIL, b'a\nb\nc\n'), |
24 | | - ( |
25 | | - b'#comment1\nfoo\n#comment2\nbar\n', |
26 | | - [], |
27 | | - FAIL, |
28 | | - b'#comment2\nbar\n#comment1\nfoo\n', |
29 | | - ), |
30 | | - ( |
31 | | - b'#comment1\nbar\n#comment2\nfoo\n', |
32 | | - [], |
33 | | - PASS, |
34 | | - b'#comment1\nbar\n#comment2\nfoo\n', |
35 | | - ), |
36 | | - (b'#comment\n\nfoo\nbar\n', [], FAIL, b'#comment\n\nbar\nfoo\n'), |
37 | | - (b'#comment\n\nbar\nfoo\n', [], PASS, b'#comment\n\nbar\nfoo\n'), |
38 | | - ( |
39 | | - b'foo\n\t#comment with indent\nbar\n', |
40 | | - [], |
41 | | - FAIL, |
42 | | - b'\t#comment with indent\nbar\nfoo\n', |
43 | | - ), |
44 | | - ( |
45 | | - b'bar\n\t#comment with indent\nfoo\n', |
46 | | - [], |
47 | | - PASS, |
48 | | - b'bar\n\t#comment with indent\nfoo\n', |
49 | | - ), |
50 | | - (b'\nfoo\nbar\n', [], FAIL, b'bar\n\nfoo\n'), |
51 | | - (b'\nbar\nfoo\n', [], PASS, b'\nbar\nfoo\n'), |
52 | | - ( |
53 | | - b'pyramid-foo==1\npyramid>=2\n', |
54 | | - [], |
55 | | - FAIL, |
56 | | - b'pyramid>=2\npyramid-foo==1\n', |
57 | | - ), |
58 | | - ( |
59 | | - b'a==1\n' |
60 | | - b'c>=1\n' |
61 | | - b'bbbb!=1\n' |
62 | | - b'c-a>=1;python_version>="3.6"\n' |
63 | | - b'e>=2\n' |
64 | | - b'd>2\n' |
65 | | - b'g<2\n' |
66 | | - b'f<=2\n', |
67 | | - [], |
68 | | - FAIL, |
69 | | - b'a==1\n' |
70 | | - b'bbbb!=1\n' |
71 | | - b'c>=1\n' |
72 | | - b'c-a>=1;python_version>="3.6"\n' |
73 | | - b'd>2\n' |
74 | | - b'e>=2\n' |
75 | | - b'f<=2\n' |
76 | | - b'g<2\n', |
77 | | - ), |
78 | | - (b'a==1\nb==1\na==1\n', [], FAIL, b'a==1\nb==1\n'), |
79 | | - ( |
80 | | - b'a==1\nb==1\n#comment about a\na==1\n', |
81 | | - [], |
82 | | - FAIL, |
83 | | - b'#comment about a\na==1\nb==1\n', |
84 | | - ), |
85 | | - (b'ocflib\nDjango\nPyMySQL\n', [], FAIL, b'Django\nocflib\nPyMySQL\n'), |
86 | | - ( |
87 | | - b'-e git+ssh://git_url@tag#egg=ocflib\nDjango\nPyMySQL\n', |
88 | | - [], |
89 | | - FAIL, |
90 | | - b'Django\n-e git+ssh://git_url@tag#egg=ocflib\nPyMySQL\n', |
91 | | - ), |
92 | | - (b'bar\npkg-resources==0.0.0\nfoo\n', [], FAIL, b'bar\nfoo\n'), |
93 | | - (b'foo\npkg-resources==0.0.0\nbar\n', [], FAIL, b'bar\nfoo\n'), |
94 | | - (b'bar\npkg_resources==0.0.0\nfoo\n', [], FAIL, b'bar\nfoo\n'), |
95 | | - (b'foo\npkg_resources==0.0.0\nbar\n', [], FAIL, b'bar\nfoo\n'), |
96 | | - ( |
97 | | - b'git+ssh://git_url@tag#egg=ocflib\nDjango\nijk\n', |
98 | | - [], |
99 | | - FAIL, |
100 | | - b'Django\nijk\ngit+ssh://git_url@tag#egg=ocflib\n', |
101 | | - ), |
102 | | - ( |
103 | | - b'b==1.0.0\n' |
104 | | - b'c=2.0.0 \\\n' |
105 | | - b' --hash=sha256:abcd\n' |
106 | | - b'a=3.0.0 \\\n' |
107 | | - b' --hash=sha256:a1b1c1d1', |
108 | | - [], |
109 | | - FAIL, |
110 | | - b'a=3.0.0 \\\n' |
111 | | - b' --hash=sha256:a1b1c1d1\n' |
112 | | - b'b==1.0.0\n' |
113 | | - b'c=2.0.0 \\\n' |
114 | | - b' --hash=sha256:abcd\n', |
115 | | - ), |
116 | | - ( |
117 | | - b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n', |
118 | | - [], |
119 | | - PASS, |
120 | | - b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n', |
121 | | - ), |
122 | | - (b'bar\nfoo\n', ["--fail-without-version"], FAIL, b'bar\nfoo\n'), |
123 | | - (b'bar==1.0\nfoo==1.1a\n', ["--fail-without-version"], PASS, b'bar==1.0\nfoo==1.1a\n'), |
124 | | - (b'#test\nbar==1.0\nfoo==1.1a\n', ["--fail-without-version"], PASS, b'#test\nbar==1.0\nfoo==1.1a\n'), |
125 | | - (b'bar==1.0\n#test\nfoo==1.1a\n', ["--fail-without-version"], PASS, b'bar==1.0\n#test\nfoo==1.1a\n'), |
| 15 | + (b'', [], PASS, b''), |
| 16 | + (b'\n', [], PASS, b'\n'), |
| 17 | + (b'# intentionally empty\n', [], PASS, b'# intentionally empty\n'), |
| 18 | + (b'foo\n# comment at end\n', [], PASS, b'foo\n# comment at end\n'), |
| 19 | + (b'foo\nbar\n', [], FAIL, b'bar\nfoo\n'), |
| 20 | + (b'bar\nfoo\n', [], PASS, b'bar\nfoo\n'), |
| 21 | + (b'a\nc\nb\n', [], FAIL, b'a\nb\nc\n'), |
| 22 | + (b'a\nc\nb', [], FAIL, b'a\nb\nc\n'), |
| 23 | + (b'a\nb\nc', [], FAIL, b'a\nb\nc\n'), |
| 24 | + ( |
| 25 | + b'#comment1\nfoo\n#comment2\nbar\n', |
| 26 | + [], |
| 27 | + FAIL, |
| 28 | + b'#comment2\nbar\n#comment1\nfoo\n', |
| 29 | + ), |
| 30 | + ( |
| 31 | + b'#comment1\nbar\n#comment2\nfoo\n', |
| 32 | + [], |
| 33 | + PASS, |
| 34 | + b'#comment1\nbar\n#comment2\nfoo\n', |
| 35 | + ), |
| 36 | + (b'#comment\n\nfoo\nbar\n', [], FAIL, b'#comment\n\nbar\nfoo\n'), |
| 37 | + (b'#comment\n\nbar\nfoo\n', [], PASS, b'#comment\n\nbar\nfoo\n'), |
| 38 | + ( |
| 39 | + b'foo\n\t#comment with indent\nbar\n', |
| 40 | + [], |
| 41 | + FAIL, |
| 42 | + b'\t#comment with indent\nbar\nfoo\n', |
| 43 | + ), |
| 44 | + ( |
| 45 | + b'bar\n\t#comment with indent\nfoo\n', |
| 46 | + [], |
| 47 | + PASS, |
| 48 | + b'bar\n\t#comment with indent\nfoo\n', |
| 49 | + ), |
| 50 | + (b'\nfoo\nbar\n', [], FAIL, b'bar\n\nfoo\n'), |
| 51 | + (b'\nbar\nfoo\n', [], PASS, b'\nbar\nfoo\n'), |
| 52 | + ( |
| 53 | + b'pyramid-foo==1\npyramid>=2\n', |
| 54 | + [], |
| 55 | + FAIL, |
| 56 | + b'pyramid>=2\npyramid-foo==1\n', |
| 57 | + ), |
| 58 | + ( |
| 59 | + b'a==1\n' |
| 60 | + b'c>=1\n' |
| 61 | + b'bbbb!=1\n' |
| 62 | + b'c-a>=1;python_version>="3.6"\n' |
| 63 | + b'e>=2\n' |
| 64 | + b'd>2\n' |
| 65 | + b'g<2\n' |
| 66 | + b'f<=2\n', |
| 67 | + [], |
| 68 | + FAIL, |
| 69 | + b'a==1\n' |
| 70 | + b'bbbb!=1\n' |
| 71 | + b'c>=1\n' |
| 72 | + b'c-a>=1;python_version>="3.6"\n' |
| 73 | + b'd>2\n' |
| 74 | + b'e>=2\n' |
| 75 | + b'f<=2\n' |
| 76 | + b'g<2\n', |
| 77 | + ), |
| 78 | + (b'a==1\nb==1\na==1\n', [], FAIL, b'a==1\nb==1\n'), |
| 79 | + ( |
| 80 | + b'a==1\nb==1\n#comment about a\na==1\n', |
| 81 | + [], |
| 82 | + FAIL, |
| 83 | + b'#comment about a\na==1\nb==1\n', |
| 84 | + ), |
| 85 | + (b'ocflib\nDjango\nPyMySQL\n', [], FAIL, b'Django\nocflib\nPyMySQL\n'), |
| 86 | + ( |
| 87 | + b'-e git+ssh://git_url@tag#egg=ocflib\nDjango\nPyMySQL\n', |
| 88 | + [], |
| 89 | + FAIL, |
| 90 | + b'Django\n-e git+ssh://git_url@tag#egg=ocflib\nPyMySQL\n', |
| 91 | + ), |
| 92 | + (b'bar\npkg-resources==0.0.0\nfoo\n', [], FAIL, b'bar\nfoo\n'), |
| 93 | + (b'foo\npkg-resources==0.0.0\nbar\n', [], FAIL, b'bar\nfoo\n'), |
| 94 | + (b'bar\npkg_resources==0.0.0\nfoo\n', [], FAIL, b'bar\nfoo\n'), |
| 95 | + (b'foo\npkg_resources==0.0.0\nbar\n', [], FAIL, b'bar\nfoo\n'), |
| 96 | + ( |
| 97 | + b'git+ssh://git_url@tag#egg=ocflib\nDjango\nijk\n', |
| 98 | + [], |
| 99 | + FAIL, |
| 100 | + b'Django\nijk\ngit+ssh://git_url@tag#egg=ocflib\n', |
| 101 | + ), |
| 102 | + ( |
| 103 | + b'b==1.0.0\n' |
| 104 | + b'c=2.0.0 \\\n' |
| 105 | + b' --hash=sha256:abcd\n' |
| 106 | + b'a=3.0.0 \\\n' |
| 107 | + b' --hash=sha256:a1b1c1d1', |
| 108 | + [], |
| 109 | + FAIL, |
| 110 | + b'a=3.0.0 \\\n' |
| 111 | + b' --hash=sha256:a1b1c1d1\n' |
| 112 | + b'b==1.0.0\n' |
| 113 | + b'c=2.0.0 \\\n' |
| 114 | + b' --hash=sha256:abcd\n', |
| 115 | + ), |
| 116 | + ( |
| 117 | + b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n', |
| 118 | + [], |
| 119 | + PASS, |
| 120 | + b'a=2.0.0 \\\n --hash=sha256:abcd\nb==1.0.0\n', |
| 121 | + ), |
| 122 | + (b'bar\nfoo\n', ['--fail-without-version'], FAIL, b'bar\nfoo\n'), |
| 123 | + (b'bar==1.0\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'bar==1.0\nfoo==1.1a\n'), |
| 124 | + (b'#test\nbar==1.0\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'#test\nbar==1.0\nfoo==1.1a\n'), |
| 125 | + (b'bar==1.0\n#test\nfoo==1.1a\n', ['--fail-without-version'], PASS, b'bar==1.0\n#test\nfoo==1.1a\n'), |
126 | 126 | ), |
127 | 127 | ) |
128 | 128 | def test_integration(input_s, argv, expected_retval, output, tmpdir): |
129 | | - path = tmpdir.join('file.txt') |
130 | | - path.write_binary(input_s) |
| 129 | + path = tmpdir.join('file.txt') |
| 130 | + path.write_binary(input_s) |
131 | 131 |
|
132 | | - output_retval = main([str(path)] + argv) |
| 132 | + output_retval = main([str(path)] + argv) |
133 | 133 |
|
134 | | - assert path.read_binary() == output |
135 | | - assert output_retval == expected_retval |
| 134 | + assert path.read_binary() == output |
| 135 | + assert output_retval == expected_retval |
136 | 136 |
|
137 | 137 |
|
138 | 138 | def test_requirement_object(): |
139 | | - top_of_file = Requirement() |
140 | | - top_of_file.comments.append(b'#foo') |
141 | | - top_of_file.value = b'\n' |
| 139 | + top_of_file = Requirement() |
| 140 | + top_of_file.comments.append(b'#foo') |
| 141 | + top_of_file.value = b'\n' |
142 | 142 |
|
143 | | - requirement_foo = Requirement() |
144 | | - requirement_foo.value = b'foo' |
| 143 | + requirement_foo = Requirement() |
| 144 | + requirement_foo.value = b'foo' |
145 | 145 |
|
146 | | - requirement_bar = Requirement() |
147 | | - requirement_bar.value = b'bar' |
| 146 | + requirement_bar = Requirement() |
| 147 | + requirement_bar.value = b'bar' |
148 | 148 |
|
149 | | - requirements_bar_versioned = Requirement() |
150 | | - requirements_bar_versioned.value = b'bar==1.0' |
| 149 | + requirements_bar_versioned = Requirement() |
| 150 | + requirements_bar_versioned.value = b'bar==1.0' |
151 | 151 |
|
152 | | - # check for version specification |
153 | | - assert top_of_file.contains_version_specifier() is False |
154 | | - assert requirement_foo.contains_version_specifier() is False |
155 | | - assert requirement_bar.contains_version_specifier() is False |
156 | | - assert requirements_bar_versioned.contains_version_specifier() is True |
| 152 | + # check for version specification |
| 153 | + assert top_of_file.contains_version_specifier() is False |
| 154 | + assert requirement_foo.contains_version_specifier() is False |
| 155 | + assert requirement_bar.contains_version_specifier() is False |
| 156 | + assert requirements_bar_versioned.contains_version_specifier() is True |
157 | 157 |
|
158 | | - # This may look redundant, but we need to test both foo.__lt__(bar) and |
159 | | - # bar.__lt__(foo) |
160 | | - assert requirement_foo > top_of_file |
161 | | - assert top_of_file < requirement_foo |
162 | | - assert requirement_foo > requirement_bar |
163 | | - assert requirement_bar < requirement_foo |
| 158 | + # This may look redundant, but we need to test both foo.__lt__(bar) and |
| 159 | + # bar.__lt__(foo) |
| 160 | + assert requirement_foo > top_of_file |
| 161 | + assert top_of_file < requirement_foo |
| 162 | + assert requirement_foo > requirement_bar |
| 163 | + assert requirement_bar < requirement_foo |
0 commit comments