Atlas-Download-Tools icon indicating copy to clipboard operation
Atlas-Download-Tools copied to clipboard

Clean up pytest markers

Open jankrepl opened this issue 4 years ago • 7 comments

https://github.com/BlueBrain/Atlas-Download-Tools/blob/829206f9a2a21720bebc8830d51971315fccde27/tox.ini#L70-L83

It seems like the todo and slow markers are not used in the code anymore. Do you think we should keep them? Additionally, there are some tests that requires internet and are not marked with the marker internet. See below an example (maybe there are more?).

https://github.com/BlueBrain/Atlas-Download-Tools/blob/829206f9a2a21720bebc8830d51971315fccde27/tests/test_utils.py#L521-L529

Anyway, I am not sure how useful the internet marker is, however, it can help us identify and filter tests that require it.

jankrepl avatar Aug 26 '21 07:08 jankrepl

How do we want to deal with slow tests?

But I'd suggest to for sure delete not slow from addopts in tox because this way we always skip these tests.

Stannislav avatar Aug 26 '21 08:08 Stannislav

Whoever takes this ticket, would it be possible to add the slow marker to these two tests: https://github.com/BlueBrain/Atlas-Download-Tools/blob/43e77aacaa41b7edba42fd216d24bb0eb2ffda92/tests/test_utils.py#L71-L93

They each take 2-3 seconds.

Stannislav avatar Aug 26 '21 08:08 Stannislav

How do we want to deal with slow tests?

But I'd suggest to for sure delete not slow from addopts in tox because this way we always skip these tests.

Well, I guess I am open to discussion here. My two cents:

Locally, I always run

pytest

Which would currently exclude slow, internet and todo tests. This exclusion results in running essential tests that are fast. Which I like.

One can always dynamically overwrite the markers

pytest -m ""  # runs everything

IMO this could be done in the CI since I would not mind if it takes a couple of extra seconds.

jankrepl avatar Aug 26 '21 08:08 jankrepl

I guess we need a consensus on what we want to run where 😅

  • Locally during dev
  • In CI on PRs
  • In CI on main

I guess at least in one of the three we should run all tests.

Stannislav avatar Aug 26 '21 08:08 Stannislav

Anyway, the todo marker is stupid IMO.

jankrepl avatar Aug 26 '21 08:08 jankrepl

Maybe we can try and find a pytest config in tox.ini that suits all of us for local runs? Running pytest in the shell would then give the optimal output straight away.

My preference (skip slow and internet tests, durations=5, verbosity=0, less spamming in the stdout):

[pytest]
testpaths = tests
addopts =
    -m "not slow and not internet"
    --cov-config=tox.ini
    --no-cov-on-fail
    --color=yes
markers =
    internet: requires connection to the internet
    slow: mark denoting a test that is too slow

How about you? Post your preferred config here and we can try to find an intersection/union :)

Stannislav avatar Aug 30 '21 11:08 Stannislav

But I guess in the CI we

  • should run all marked tests
  • can configure a more complete/verbose output

So, for exampe, in run-tests.yaml we could write

run: tox -vv -e ${{ matrix.tox-env }} -- --color=yes -m "" --cov --durations=20 --verbosity=1

Stannislav avatar Aug 30 '21 11:08 Stannislav