V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
pyse
V2EX  ›  Python

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

  •  
  •   pyse · 2018-06-25 12:57:34 +08:00 · 1343 次点击
    这是一个创建于 2125 天前的主题,其中的信息可能已经有所发展或是发生改变。

    伪代码 ,只帖了关键部分

    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
    
    2 条回复    2018-10-31 09:08:59 +08:00
    pyse
        1
    pyse  
    OP
       2018-06-25 20:37:39 +08:00
    没有人知道吗?
    pyse
        2
    pyse  
    OP
       2018-10-31 09:08:59 +08:00
    挖坟
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5052 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 09:35 · PVG 17:35 · LAX 02:35 · JFK 05:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.