File: test_install_basic.py

package info (click to toggle)
mozjs78 78.15.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 739,892 kB
  • sloc: javascript: 1,344,214; cpp: 1,215,708; python: 526,544; ansic: 433,835; xml: 118,736; sh: 26,176; asm: 16,664; makefile: 11,537; yacc: 4,486; perl: 2,564; ada: 1,681; lex: 1,414; pascal: 1,139; cs: 879; exp: 499; java: 164; ruby: 68; sql: 45; csh: 35; sed: 18; lisp: 2
file content (266 lines) | stat: -rw-r--r-- 8,296 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
import contextlib
import os

from pipenv.utils import temp_environ
from pipenv.vendor import delegator

import pytest

from flaky import flaky


@pytest.mark.install
@pytest.mark.setup
@pytest.mark.skip(reason="this doesn't work on travis")
def test_basic_setup(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        with PipenvInstance(pipfile=False) as p:
            c = p.pipenv('install requests')
            assert c.return_code == 0

            assert 'requests' in p.pipfile['packages']
            assert 'requests' in p.lockfile['default']
            assert 'chardet' in p.lockfile['default']
            assert 'idna' in p.lockfile['default']
            assert 'urllib3' in p.lockfile['default']
            assert 'certifi' in p.lockfile['default']


@pytest.mark.install
@flaky
def test_basic_install(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        c = p.pipenv('install requests')
        assert c.return_code == 0
        assert 'requests' in p.pipfile['packages']
        assert 'requests' in p.lockfile['default']
        assert 'chardet' in p.lockfile['default']
        assert 'idna' in p.lockfile['default']
        assert 'urllib3' in p.lockfile['default']
        assert 'certifi' in p.lockfile['default']


@pytest.mark.complex
@pytest.mark.lock
@pytest.mark.skip(reason='Does not work unless you can explicitly install into py2')
def test_complex_lock(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        c = p.pipenv('install apscheduler')
        assert c.return_code == 0
        assert 'apscheduler' in p.pipfile['packages']
        assert 'funcsigs' in p.lockfile[u'default']
        assert 'futures' in p.lockfile[u'default']


@pytest.mark.dev
@pytest.mark.run
@flaky
def test_basic_dev_install(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        c = p.pipenv('install requests --dev')
        assert c.return_code == 0
        assert 'requests' in p.pipfile['dev-packages']
        assert 'requests' in p.lockfile['develop']
        assert 'chardet' in p.lockfile['develop']
        assert 'idna' in p.lockfile['develop']
        assert 'urllib3' in p.lockfile['develop']
        assert 'certifi' in p.lockfile['develop']

        c = p.pipenv('run python -m requests.help')
        assert c.return_code == 0


@pytest.mark.dev
@pytest.mark.install
@flaky
def test_install_without_dev(PipenvInstance, pypi):
    """Ensure that running `pipenv install` doesn't install dev packages"""
    with PipenvInstance(pypi=pypi, chdir=True) as p:
        with open(p.pipfile_path, 'w') as f:
            contents = """
[packages]
six = "*"

[dev-packages]
pytz = "*"
            """.strip()
            f.write(contents)
        c = p.pipenv('install')
        assert c.return_code == 0
        assert 'six' in p.pipfile['packages']
        assert 'pytz' in p.pipfile['dev-packages']
        assert 'six' in p.lockfile['default']
        assert 'pytz' in p.lockfile['develop']
        c = p.pipenv('run python -c "import pytz"')
        assert c.return_code != 0
        c = p.pipenv('run python -c "import six"')
        assert c.return_code == 0


@pytest.mark.install
@flaky
def test_install_without_dev_section(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        with open(p.pipfile_path, 'w') as f:
            contents = """
[packages]
six = "*"
            """.strip()
            f.write(contents)
        c = p.pipenv('install')
        assert c.return_code == 0
        assert 'six' in p.pipfile['packages']
        assert p.pipfile.get('dev-packages', {}) == {}
        assert 'six' in p.lockfile['default']
        assert p.lockfile['develop'] == {}
        c = p.pipenv('run python -c "import six"')
        assert c.return_code == 0


@pytest.mark.extras
@pytest.mark.install
@flaky
def test_extras_install(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi, chdir=True) as p:
        c = p.pipenv('install requests[socks]')
        assert c.return_code == 0
        assert 'requests' in p.pipfile['packages']
        assert 'extras' in p.pipfile['packages']['requests']

        assert 'requests' in p.lockfile['default']
        assert 'chardet' in p.lockfile['default']
        assert 'idna' in p.lockfile['default']
        assert 'urllib3' in p.lockfile['default']
        assert 'pysocks' in p.lockfile['default']


@pytest.mark.install
@pytest.mark.pin
@flaky
def test_windows_pinned_pipfile(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        with open(p.pipfile_path, 'w') as f:
            contents = """
[packages]
tablib = "<0.12"
            """.strip()
            f.write(contents)
        c = p.pipenv('install')
        assert c.return_code == 0
        assert 'tablib' in p.pipfile['packages']
        assert 'tablib' in p.lockfile['default']


@pytest.mark.install
@pytest.mark.resolver
@pytest.mark.backup_resolver
@flaky
def test_backup_resolver(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        with open(p.pipfile_path, 'w') as f:
            contents = """
[packages]
"ibm-db-sa-py3" = "==0.3.1-1"
            """.strip()
            f.write(contents)

        c = p.pipenv('install')
        assert c.return_code == 0
        assert 'ibm-db-sa-py3' in p.lockfile['default']


@pytest.mark.run
@pytest.mark.alt
@flaky
def test_alternative_version_specifier(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        with open(p.pipfile_path, 'w') as f:
            contents = """
[packages]
requests = {version = "*"}
            """.strip()
            f.write(contents)

        c = p.pipenv('install')
        assert c.return_code == 0

        assert 'requests' in p.lockfile['default']
        assert 'idna' in p.lockfile['default']
        assert 'urllib3' in p.lockfile['default']
        assert 'certifi' in p.lockfile['default']
        assert 'chardet' in p.lockfile['default']

        c = p.pipenv('run python -c "import requests; import idna; import certifi;"')
        assert c.return_code == 0


@pytest.mark.bad
@pytest.mark.install
def test_bad_packages(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        c = p.pipenv('install NotAPackage')
        assert c.return_code > 0


@pytest.mark.extras
@pytest.mark.install
@pytest.mark.requirements
@pytest.mark.skip(reason="Not mocking this.")
def test_requirements_to_pipfile(PipenvInstance, pypi):

    with PipenvInstance(pipfile=False, chdir=True, pypi=pypi) as p:

        # Write a requirements file
        with open('requirements.txt', 'w') as f:
            f.write('requests[socks]==2.18.1\n')

        c = p.pipenv('install')
        assert c.return_code == 0
        print(c.out)
        print(c.err)
        print(delegator.run('ls -l').out)

        # assert stuff in pipfile
        assert 'requests' in p.pipfile['packages']
        assert 'extras' in p.pipfile['packages']['requests']

        # assert stuff in lockfile
        assert 'requests' in p.lockfile['default']
        assert 'chardet' in p.lockfile['default']
        assert 'idna' in p.lockfile['default']
        assert 'urllib3' in p.lockfile['default']
        assert 'pysocks' in p.lockfile['default']


@pytest.mark.cli
@pytest.mark.clean
def test_clean_on_empty_venv(PipenvInstance, pypi):
    with PipenvInstance(pypi=pypi) as p:
        c = p.pipenv('clean')
        assert c.return_code == 0


@pytest.mark.install
def test_install_does_not_extrapolate_environ(PipenvInstance, pypi):
    with temp_environ(), PipenvInstance(pypi=pypi, chdir=True) as p:
        os.environ['PYPI_URL'] = pypi.url

        with open(p.pipfile_path, 'w') as f:
            f.write("""
[[source]]
url = '${PYPI_URL}/simple'
verify_ssl = true
name = 'mockpi'
            """)

        # Ensure simple install does not extrapolate.
        c = p.pipenv('install')
        assert c.return_code == 0
        assert p.pipfile['source'][0]['url'] == '${PYPI_URL}/simple'
        assert p.lockfile['_meta']['sources'][0]['url'] == '${PYPI_URL}/simple'

        # Ensure package install does not extrapolate.
        c = p.pipenv('install six')
        assert c.return_code == 0
        assert p.pipfile['source'][0]['url'] == '${PYPI_URL}/simple'
        assert p.lockfile['_meta']['sources'][0]['url'] == '${PYPI_URL}/simple'