0

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) 
Community
  • 1
  • 1
Nathan Tregillus
  • 6,006
  • 3
  • 52
  • 91

1 Answers1

0

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

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
  • That makes it a class method, and nose parameterized is looking for a static method in scope. This won't work – Nathan Tregillus Jun 20 '15 at 19:10
  • 2
    @NathanTregillus then you have done something wrong, because suppressing an error doesn't change your code. – jonrsharpe Jun 20 '15 at 19:25
  • please try this out on the example code shown within the linked question. I tried what you are describing and nose.parameterized blows up attempting to create the tests. – Nathan Tregillus Jun 21 '15 at 21:40
  • 1
    I did exactly that ... both with the error highlight, and while I was suppressing the error highlight, I got `output---------------------------------------------------------------------- Ran 1 test in 0.001s OK` ... I should add this was a big pain in the ass since i didnt already have any of the nosetest stuff on this box and had to install it all ... – Joran Beasley Jun 21 '15 at 22:44
  • let me clarify, step 3 states to "add self" this modifies the code, which nose.parameterized does now recognize, it is looking for a function that does not take any parameters. @JoranBeasley, I attempted to follow these steps and the test fails, again due to the self parameter not being passed in. what version of nose did you use? – Nathan Tregillus Jun 22 '15 at 18:44
  • __press the right arrow key on the "Add self" line at the top of the suggestions__ ... it does not say "SELECT" it or click it or any variation other than pressing the right arrow key on your keyboard .. just press the right arrow and move on to step 4 ... – Joran Beasley Jun 22 '15 at 21:18