当前位置: 首页>>代码示例>>Python>>正文


Python Recipe.get_release方法代码示例

本文整理汇总了Python中djangorecipe.recipe.Recipe.get_release方法的典型用法代码示例。如果您正苦于以下问题:Python Recipe.get_release方法的具体用法?Python Recipe.get_release怎么用?Python Recipe.get_release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在djangorecipe.recipe.Recipe的用法示例。


在下文中一共展示了Recipe.get_release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestRecipe

# 需要导入模块: from djangorecipe.recipe import Recipe [as 别名]
# 或者: from djangorecipe.recipe.Recipe import get_release [as 别名]

#.........这里部分代码省略.........
        self.recipe.options['pth-files'] = 'somedir'

        self.recipe.install()
        self.assertEqual(addsitedir.call_args, (('somedir', set([])), {}))
        # The extra-paths option has been extended.
        self.assertEqual(self.recipe.options['extra-paths'], '\nextra\ndirs')

    def test_create_wsgi_script_projectegg(self):
        # When a projectegg is specified, then the egg specified
        # should get used as the project in the wsgi script.
        wsgi = os.path.join(self.bin_dir, 'django.wsgi')
        recipe_dir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..'))
        self.recipe.options['projectegg'] = 'spameggs'
        self.recipe.options['wsgi'] = 'true'
        self.recipe.make_scripts([recipe_dir], [])
        self.assert_(os.path.exists(wsgi))
        # Check that we have 'spameggs' as the project
        self.assert_('spameggs.development' in open(wsgi).read())

    def test_settings_option(self):
        # The settings option can be used to specify the settings file
        # for Django to use. By default it uses `development`.
        self.assertEqual(self.recipe.options['settings'], 'development')
        # When we change it an generate a manage script it will use
        # this var.
        self.recipe.options['settings'] = 'spameggs'
        self.recipe.create_manage_script([], [])
        manage = os.path.join(self.bin_dir, 'django')
        self.assert_("djangorecipe.manage.main('project.spameggs')"
                     in open(manage).read())

    @mock.patch('urllib2', 'urlopen')
    def test_get_release(self, mock):
        # The get_release method fecthes a release tarball and
        # extracts it. We have setup a mock so that it won't actually
        # download the release. Let's call the code.
        class FakeFile(object):
            def read(self):
                return 'Django tarball'
            def close(self):
                self.closed = True

        tmp = tempfile.mkdtemp()
        filename = os.path.join(tmp, 'django-0.96.2.tar.gz')
        mock.return_value = FakeFile()
        try:
            self.assertEqual(
                self.recipe.get_release('0.96.2', tmp),
                filename)
            # It tried to download the release through our mock
            mock.assert_called_with(
                'http://www.djangoproject.com/download/0.96.2/tarball/')
            # The file should have been filled with the contents from the
            # handle it got.
            self.assertEqual(open(filename).read(), 'Django tarball')
        finally:
            shutil.rmtree(tmp)

    @mock.patch('setuptools.archive_util', 'unpack_archive')
    @mock.patch('shutil', 'move')
    @mock.patch('shutil', 'rmtree')
    @mock.patch('os', 'listdir')
    def test_install_release(self, unpack, move, rmtree, listdir):
        # To install a release the recipe uses a specific method. We
        # have have mocked all the calls which interact with the
开发者ID:attilaolah,项目名称:djangorecipe,代码行数:70,代码来源:tests.py


注:本文中的djangorecipe.recipe.Recipe.get_release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。