Python
文章平均质量分 77
zhaoeryi
zhaoeryi@hotmail.com
展开
-
Python中的 "import" 和 "from ... import"
在python中, 怎么选择使用"import" 或者"from .. import" 呢无论使用哪种import方式, 都必须满足只import module, 不import module中的对象让后面的代码可以直接使用不包含package的module name. Bad (没import module, 而是import了module中的server函数)原创 2014-08-07 16:16:39 · 771 阅读 · 0 评论 -
Magic words in Python
http://www.rafekettler.com/magicmethods.html原创 2014-08-06 15:13:54 · 779 阅读 · 0 评论 -
subunit 协议
subunit protocolSubunit is a streaming protocol for test results. Subunit Version 2 isa binary protocol consisting of independent packets. The packets that can be embeddedin the output from t原创 2014-08-07 18:36:03 · 2477 阅读 · 0 评论 -
简单的 Nova REST API 实现程序
正在看Nova API的代码, 仿照其中的REST 实现逻辑写了一个测试程序. 大概的调用顺序是: Python Delopy -- > MyRouter --> routes.middleware.RoutesMiddleware --> MyApplication --> MyController和这个最简单的程序相比, Nova API 支持了更多的功能, 例如XML/JSON序列化原创 2014-08-22 18:27:07 · 2151 阅读 · 0 评论 -
Python中的下划线
总结如下:1) 前带一个"_"的变量: 私有变量. 前面带有一个"_"的变量, 但是并没有真正的封装隐藏, 外部还是可以访问2) 后面带有一个"_"的变量, 为了避免和Python中已有的关键字冲突3) 前后各有两个"_"的变量, 代表Python中的Magic Word_single_leading_underscore: 私有变量. sin原创 2014-09-01 18:07:53 · 872 阅读 · 0 评论 -
Python 中的 fixture 和 fixtures
1 Fixture 概念Fixture是测试中的概念:Fixture 指的是测试中依赖的数据和条件等等Python的 unittest 库提供了对 fixture的一些支持每个TestCase 应该在setUp中, 自己负责资源的创建, 例如class MyTestCase(unittest.TestCase): def my_fixture_setup(self):原创 2014-09-15 16:05:24 · 9153 阅读 · 0 评论 -
使用 Python 的 jsonschema 对 json 做验证
在OpenStack中, 使用了Python的 jsonschema包, Python JSON Schema Library https://pypi.python.org/pypi/jsonschema JSON Schema Introductionhttp://json-schema.org/原创 2014-08-13 18:12:25 · 9475 阅读 · 0 评论 -
Python 中的 unit test 流程
Python 中的 unit test 流程看了看Python中的单元测试流程, 写了个测试代码来看整体的测试流程总结如下一个 test case 类应该派生自 unittest.TestCase正常的的test case的调用顺序为子类TestCase可以注册自己的清理函数(my_cleanup). 这个清理函数会在teardown之后被调用原创 2014-09-02 17:59:37 · 3388 阅读 · 0 评论