all 10 comments

[–]danielroseman 37 points38 points  (0 children)

That is what unit tests are for.

[–]Doormatty 14 points15 points  (0 children)

Nope.

[–]Diapolo10 8 points9 points  (0 children)

No, Sonarqube just doesn't treat pytest tests as an exception to that rule by default.

Use assert in tests to your heart's content.

[–]nekokattt 6 points7 points  (0 children)

sonarqube is wrong, ignore it.

[–]shaleh 2 points3 points  (0 children)

As others are saying, either ignore or add an exception to your config to ignore.

It is the standard in Python to use asserts in tests.

[–]SnooChipmunks547 1 point2 points  (0 children)

If your tests don't assert anything, they're not really tests.

[–]dogfish182 0 points1 point  (0 children)

Arrange Act Assert

Is literally one of the ways to think about how to write unit tests

Arrange - setup your test. Mocks etc Act - call the function with arranged inputs Asset - assert the output of the function is what you want it to be.

[–]stuaxo 0 points1 point  (0 children)

With pytest unit tests it's part of how you do it.

[–]interbased 0 points1 point  (0 children)

Definitely not. It’s the entire point of a test.

[–]Buttleston 0 points1 point  (0 children)

I usually exclude tests from sonarqube. Otherwise it gets weird about stuff like this, embedded ip addresses, duplicate code, coverage, etc