Shmuelt
Shmuelt

Reputation: 151

Pytest not throwing errors where I expect them

When I run the following code, pytest gives me a failure. From my understanding based on the docs and a question I asked on this plugin it should be returning an error.

I made a custom plugin just for this problem and the root of the issue seems to be that both setup and teardown pass, while call fails, hence why it's registering as a failure and not an error. I guess the better question is why doesn't setup fail?

I'm running on windows using pytest 3.1.2. Pip list shouldn't matter, though I will note that I don't have the above mentioned plugin installed and that my custom plugin only prints information.

I'm not sure if this is a bug or just my misunderstanding, so I decided to post both here and on pytest's github. Thank you for the help

import pytest
import unittest

class base(unittest.TestCase):
    def setUp(self):
        raise ValueError

class test(base):
    def test(self):
        print("Hello")

pytest.main()

Upvotes: 1

Views: 360

Answers (1)

Bruno Oliveira
Bruno Oliveira

Reputation: 15245

I posted a detailed answer in pytest-dev/pytest#2677.

Upvotes: 1

Related Questions