在运行时期间从上下文获取pytest名称和参数

时间:2016-04-05 11:55:19

标签: python python-2.7 testing pytest

据我所知,有一种方法可以在运行时运行测试的名称和参数,使用PyTest with fixture' request':

def test_example(request):
   print 'name: %s' % request.node.name
   print 'params: %s' % request.node.funcargs

有没有办法从静态上下文中获取相同的信息? 我试图编写一个能够返回相同信息的静态方法:

def static_method():
   if not RandomPytestClass.context:
      return None
   return RandomPytestClass.context.running_test_name, RandomPytestClass.context.running_test_params

0 个答案:

没有答案