Commit b14ed9cb authored by Jason R. Coombs's avatar Jason R. Coombs

Convert remaining tests in test_easy_install to pytest.

parent 943d583e
...@@ -4,7 +4,6 @@ import sys ...@@ -4,7 +4,6 @@ import sys
import os import os
import shutil import shutil
import tempfile import tempfile
import unittest
import site import site
import contextlib import contextlib
import textwrap import textwrap
...@@ -67,7 +66,7 @@ SETUP_PY = DALS(""" ...@@ -67,7 +66,7 @@ SETUP_PY = DALS("""
setup(name='foo') setup(name='foo')
""") """)
class TestEasyInstallTest(unittest.TestCase): class TestEasyInstallTest:
def test_install_site_py(self): def test_install_site_py(self):
dist = Distribution() dist = Distribution()
...@@ -77,7 +76,7 @@ class TestEasyInstallTest(unittest.TestCase): ...@@ -77,7 +76,7 @@ class TestEasyInstallTest(unittest.TestCase):
try: try:
cmd.install_site_py() cmd.install_site_py()
sitepy = os.path.join(cmd.install_dir, 'site.py') sitepy = os.path.join(cmd.install_dir, 'site.py')
self.assertTrue(os.path.exists(sitepy)) assert os.path.exists(sitepy)
finally: finally:
shutil.rmtree(cmd.install_dir) shutil.rmtree(cmd.install_dir)
...@@ -87,7 +86,7 @@ class TestEasyInstallTest(unittest.TestCase): ...@@ -87,7 +86,7 @@ class TestEasyInstallTest(unittest.TestCase):
args = next(get_script_args(dist)) args = next(get_script_args(dist))
name, script = itertools.islice(args, 2) name, script = itertools.islice(args, 2)
self.assertEqual(script, WANTED) assert script == WANTED
def test_no_find_links(self): def test_no_find_links(self):
# new option '--no-find-links', that blocks find-links added at # new option '--no-find-links', that blocks find-links added at
...@@ -100,7 +99,7 @@ class TestEasyInstallTest(unittest.TestCase): ...@@ -100,7 +99,7 @@ class TestEasyInstallTest(unittest.TestCase):
cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok')
cmd.args = ['ok'] cmd.args = ['ok']
cmd.ensure_finalized() cmd.ensure_finalized()
self.assertEqual(cmd.package_index.scanned_urls, {}) assert cmd.package_index.scanned_urls == {}
# let's try without it (default behavior) # let's try without it (default behavior)
cmd = easy_install(dist) cmd = easy_install(dist)
...@@ -110,27 +109,27 @@ class TestEasyInstallTest(unittest.TestCase): ...@@ -110,27 +109,27 @@ class TestEasyInstallTest(unittest.TestCase):
cmd.args = ['ok'] cmd.args = ['ok']
cmd.ensure_finalized() cmd.ensure_finalized()
keys = sorted(cmd.package_index.scanned_urls.keys()) keys = sorted(cmd.package_index.scanned_urls.keys())
self.assertEqual(keys, ['link1', 'link2']) assert keys == ['link1', 'link2']
class TestPTHFileWriter(unittest.TestCase): class TestPTHFileWriter:
def test_add_from_cwd_site_sets_dirty(self): def test_add_from_cwd_site_sets_dirty(self):
'''a pth file manager should set dirty '''a pth file manager should set dirty
if a distribution is in site but also the cwd if a distribution is in site but also the cwd
''' '''
pth = PthDistributions('does-not_exist', [os.getcwd()]) pth = PthDistributions('does-not_exist', [os.getcwd()])
self.assertTrue(not pth.dirty) assert not pth.dirty
pth.add(PRDistribution(os.getcwd())) pth.add(PRDistribution(os.getcwd()))
self.assertTrue(pth.dirty) assert pth.dirty
def test_add_from_site_is_ignored(self): def test_add_from_site_is_ignored(self):
location = '/test/location/does-not-have-to-exist' location = '/test/location/does-not-have-to-exist'
# PthDistributions expects all locations to be normalized # PthDistributions expects all locations to be normalized
location = pkg_resources.normalize_path(location) location = pkg_resources.normalize_path(location)
pth = PthDistributions('does-not_exist', [location, ]) pth = PthDistributions('does-not_exist', [location, ])
self.assertTrue(not pth.dirty) assert not pth.dirty
pth.add(PRDistribution(location)) pth.add(PRDistribution(location))
self.assertTrue(not pth.dirty) assert not pth.dirty
@pytest.yield_fixture @pytest.yield_fixture
...@@ -276,7 +275,7 @@ class TestDistutilsPackage: ...@@ -276,7 +275,7 @@ class TestDistutilsPackage:
run_setup('setup.py', ['bdist_egg']) run_setup('setup.py', ['bdist_egg'])
class TestSetupRequires(unittest.TestCase): class TestSetupRequires:
def test_setup_requires_honors_fetch_params(self): def test_setup_requires_honors_fetch_params(self):
""" """
...@@ -312,8 +311,8 @@ class TestSetupRequires(unittest.TestCase): ...@@ -312,8 +311,8 @@ class TestSetupRequires(unittest.TestCase):
easy_install_pkg.main(ei_params) easy_install_pkg.main(ei_params)
# there should have been two or three requests to the server # there should have been two or three requests to the server
# (three happens on Python 3.3a) # (three happens on Python 3.3a)
self.assertTrue(2 <= len(p_index.requests) <= 3) assert 2 <= len(p_index.requests) <= 3
self.assertEqual(p_index.requests[0].path, '/does-not-exist/') assert p_index.requests[0].path == '/does-not-exist/'
@staticmethod @staticmethod
@contextlib.contextmanager @contextlib.contextmanager
...@@ -363,8 +362,8 @@ class TestSetupRequires(unittest.TestCase): ...@@ -363,8 +362,8 @@ class TestSetupRequires(unittest.TestCase):
'caused a VersionConflict') 'caused a VersionConflict')
lines = stdout.readlines() lines = stdout.readlines()
self.assertTrue(len(lines) > 0) assert len(lines) > 0
self.assertTrue(lines[-1].strip(), 'test_pkg') assert lines[-1].strip(), 'test_pkg'
finally: finally:
pkg_resources.__setstate__(pr_state) pkg_resources.__setstate__(pr_state)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment