Skip to content

Commit

Permalink
try a small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Aug 18, 2016
1 parent 75e9a5b commit b79bbb2
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pytest
from conda.install import rm_rf


class ExportIntegrationTests(TestCase):

@pytest.mark.timeout(900)
Expand All @@ -16,17 +17,18 @@ def test_basic(self):
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")
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)
output2, error = run_command(Commands.LIST, prefix2, "-e")
self.assertEqual(output, output2)

def test_multi_channel_explicit(self):
"""
Expand All @@ -43,15 +45,16 @@ def test_multi_channel_explicit(self):
output, error = run_command(Commands.LIST, prefix, "--explicit")
self.assertIn("conda-forge", output)

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")
assert_package_is_installed(prefix2, "six")
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)
output2, _ = run_command(Commands.LIST, prefix2, "--explicit")
self.assertEqual(output, output2)

0 comments on commit b79bbb2

Please sign in to comment.