unittest 中 parameterized 不能传递其他方法的返回值吗?

2018-06-25 12:57:34 +08:00
 pyse

伪代码 ,只帖了关键部分

class test(unittest.TestCase):

def tobase64(self, img):
        with open(img, "rb") as f:
            base64_img = base64.b64encode(f.read())
            baseimg = str(base64_img).split("'")[1]
            return baseimg

@parameterized.expand([('', '', '', '200'),
                           ('', '123', '', '200'),
                           (self.tobase64(img), str(uuid.uuid4()), 0, 000)])
def test_case1(self):
      pass

报错如下:

  File "E:\intellif\shijuPK\sjpk.py", line 41, in PK
    (self.tobase64(img), str(uuid.uuid4()), 0, 000)])
NameError: name 'self' is not defined
1384 次点击
所在节点    Python
2 条回复
pyse
2018-06-25 20:37:39 +08:00
没有人知道吗?
pyse
2018-10-31 09:08:59 +08:00
挖坟

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/465619

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX