-
Notifications
You must be signed in to change notification settings - Fork 9
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
Bootstrap Unit Test framework #412
Conversation
- Readme - Vscode settings - test_hello.py example - tox.ini configuration via simple `tox -e unit` run
Foresight Summary
View More Details✅ CI workflow has finished in 40 seconds and finished at 1st Mar, 2023.
*You can configure Foresight comments in your organization settings page. |
|
||
# Unit tests | ||
# https://docs.python.org/3/library/unittest.html | ||
# Run: | ||
# tox -e unit | ||
[testenv:unit] | ||
commands = | ||
python3 -m unittest discover --verbose --top-level-directory scripts --start-directory scripts/tests/unit --pattern "test_*.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out, this part was the hardest that took us a lot of time debugging to make the imports work with the directory structure and tests residing in the scripts/plugins/unit/tests/
directory.
Notice the --top-level-directory scripts
and --start-directory scripts/tests/unit
parameters.
.vscode/settings.json
Outdated
// Configuration for running unit tests with the Python extension for VS Code | ||
// https://code.visualstudio.com/docs/python/unit-testing | ||
{ | ||
"python.testing.unittestArgs": [ | ||
"--verbose", | ||
"--top-level-directory", | ||
"scripts", | ||
"--start-directory", | ||
"./scripts/tests/unit", | ||
"--pattern", | ||
"test_*.py" | ||
], | ||
"python.testing.pytestEnabled": false, | ||
// Uses the unittest module | ||
// https://docs.python.org/3/library/unittest.html | ||
"python.testing.unittestEnabled": true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
With this setup the imports work fine as we use them in BitOps core, eg. Adding the first BitOps-related tests results in an error:
bitops/scripts/plugins/logging.py Line 113 in cefdba3
So it's something to handle in future PRs. |
Part of the #286
Based on #411 meeting, we explored adding a unit test framework to the BitOps and setting up first test examples.
This PR adds an initial structure for running the Python unit tests with some basic "hello world" example to start with.
tox -e unit
runtest_hello.py
exampleadd a realistic test related to BitOps codebase