forked from conda/conda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_export.py
90 lines (72 loc) · 3.59 KB
/
test_export.py
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
import pytest
import tempfile
from conda.gateways.disk.delete import rm_rf
from datetime import datetime
from os.path import exists, join
from unittest import TestCase
from .test_create import (Commands, PYTHON_BINARY, assert_package_is_installed, make_temp_env,
make_temp_prefix, run_command)
@pytest.mark.integration
class ExportIntegrationTests(TestCase):
def test_basic(self):
with make_temp_env("python=3.5") as prefix:
assert exists(join(prefix, PYTHON_BINARY))
assert_package_is_installed(prefix, 'python-3')
output, error = run_command(Commands.LIST, prefix, "-e")
with tempfile.NamedTemporaryFile(mode="w", suffix="txt", delete=False) as env_txt:
env_txt.write(output)
env_txt.flush()
env_txt.close()
prefix2 = make_temp_prefix()
run_command(Commands.CREATE, prefix2 , "--file " + env_txt.name)
assert_package_is_installed(prefix2, "python")
output2, error= run_command(Commands.LIST, prefix2, "-e")
self.assertEqual(output, output2)
@pytest.mark.xfail(datetime.now() < datetime(2017, 4, 1), reason="Bring back `conda list --export` #3445", strict=True)
def test_multi_channel_export(self):
"""
When try to import from txt
every package should come from same channel
"""
with make_temp_env("python=3.5") as prefix:
assert exists(join(prefix, PYTHON_BINARY))
assert_package_is_installed(prefix, 'python-3')
run_command(Commands.INSTALL, prefix, "six", "-c", "conda-forge")
assert_package_is_installed(prefix, "six")
output, error = run_command(Commands.LIST, prefix, "-e")
self.assertIn("conda-forge", output)
try:
with tempfile.NamedTemporaryFile(mode="w", suffix="txt", delete=False) as env_txt:
env_txt.write(output)
env_txt.close()
prefix2 = make_temp_prefix()
run_command(Commands.CREATE, prefix2 , "--file " + env_txt.name)
assert_package_is_installed(prefix2, "python")
output2, error = run_command(Commands.LIST, prefix2, "-e")
self.assertEqual(output, output2)
finally:
rm_rf(env_txt.name)
def test_multi_channel_explicit(self):
"""
When try to import from txt
every package should come from same channel
"""
with make_temp_env("python=3.5") as prefix:
assert exists(join(prefix, PYTHON_BINARY))
assert_package_is_installed(prefix, 'python-3')
run_command(Commands.INSTALL, prefix, "six", "-c", "conda-forge")
assert_package_is_installed(prefix, "six")
output, error = run_command(Commands.LIST, prefix, "--explicit")
self.assertIn("conda-forge", output)
try:
with tempfile.NamedTemporaryFile(mode="w", suffix="txt", delete=False) as env_txt:
env_txt.write(output)
env_txt.close()
prefix2 = make_temp_prefix()
run_command(Commands.CREATE, prefix2, "--file " + env_txt.name)
assert_package_is_installed(prefix2, "python")
assert_package_is_installed(prefix2, "six")
output2, _ = run_command(Commands.LIST, prefix2, "--explicit")
self.assertEqual(output, output2)
finally:
rm_rf(env_txt.name)