diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-02 11:05:52 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-02 11:05:52 -0500 |
commit | 58c0f87887ee451424da702bfd70c0332e28ac5c (patch) | |
tree | 54fb325f19ba08f11c62dc091bb1e8c7b041bbba /setuptools/tests/test_packageindex.py | |
parent | 23d9089cb0e74b75ead48991509f9dff3fa5eff2 (diff) | |
download | external_python_setuptools-58c0f87887ee451424da702bfd70c0332e28ac5c.tar.gz external_python_setuptools-58c0f87887ee451424da702bfd70c0332e28ac5c.tar.bz2 external_python_setuptools-58c0f87887ee451424da702bfd70c0332e28ac5c.zip |
Remove dependence on unittest in favor of pytest for test_packgeindex
Diffstat (limited to 'setuptools/tests/test_packageindex.py')
-rw-r--r-- | setuptools/tests/test_packageindex.py | 63 |
1 files changed, 36 insertions, 27 deletions
diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 6aec44f9..5a46f613 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -9,7 +9,8 @@ import pkg_resources import setuptools.package_index from setuptools.tests.server import IndexServer -class TestPackageIndex(unittest.TestCase): + +class TestPackageIndex: def test_bad_url_bad_port(self): index = setuptools.package_index.PackageIndex() @@ -18,9 +19,9 @@ class TestPackageIndex(unittest.TestCase): v = index.open_url(url) except Exception: v = sys.exc_info()[1] - self.assertTrue(url in str(v)) + assert url in str(v) else: - self.assertTrue(isinstance(v, HTTPError)) + assert isinstance(v, HTTPError) def test_bad_url_typo(self): # issue 16 @@ -35,9 +36,9 @@ class TestPackageIndex(unittest.TestCase): v = index.open_url(url) except Exception: v = sys.exc_info()[1] - self.assertTrue(url in str(v)) + assert url in str(v) else: - self.assertTrue(isinstance(v, HTTPError)) + assert isinstance(v, HTTPError) def test_bad_url_bad_status_line(self): index = setuptools.package_index.PackageIndex( @@ -53,7 +54,7 @@ class TestPackageIndex(unittest.TestCase): v = index.open_url(url) except Exception: v = sys.exc_info()[1] - self.assertTrue('line' in str(v)) + assert 'line' in str(v) else: raise AssertionError('Should have raise here!') @@ -94,7 +95,7 @@ class TestPackageIndex(unittest.TestCase): hosts=('www.example.com',) ) url = 'file:///tmp/test_package_index' - self.assertTrue(index.url_ok(url, True)) + assert index.url_ok(url, True) def test_links_priority(self): """ @@ -127,21 +128,30 @@ class TestPackageIndex(unittest.TestCase): server.stop() # the distribution has been found - self.assertTrue('foobar' in pi) + assert 'foobar' in pi # we have only one link, because links are compared without md5 - self.assertTrue(len(pi['foobar'])==1) + assert len(pi['foobar'])==1 # the link should be from the index - self.assertTrue('correct_md5' in pi['foobar'][0].location) + assert 'correct_md5' in pi['foobar'][0].location def test_parse_bdist_wininst(self): - self.assertEqual(setuptools.package_index.parse_bdist_wininst( - 'reportlab-2.5.win32-py2.4.exe'), ('reportlab-2.5', '2.4', 'win32')) - self.assertEqual(setuptools.package_index.parse_bdist_wininst( - 'reportlab-2.5.win32.exe'), ('reportlab-2.5', None, 'win32')) - self.assertEqual(setuptools.package_index.parse_bdist_wininst( - 'reportlab-2.5.win-amd64-py2.7.exe'), ('reportlab-2.5', '2.7', 'win-amd64')) - self.assertEqual(setuptools.package_index.parse_bdist_wininst( - 'reportlab-2.5.win-amd64.exe'), ('reportlab-2.5', None, 'win-amd64')) + parse = setuptools.package_index.parse_bdist_wininst + + actual = parse('reportlab-2.5.win32-py2.4.exe') + expected = 'reportlab-2.5', '2.4', 'win32' + assert actual == expected + + actual = parse('reportlab-2.5.win32.exe') + expected = 'reportlab-2.5', None, 'win32' + assert actual == expected + + actual = parse('reportlab-2.5.win-amd64-py2.7.exe') + expected = 'reportlab-2.5', '2.7', 'win-amd64' + assert actual == expected + + actual = parse('reportlab-2.5.win-amd64.exe') + expected = 'reportlab-2.5', None, 'win-amd64' + assert actual == expected def test__vcs_split_rev_from_url(self): """ @@ -149,8 +159,8 @@ class TestPackageIndex(unittest.TestCase): """ vsrfu = setuptools.package_index.PackageIndex._vcs_split_rev_from_url url, rev = vsrfu('https://example.com/bar@2995') - self.assertEqual(url, 'https://example.com/bar') - self.assertEqual(rev, '2995') + assert url == 'https://example.com/bar' + assert rev == '2995' def test_local_index(self): """ @@ -173,31 +183,30 @@ class TestContentCheckers(unittest.TestCase): checker = setuptools.package_index.HashChecker.from_url( 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478') checker.feed('You should probably not be using MD5'.encode('ascii')) - self.assertEqual(checker.hash.hexdigest(), - 'f12895fdffbd45007040d2e44df98478') - self.assertTrue(checker.is_valid()) + assert checker.hash.hexdigest() == 'f12895fdffbd45007040d2e44df98478' + assert checker.is_valid() def test_other_fragment(self): "Content checks should succeed silently if no hash is present" checker = setuptools.package_index.HashChecker.from_url( 'http://foo/bar#something%20completely%20different') checker.feed('anything'.encode('ascii')) - self.assertTrue(checker.is_valid()) + assert checker.is_valid() def test_blank_md5(self): "Content checks should succeed if a hash is empty" checker = setuptools.package_index.HashChecker.from_url( 'http://foo/bar#md5=') checker.feed('anything'.encode('ascii')) - self.assertTrue(checker.is_valid()) + assert checker.is_valid() def test_get_hash_name_md5(self): checker = setuptools.package_index.HashChecker.from_url( 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478') - self.assertEqual(checker.hash_name, 'md5') + assert checker.hash_name == 'md5' def test_report(self): checker = setuptools.package_index.HashChecker.from_url( 'http://foo/bar#md5=f12895fdffbd45007040d2e44df98478') rep = checker.report(lambda x: x, 'My message about %s') - self.assertEqual(rep, 'My message about md5') + assert rep == 'My message about md5' |