PyCharm errors for valid python code

孤街浪徒 提交于 2019-12-13 08:03:11

问题


I posted the following question regarding nose and parameterized tests:

use-class-method-in-nose-parameterize.expand call

and I got my answer, but now I wonder why PyCharm is failing to recognize this as valid code. Does anyone know how to turn off this warning in Pycharm, or should i submit this as a bug to jet brains?

Here is what I know works, but PyCharm provides false negative error messages:

class MyUnitTestClass(TestCase):
  def generate_scenarios():
    yield ('this_is_my_test', 1, 2)

  @parameterized.expand(generate_scenarios())
  def test_scenario(self, test_name, input, expected_output):
    self.assertEquals(input+input, expected_output) 

回答1:


you can suppress anything you want in pycharm

  1. put the cursor right in between the parentheses (where it is underlined in red)
  2. press alt+enter to bring up suggestions
  3. press the right arrow key on the "Add self" line at the top of the suggestions
  4. select the option to suppress error

see also: https://www.jetbrains.com/pycharm/help/suppressing-inspections.html



来源:https://stackoverflow.com/questions/30943408/pycharm-errors-for-valid-python-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!