Skip to content

Remove reference to bin when importing modules in some unit tests (BugFix)#874

Merged
Hook25 merged 1 commit intomainfrom
fix-unit-test-imports
Dec 13, 2023
Merged

Remove reference to bin when importing modules in some unit tests (BugFix)#874
Hook25 merged 1 commit intomainfrom
fix-unit-test-imports

Conversation

@pieqq
Copy link
Copy Markdown
Collaborator

@pieqq pieqq commented Dec 6, 2023

When running ./manage.py test -u from the provider, unittest is made aware of the content of the bin/ directory so Python code from this directory can be imported directly.

Description

When preparing a presentation about unit testing in Checkbox, I found that some unit tests import scripts from bin, which is not required when running unit tests the usual way (./manage.py test -u).

Resolved issues

Running unit tests locally using the ./manage.py test -u command.

Tests

  • Tests are passing when running the ./manage.py test -u command from the base provider directory in a venv.
  • Single test files can be executed, for example PYTHONPATH=~/checkbox/providers/base/bin python -m unittest test_camera_quality.py from the providers/base/tests/ directory.

When running `./manage.py test -u` from the provider, unittest is made
aware of the content of the bin/ directory so Python code from this
directory can be imported directly.
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8d1f256) 35.70% compared to head (4d02a31) 35.70%.
Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #874   +/-   ##
=======================================
  Coverage   35.70%   35.70%           
=======================================
  Files         303      303           
  Lines       34250    34250           
  Branches     5917     5917           
=======================================
  Hits        12230    12230           
  Misses      21458    21458           
  Partials      562      562           
Flag Coverage Δ
provider-base 5.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Collaborator

@Hook25 Hook25 left a comment

Choose a reason for hiding this comment

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

+1, nice catch

@Hook25 Hook25 merged commit 32448d5 into main Dec 13, 2023
@Hook25 Hook25 deleted the fix-unit-test-imports branch December 13, 2023 10:03
kissiel pushed a commit that referenced this pull request Dec 13, 2023
…gFix) (#874)

Remove reference to bin when importing modules in some unit tests

When running `./manage.py test -u` from the provider, unittest is made
aware of the content of the bin/ directory so Python code from this
directory can be imported directly.
kissiel pushed a commit that referenced this pull request Dec 13, 2023
…gFix) (#874)

Remove reference to bin when importing modules in some unit tests

When running `./manage.py test -u` from the provider, unittest is made
aware of the content of the bin/ directory so Python code from this
directory can be imported directly.
binli pushed a commit to binli/checkbox that referenced this pull request Mar 22, 2024
…gFix) (canonical#874)

Remove reference to bin when importing modules in some unit tests

When running `./manage.py test -u` from the provider, unittest is made
aware of the content of the bin/ directory so Python code from this
directory can be imported directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants