美文网首页
tox测试 笔记

tox测试 笔记

作者: 笨手笨脚越 | 来源:发表于2017-06-27 10:25 被阅读166次

测试文件需要test_作为前缀,比如 test_storages.py

进行tox测试:

  1. 进入虚拟环境
[ubuntu@localhost cinder]$ . .tox/py27/bin/activate

  1. 使用指令运行测试程序
(py27) [ubuntu@localhost cinder]$ ostestr cinder.tests.unit.storages.db.test_storages.StorageTestCase.test_storage_destroy_not_found_storage
  • ostestr 不可进行pdb调试
(py27) [ubuntu@localhost cinder]$ python -m testtools.run test_storages.StorageTestCase.test_storage_create_not_found_device
  • python -m testtools.run 可以进行pdb调试
  1. 退出虚拟环境
(py27) [ubuntu@localhost cinder]$ deactivate

cinder测试源码test.py里定义了默认数据库连接sqlite,我们要修成mysql更适合我们的测试:

cinder\test.py:

def setUp(self):

        # 配置内存数据库,此段注释掉,不然会连接sqlite作为数据库
        # CONF.set_default('connection', 'sqlite://', 'database')
        # CONF.set_default('sqlite_synchronous', False, 'database')

        # global _DB_CACHE
        # if not _DB_CACHE:
        #     _DB_CACHE = Database(sqla_api, migration,
        #                          sql_connection=CONF.database.connection)
        # self.useFixture(_DB_CACHE)
        
        # 配置mysql连接
        CONF.set_default('connection', 'mysql+pymysql://root:secret@127.0.0.1/cinder?charset=utf8', 'database')

相关文章

  • tox测试 笔记

    测试文件需要test_作为前缀,比如 test_storages.py 进行tox测试: 进入虚拟环境 使用指令运...

  • openstack测试之testr和tox

    openstack 测试之 testr and tox testr testr用于运行python测试仓库的测试用...

  • Python 任务自动化工具 tox 教程

    在我刚翻译完的 Python 打包系列文章中,作者提到了一个神奇的测试工具 tox,而且他本人就是 tox 的维护...

  • Tox - 使用介绍

    1. 概述 tox是通用的虚拟环境管理和测试命令行工具。tox能够让我们在同一个Host上自定义出多套相互独立且隔...

  • tox

    https://tox.readthedocs.io/en/latest/install.html Tox 是个标...

  • Tox

    Tox 是一款即时通信软件,可以语音、也可以视频。"保护我们剩下的人的通话信息安全" 安全 有效避免来自政府的网络...

  • Pytest - 如何mock一个装饰器decorator

    1. 概述 Python项目的自动化单元测试,可以通过Tox和Pytest完成,提高Python项目的可维护性和健...

  • 利用tox打造自动自动化测试框架

    什么是tox tox官方文档的第一句话 standardize testing in Python,意思就是说标准...

  • tox工具

    官方文档 : http://tox.readthedocs.io/en/latest/example/basic....

  • 测试一下笔记

    测试一下笔记测试一下笔记测试一下笔记测试一下笔记测试一下笔记测试一下笔记测试一下笔记

网友评论

      本文标题:tox测试 笔记

      本文链接:https://www.haomeiwen.com/subject/tugscxtx.html