"""develop tests
"""
import os
import re
import shutil
import site
import tempfile
import unittest

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)
        with open('setup.py', 'w') as f:
            f.write(SETUP_PY)
        with open('hi.py', 'w') as f:
            f.write('1\n')
        self.old_base = site.USER_BASE
        site.USER_BASE = tempfile.mkdtemp()
        self.old_site = site.USER_SITE
        site.USER_SITE = tempfile.mkdtemp()

    def tearDown(self):
        os.chdir(self.old_cwd)
        shutil.rmtree(self.dir)
        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):
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['bdist_egg'],
            name='foo',
            py_modules=['hi']
            ))
        os.makedirs(os.path.join('build', 'src'))
        with contexts.quiet():
            dist.parse_command_line()
            dist.run_commands()

        # 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)


@@ -38,65 +38,34 @@
  re%0A
+%0A
 import 
-shutil%0Aimport site%0Aimport tempfile%0Aimport unittest
+pytest%0Aimport mock
 %0A%0Afr
@@ -221,744 +221,709 @@
 %22%22%0A%0A
-class TestDevelopTest(unittest.TestCase):%0A%0A    
+@pytest.yield_fixture%0A
 def 
+u
 se
-tUp(self):%0A        self.dir = tempfile.mkdtemp()%0A        self.old_cwd = os.getcwd()%0A        os.chdir(self.dir)%0A        with open('setup.py', 'w') as f:%0A            f.write(SETUP_PY)%0A        with open('hi.py', 'w') as f:%0A            f.write('1%5Cn')%0A        self.old_base = site.USER_BASE%0A        site.USER_BASE = tempfile.mkdtemp()%0A        self.old_site = site.USER_SITE%0A        site.USER_SITE = tempfile.mkdtemp()%0A%0A    def tearDown(self):%0A        os.chdir(self.old_cwd)%0A        shutil.rmtree(self.dir)%0A        shutil.rmtree(site.USER_BASE)%0A        shutil.rmtree(site.USER_SITE)%0A        site.USER_BASE = self.old_base%0A        site.USER_SITE = self.old_site%0A%0A    def test_bdist_egg(self
+r_override():%0A    %22%22%22%0A    Override site.USER_BASE and site.USER_SITE with temporary directories in%0A    a context.%0A    %22%22%22%0A    with contexts.tempdir() as user_base:%0A        with mock.patch('site.USER_BASE', user_base):%0A            with contexts.tempdir() as user_site:%0A                with mock.patch('site.USER_SITE', user_site):%0A                    yield%0A%0A%0A@pytest.yield_fixture%0Adef setup_context(tmpdir):%0A    with (tmpdir/'setup.py').open('w') as f:%0A        f.write(SETUP_PY)%0A    with (tmpdir/'hi.py').open('w') as f:%0A        f.write('1%5Cn')%0A    with tmpdir.as_cwd():%0A        yield tmpdir%0A%0A%0Aclass TestDevelopTest:%0A    def test_bdist_egg(self, setup_context, user_override
 ):%0A 
@@ -1364,24 +1364,15 @@
     
-self.
 assert
-True(
+ 
 re.m
@@ -1416,73 +1416,5 @@
 ent)
-)%0A%0Adef test_suite():%0A    return unittest.makeSuite(TestDevelopTest)%0A
 %0A

Replace setup and teardown with pytest fixtures.