0

Code is the following:

import pytest

@pytest.mark.parametrize("x", [0, 1])
@pytest.mark.parametrize("y", [2, 3])

def test_foo(x, y):
    assert x > y

But by running the test system gives:

Process finished with exit code 0

Does someone know why it does not work?

Dino
  • 7,779
  • 12
  • 46
  • 85
Dober
  • 1
  • Hi and welcome to stackoverflow, please take a look at this article https://stackoverflow.com/help/mcve also please edit your question by adding more details about your problem – Fourat Sep 30 '19 at 07:36

2 Answers2

1

I've run your code and it is working fine and giving Assertion error as well.

Here, it seems that you are running the test as normal python file.

You need to run your file as pytest test. For that you need to setup pytest configuration.

In pycharm, Go to Run -> Edit Configurations... Then click the + in the upper left of the modal dialog. Select "python tests" -> py.test Then I give it a name like "All test with py.test"

select Target: module name or path to your test file > click on OK

Now from Run menu select run "All test with py.test" or press shift+ f10

Help link : How do I configure PyCharm to run py.test tests?

Chanda Korat
  • 2,453
  • 2
  • 19
  • 23
0

Try out this code:

import pytest
@pytest.mark.parametrize(params=["x", [0, 1]])
def test_foo(x, y): 
    assert x > y
Ishan Joshi
  • 487
  • 3
  • 7