小编Oct*_*ian的帖子

在 Python 中测试抽象类

我使用Python(2.7)中的抽象类创建了一个类,现在我想通过Nose测试这个类。技术上如何实现?

这里我给出一个示例代码:

# -*- coding: utf-8 -*-
from abc import ABCMeta, abstractmethod, abstractproperty


class A(object):

    __metaclass__ = ABCMeta

    @abstractproperty
    def a(self):
        pass

    @abstractmethod
    def do(self, obj):
        pass
Run Code Online (Sandbox Code Playgroud)

python unit-testing nose

5
推荐指数
1
解决办法
3901
查看次数

标签 统计

nose ×1

python ×1

unit-testing ×1