Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Switch from nosetest to pytest #10177

Merged
merged 11 commits into from Jun 29, 2020

Conversation

bkyryliuk
Copy link
Member

@bkyryliuk bkyryliuk commented Jun 26, 2020

Changed test runner from nosetests to pytest
Tox locally seems to be working just fine and contributor instructions don't need to change.

Changes:

  1. changed runner from nosetests to pytest
  2. added pytest.ini for global pytest controls
  3. updated run.sh and tox not to compute the coverage
  4. updated test classes to start with Test_ and not too have init method

Naming conventions:

Testing

  • Made sure that test coverage stays the same
  • Validated that tests match to the nosetest via pytest --collect-only

@bkyryliuk bkyryliuk marked this pull request as draft June 26, 2020 21:12
@bkyryliuk bkyryliuk changed the title [WIP] Switch from nosetest to pytest feat: [WIP] Switch from nosetest to pytest Jun 26, 2020
@bkyryliuk bkyryliuk changed the title feat: [WIP] Switch from nosetest to pytest feat: Switch from nosetest to pytest Jun 26, 2020
@bkyryliuk bkyryliuk marked this pull request as ready for review June 26, 2020 23:09
@ktmud
Copy link
Member

ktmud commented Jun 26, 2020

  1. Code coverage is missing

  2. Might want to remove nosetests from pip dependencies and clean this up as well.

@bkyryliuk
Copy link
Member Author

  1. Code coverage is missing
  2. Might want to remove nosetests from pip dependencies and clean this up as well.

@ktmud good catch. Will do the 1. As for point 2 - I changed nosetests there to the tool:pytest

@ktmud
Copy link
Member

ktmud commented Jun 26, 2020

Ah, sorry for missing that. Are those nosetests options in setup.cfg also valid for pytest as well?

@bkyryliuk
Copy link
Member Author

Ah, sorry for missing that. Are those nosetests options in setup.cfg also valid for pytest as well?

@ktmud taking into account that we want to modify the local tests vs CI behavior that section is probably not needed.
Can you take another look at the PR?
I've modified it to run test coverage only in the python_tests.sh

Copy link
Member

@ktmud ktmud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM! Do you know why did Codecov say overall coverage dropped by 17.79%?

@@ -23,5 +23,5 @@ echo "Superset config module: $SUPERSET_CONFIG"

superset db upgrade
superset init
nosetests --stop tests/load_examples_test.py
nosetests --stop --exclude=load_examples_test tests
pytest --maxfail=1 tests/load_examples_test.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want coverage for this file as well? I don't think it's needed but it was covered in previous setup.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my preference is not to count it, to me this is more a fixture setup rather than an actual test.
However do not have a preference here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://codecov.io/gh/apache/incubator-superset/pull/10177/commits - looks like it was the reason for dropped coverage - will keep playing with it

@apache apache deleted a comment from codecov-commenter Jun 27, 2020
@bkyryliuk
Copy link
Member Author

Code LGTM! Do you know why did Codecov say overall coverage dropped by 17.79%?
old run, will try to see how can I trigger it again

@bkyryliuk bkyryliuk force-pushed the bogdan/pytest_runner branch 2 times, most recently from 85296ad to eaafbb7 Compare June 28, 2020 00:36
@bkyryliuk bkyryliuk marked this pull request as ready for review June 28, 2020 00:37
@bkyryliuk
Copy link
Member Author

@ktmud and @john-bodley could you please take another look?
I've missed some tests in the original implementation and had to do extra changes to the test class names.

@ktmud
Copy link
Member

ktmud commented Jun 28, 2020

Codecov seems to be stuck at "waiting for CI to complete", just like in #10142 . If you can get it fixed, that'd be great. If not, we can probably just merge this as is and see if it's a recurring issue in the next PR.

There were also some deprecation warnings in the logs that might worth fixing (could be in another PR):

tests/security_tests.py::TestRolePermission::test_set_perm_slice
  /home/runner/work/incubator-superset/incubator-superset/tests/security_tests.py:425: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(slice.schema_perm, table.schema_perm)

@bkyryliuk
Copy link
Member Author

Codecov seems to be stuck at "waiting for CI to complete", just like in #10142 . If you can get it fixed, that'd be great. If not, we can probably just merge this as is and see if it's a recurring issue in the next PR.

There were also some deprecation warnings in the logs that might worth fixing (could be in another PR):

tests/security_tests.py::TestRolePermission::test_set_perm_slice
  /home/runner/work/incubator-superset/incubator-superset/tests/security_tests.py:425: DeprecationWarning: Please use assertEqual instead.
    self.assertEquals(slice.schema_perm, table.schema_perm)

@ktmud this is interesting, report is generated on their side: https://codecov.io/gh/apache/incubator-superset/pull/10177
however was not send to update the PR, will amend the PR and see if it fixes it.

@codecov-commenter
Copy link

Codecov Report

Merging #10177 into master will decrease coverage by 0.14%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10177      +/-   ##
==========================================
- Coverage   65.84%   65.69%   -0.15%     
==========================================
  Files         594      594              
  Lines       31486    31492       +6     
  Branches     3222     3223       +1     
==========================================
- Hits        20732    20689      -43     
- Misses      10574    10623      +49     
  Partials      180      180              
Flag Coverage Δ
#javascript 59.42% <ø> (+<0.01%) ⬆️
#python 70.16% <ø> (-0.26%) ⬇️
Impacted Files Coverage Δ
superset/examples/birth_names.py 77.77% <0.00%> (-22.23%) ⬇️
superset/examples/unicode_test_data.py 81.63% <0.00%> (-18.37%) ⬇️
superset/examples/energy.py 84.61% <0.00%> (-15.39%) ⬇️
superset/examples/world_bank.py 84.61% <0.00%> (-15.39%) ⬇️
superset/examples/helpers.py 85.00% <0.00%> (-12.50%) ⬇️
superset/examples/css_templates.py 89.47% <0.00%> (-10.53%) ⬇️
superset/dashboards/dao.py 91.26% <0.00%> (-0.98%) ⬇️
superset/cli.py 39.72% <0.00%> (-0.35%) ⬇️
...erset-frontend/src/SqlLab/components/ResultSet.jsx 70.24% <0.00%> (-0.10%) ⬇️
superset/views/database/api.py 87.50% <0.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4342c33...d083dc9. Read the comment docs.

@bkyryliuk bkyryliuk merged commit 4e340c8 into apache:master Jun 29, 2020
@bkyryliuk bkyryliuk deleted the bogdan/pytest_runner branch June 29, 2020 22:36
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* Switch from nosetest to pytest

Fix schedule tests

Collect pytest coverage

Move pytest config into pytest.ini

Move cov to the pytest.ini

* Append coverage for the 2nd run

* Add coverage to all commands

* Coverage only for tests

* Get coverage from 1 place

* Rename classes to be  pytest compatible

* Test coverage for examples and tests

* Max diff to -1

* Explain how to run pytest for the whole project

* Do not append code coverage for the main run

* Do not run coverage on examples

Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants