在类中使用python中的@attr

时间:2014-08-27 06:47:11

标签: python

我正在浏览开放堆栈的Tempest代码。我在类中看到了一些语法@,如下所示。有人可以给我一个正确的链接,我可以在上面了解为什么使用这个@。

  @classmethod
      def setUpClass(cls):
      cls.set_network_resources()
      super(TestLargeOpsScenario, cls).setUpClass()

甚至是这样,

  @attr(type='smoke')
  def test_update_setver_name(self):
        name = rand_server('server')

那么@ over在这里的用途是什么?

2 个答案:

答案 0 :(得分:1)

来自python docs:

Python Doc

或之前的stackoverflow问题:

Previously answered question

答案 1 :(得分:0)

@attr,装饰者DP。 更多有关Decorator DP的理解,例如: http://thecodeship.com/patterns/guide-to-python-function-decorators/