-
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
Changes from 3 commits
c851f63
82283ec
bab5712
a43e425
c36c7ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 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 | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# BitOps Unit Tests | ||
|
||
This directory contains tests for the BitOps core. | ||
We use the built-in [`unittest`](https://docs.python.org/3/library/unittest.html) module as a framework for testing. | ||
|
||
## Running the tests | ||
The testing command is defined in [`tox.ini`](../../tox.ini) and can be run with `tox`: | ||
```bash | ||
tox -e unit | ||
``` | ||
|
||
## VSCode Configuration | ||
The repository contains a `.vscode/settings.json` file that configures VSCode to auto-discover the tests and run the test suite. | ||
|
||
 | ||
|
||
See [Python Testing in VSCode](https://code.visualstudio.com/docs/python/testing) for more information. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import unittest | ||
|
||
|
||
class TestHello(unittest.TestCase): | ||
"""Basic test example demonstrating the hello world.""" | ||
|
||
def test_hello(self): | ||
"""Test hello world.""" | ||
self.assertEqual(True, True) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,11 @@ commands = | |
skip_install = True | ||
commands = | ||
pylint scripts/ | ||
|
||
# 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" | ||
Comment on lines
+36
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Notice the |
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.
I've also included the VSCode project-level

settings.json
.Should help to get the unit-tests auto-discovered here with zero hassle: