推荐学习书目
› 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 · Jun 25, 2018 · 1854 views
    This topic created in 3013 days ago, the information mentioned may be changed or developed.

    伪代码 ,只帖了关键部分

    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 replies  •  2018-10-31 09:08:59 +08:00
    pyse
        1
    pyse  
    OP
       Jun 25, 2018
    没有人知道吗?
    pyse
        2
    pyse  
    OP
       Oct 31, 2018
    挖坟
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   838 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 21:36 · PVG 05:36 · LAX 14:36 · JFK 17:36
    ♥ Do have faith in what you're doing.