aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_bdist_egg.py
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/tests/test_bdist_egg.py')
-rw-r--r--setuptools/tests/test_bdist_egg.py54
1 files changed, 13 insertions, 41 deletions
diff --git a/setuptools/tests/test_bdist_egg.py b/setuptools/tests/test_bdist_egg.py
index 937e0ed0..f8a68378 100644
--- a/setuptools/tests/test_bdist_egg.py
+++ b/setuptools/tests/test_bdist_egg.py
@@ -2,53 +2,32 @@
"""
import os
import re
-import shutil
-import site
-import sys
-import tempfile
-import unittest
import six
+import pytest
-from distutils.errors import DistutilsError
-from setuptools.command.bdist_egg import bdist_egg
-from setuptools.command import easy_install as easy_install_pkg
from setuptools.dist import Distribution
+from . import contexts
+
SETUP_PY = """\
from setuptools import setup
setup(name='foo', py_modules=['hi'])
"""
-class TestDevelopTest(unittest.TestCase):
-
- def setUp(self):
- self.dir = tempfile.mkdtemp()
- self.old_cwd = os.getcwd()
- os.chdir(self.dir)
- f = open('setup.py', 'w')
+@pytest.yield_fixture
+def setup_context(tmpdir):
+ with (tmpdir/'setup.py').open('w') as f:
f.write(SETUP_PY)
- f.close()
- f = open('hi.py', 'w')
+ with (tmpdir/'hi.py').open('w') as f:
f.write('1\n')
- f.close()
- if sys.version >= "2.6":
- self.old_base = site.USER_BASE
- site.USER_BASE = tempfile.mkdtemp()
- self.old_site = site.USER_SITE
- site.USER_SITE = tempfile.mkdtemp()
+ with tmpdir.as_cwd():
+ yield tmpdir
- def tearDown(self):
- os.chdir(self.old_cwd)
- shutil.rmtree(self.dir)
- if sys.version >= "2.6":
- shutil.rmtree(site.USER_BASE)
- shutil.rmtree(site.USER_SITE)
- site.USER_BASE = self.old_base
- site.USER_SITE = self.old_site
- def test_bdist_egg(self):
+class Test:
+ def test_bdist_egg(self, setup_context, user_override):
dist = Distribution(dict(
script_name='setup.py',
script_args=['bdist_egg'],
@@ -56,17 +35,10 @@ class TestDevelopTest(unittest.TestCase):
py_modules=['hi']
))
os.makedirs(os.path.join('build', 'src'))
- old_stdout = sys.stdout
- sys.stdout = o = six.StringIO()
- try:
+ with contexts.quiet():
dist.parse_command_line()
dist.run_commands()
- finally:
- sys.stdout = old_stdout
# let's see if we got our egg link at the right place
[content] = os.listdir('dist')
- self.assertTrue(re.match('foo-0.0.0-py[23].\d.egg$', content))
-
-def test_suite():
- return unittest.makeSuite(TestDevelopTest)
+ assert re.match('foo-0.0.0-py[23].\d.egg$', content)