From 8e8467a5abcaf920184dd07f6e0c092989aa12ff Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Jan 2015 16:23:39 -0500 Subject: Convert test_dist_info to pytest form --- setuptools/tests/test_dist_info.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'setuptools/tests/test_dist_info.py') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index a8adb68c..5f3b5952 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -3,23 +3,17 @@ import os import shutil import tempfile -import unittest import textwrap -try: - import ast -except: - pass +import pytest import pkg_resources -from setuptools.tests.py26compat import skipIf - def DALS(s): "dedent and left-strip" return textwrap.dedent(s).lstrip() -class TestDistInfo(unittest.TestCase): +class TestDistInfo: def test_distinfo(self): dists = {} @@ -34,18 +28,17 @@ class TestDistInfo(unittest.TestCase): assert versioned.version == '2.718' # from filename assert unversioned.version == '0.3' # from METADATA - @skipIf('ast' not in globals(), - "ast is used to test conditional dependencies (Python >= 2.6)") + @pytest.mark.importorskip('ast') def test_conditional_dependencies(self): requires = [pkg_resources.Requirement.parse('splort==4'), pkg_resources.Requirement.parse('quux>=1.1')] for d in pkg_resources.find_distributions(self.tmpdir): - self.assertEqual(d.requires(), requires[:1]) - self.assertEqual(d.requires(extras=('baz',)), requires) - self.assertEqual(d.extras, ['baz']) + assert d.requires() == requires[:1] + assert d.requires(extras=('baz',)) == requires + assert d.extras == ['baz'] - def setUp(self): + def setup_method(self, method): self.tmpdir = tempfile.mkdtemp() versioned = os.path.join(self.tmpdir, 'VersionedDistribution-2.718.dist-info') @@ -79,5 +72,5 @@ class TestDistInfo(unittest.TestCase): finally: metadata_file.close() - def tearDown(self): + def teardown_method(self, method): shutil.rmtree(self.tmpdir) -- cgit v1.2.1