-
Notifications
You must be signed in to change notification settings - Fork 138
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
Pytest related changes #248
Merged
Merged
Changes from 23 commits
Commits
Show all changes
113 commits
Select commit
Hold shift + click to select a range
4f244d3
Adapt project to run tests with pytest.
sstrehlk 4094609
Update requirements.txt
sstrehlk cfd9e93
updated tests marking
sstrehlk fbe66bd
Update conftest.py
sstrehlk daca7b8
Update conftest.py
sstrehlk 2f13f6e
Added test_marking manual.
sstrehlk f80eea5
Cosmetic corrections in test_marking.md
sstrehlk aab6bd7
adapting cli/test_yolo_format.py for pytest
sstrehlk 45e9470
Updated test_yolo_format.py
sstrehlk 46e1fe7
Corrected datumaro_components.py, updated license in added files.
sstrehlk bd8a335
Updated test_marking.md file
sstrehlk f0f343b
Updated test_marking.md file
sstrehlk 7df661c
Updates after review.
sstrehlk ea804b1
Removed unnecessary marking.
sstrehlk 7cc26a6
removed unneeded comments in requirements.py
sstrehlk e7d845a
Corrected requirement constant.
sstrehlk 299cc26
experiment related to test_can_import test.
sstrehlk 60ace83
Corrected accidentally changed indentation.
sstrehlk cfeb7d9
Updated .travis.yml to work with pytest
sstrehlk e98f5e3
Updated .travis.yml to work with pytest.
sstrehlk fe8e510
Updated .gitignore, .travis.yml
sstrehlk f0fe579
Updated .travis.yml to check pytest performance in Travis.
sstrehlk 9a164ce
Updated .travis.yml and requirements.txt.
sstrehlk bb3dd8a
Merged two imports into one line in test files.
sstrehlk 38a9abd
Removed unneded __test__ variable.
sstrehlk 9b30e6f
Corrections in names and formatting.
sstrehlk 5bbb754
Implemented and used mark_requirement decorator
sstrehlk 1c72c0a
Adapt project to run tests with pytest.
sstrehlk 84dd16b
Update requirements.txt
sstrehlk b66fd2b
updated tests marking
sstrehlk 1b38dc5
Update conftest.py
sstrehlk a02f956
Update conftest.py
sstrehlk f1ab1cf
Added test_marking manual.
sstrehlk c103080
Cosmetic corrections in test_marking.md
sstrehlk ac40b93
adapting cli/test_yolo_format.py for pytest
sstrehlk dc0df85
Updated test_yolo_format.py
sstrehlk 0867e02
Corrected datumaro_components.py, updated license in added files.
sstrehlk 514ab9f
Updated test_marking.md file
sstrehlk 4da26ad
Updated test_marking.md file
sstrehlk 854d052
Updates after review.
sstrehlk 9824f90
Removed unnecessary marking.
sstrehlk fbc449c
removed unneeded comments in requirements.py
sstrehlk 019cd16
Corrected requirement constant.
sstrehlk 15eee86
experiment related to test_can_import test.
sstrehlk a29d297
Corrected accidentally changed indentation.
sstrehlk ce37288
Updated .travis.yml to work with pytest
sstrehlk 407e029
Updated .travis.yml to work with pytest.
sstrehlk 5599849
Updated .gitignore, .travis.yml
sstrehlk 9621fdd
Updated .travis.yml to check pytest performance in Travis.
sstrehlk 8d37efb
Updated .travis.yml and requirements.txt.
sstrehlk d61169f
Merged two imports into one line in test files.
sstrehlk be1ea4a
Removed unneded __test__ variable.
sstrehlk 9269822
Corrections in names and formatting.
sstrehlk 9f8abc2
Implemented and used mark_requirement decorator
sstrehlk 1246129
Merge branch 'pytest_related_changes' of https://github.com/openvinot…
sstrehlk 64a9115
Reverted change related to pycocotools version. It's discussed in Iss…
sstrehlk 3f431ed
Updated CHANGELOG.md
sstrehlk c7e74da
Adapt project to run tests with pytest.
sstrehlk ee1e8a9
Update requirements.txt
sstrehlk 3af4a2d
updated tests marking
sstrehlk 2ae2efa
Update conftest.py
sstrehlk 3245701
Update conftest.py
sstrehlk 1c9b289
Added test_marking manual.
sstrehlk 2bee3b5
Cosmetic corrections in test_marking.md
sstrehlk 18182d6
adapting cli/test_yolo_format.py for pytest
sstrehlk d0389dc
Updated test_yolo_format.py
sstrehlk 44e9e70
Corrected datumaro_components.py, updated license in added files.
sstrehlk 9ad6a6e
Updated test_marking.md file
sstrehlk dd7e2eb
Updated test_marking.md file
sstrehlk 9307181
Updates after review.
sstrehlk 5a41f60
Removed unnecessary marking.
sstrehlk 6f8ac20
removed unneeded comments in requirements.py
sstrehlk e61e97f
Corrected requirement constant.
sstrehlk 6474be2
experiment related to test_can_import test.
sstrehlk 4025c62
Corrected accidentally changed indentation.
sstrehlk f8ce252
Updated .travis.yml to work with pytest
sstrehlk 3867d51
Updated .travis.yml to work with pytest.
sstrehlk 1be8b3c
Updated .gitignore, .travis.yml
sstrehlk d390b4b
Updated .travis.yml to check pytest performance in Travis.
sstrehlk c2f0f64
Updated .travis.yml and requirements.txt.
sstrehlk d8c518d
Merged two imports into one line in test files.
sstrehlk 1771bb9
Removed unneded __test__ variable.
sstrehlk a9144cd
Corrections in names and formatting.
sstrehlk cc63c5d
Implemented and used mark_requirement decorator
sstrehlk 1ee44ee
Adapt project to run tests with pytest.
sstrehlk 496ea03
Added test_marking manual.
sstrehlk 2e79c48
Cosmetic corrections in test_marking.md
sstrehlk dfd8a91
adapting cli/test_yolo_format.py for pytest
sstrehlk 68ab086
Corrected datumaro_components.py, updated license in added files.
sstrehlk 15980a9
Updated test_marking.md file
sstrehlk e71cd8c
Updated test_marking.md file
sstrehlk 6127c62
Updates after review.
sstrehlk 96c4c4a
removed unneeded comments in requirements.py
sstrehlk 1e40654
Corrected accidentally changed indentation.
sstrehlk 2772c04
Updated .travis.yml to work with pytest.
sstrehlk 91b58bb
Updated .gitignore, .travis.yml
sstrehlk 3cce32d
Updated .travis.yml and requirements.txt.
sstrehlk 0b4758a
Merged two imports into one line in test files.
sstrehlk 9c06cc2
Removed unneded __test__ variable.
sstrehlk a5feca0
Reverted change related to pycocotools version. It's discussed in Iss…
sstrehlk 90cb339
Updated CHANGELOG.md
sstrehlk ced967c
Merge branch 'pytest_related_changes' of https://github.com/openvinot…
sstrehlk 83204ce
github testing scripts adapted to pytest
sstrehlk f856e47
Corrected rebase.
sstrehlk 6f8328f
Merge branch 'pytest_related_changes' of https://github.com/openvinot…
sstrehlk 83cd7c2
Merge branch 'develop' into pytest_related_changes
84eb6f7
update changelog
3fa8112
Remove extra comments
2158ebe
Move test descriptions to contributing guide
b95013a
Update imports
5ad70cf
Update test annotations
a0faa20
Update markings
e32153a
Added component test run type marking for datumaro tests.
sstrehlk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,7 @@ coverage.xml | |
cover/ | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
docs/_build/ | ||
|
||
#Pycharm config files | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
# Source code elements related to pytest | ||
## Contents | ||
- [Test case description](#Test_case_description) | ||
- [Test marking](#Test_marking) | ||
- [Requirements](#Requirements) | ||
- [Type](#Type) | ||
- [Priority](#Priority) | ||
- [Component](#Component) | ||
- [Skip](#Skip) | ||
- [Bug(s)](#Bug) | ||
- [Parameters](#Parameters) | ||
- [Fixtures](#Fixtures) | ||
- [Test naming convention](#TestNaming) | ||
- [Test name](#TestName) | ||
- [Test documentation](#TestDoc) | ||
- [Docstring](#Docstring) | ||
- [Steps in test body](#Step) | ||
|
||
<a id="Test_case_description"></a> | ||
## Test case description | ||
<a id="Test_marking"></a> | ||
### Test marking | ||
<a id="Requirements"></a> | ||
#### Requirements | ||
Fully defined in GitHub issues, e.g. | ||
``` | ||
@pytest.mark.reqids(Requirements.DATUM_244, Requirements.DATUM_333) | ||
``` | ||
Requirements constants need to be added to datumaro/tests/constants/requirements.py for example: | ||
``` | ||
# [DATUMARO] Add SNYK scan integration | ||
DATUM_244 = "DATUM-244 Add Snyk integration" | ||
``` | ||
Recommended notation for requirements | ||
|
||
```python | ||
@pytest.mark.requids(Requirements.DATUM_123) | ||
``` | ||
where DATUM is a keyword for datumaro indication, and number is a datumaro github issue number. | ||
|
||
<a id="Type"></a> | ||
#### Type | ||
Test types: gui_smoke, gui_regression, manual, gui_other, gui_long, api, component, unit e.g. | ||
```python | ||
@pytest.mark.component | ||
@pytest.mark.unit | ||
``` | ||
|
||
<a id="Priority"></a> | ||
#### Priority | ||
Test priorities: low, medium, high, e.g., | ||
```python | ||
@pytest.mark.priority_low | ||
@pytest.mark.priority_medium | ||
@pytest.mark.priority_high | ||
``` | ||
<a id="Component"></a> | ||
#### Component | ||
|
||
Component marking used for indication of different system components e.g. | ||
```python | ||
@pytest.mark.components(DatumaroComponent.Datumaro) | ||
``` | ||
<a id="Skip"></a> | ||
#### Skip | ||
|
||
For marking tests, which should be skipped for example for not yet tests, e.g., | ||
```python | ||
@pytest.mark.skip(reason=SkipMessages.NOT_IMPLEMENTED) | ||
``` | ||
<a id="Bug"></a> | ||
#### Bug(s): | ||
|
||
In case of test failure, bug should be entered into github issues, and test can be marked e.g. | ||
```python | ||
@pytest.mark.bugs("DATUM-219 - Return format is not uniform") | ||
``` | ||
<a id="Parameters"></a> | ||
#### Parameters: | ||
|
||
Parameters are used for running the same test with different parameters e.g. | ||
```python | ||
@pytest.mark.parametrize("numpy_array, batch_size", [ | ||
(np.zeros([2]), 0), | ||
(np.zeros([2]), 1), | ||
(np.zeros([2]), 2), | ||
(np.zeros([2]), 5), | ||
(np.zeros([5]), 2), | ||
]) | ||
``` | ||
|
||
<a id="Fixtures"></a> | ||
#### Fixtures | ||
|
||
If needed pytest fixtures can be used - for more details see pytest documentation <br> | ||
https://docs.pytest.org/en/6.2.x/contents.html <br> | ||
(be aware that fixtures are supported in pytest, and they are not supported in unittests) | ||
|
||
<a id="TestNaming"></a> | ||
### Test naming convention | ||
|
||
<a id="TestName"></a> | ||
#### Test name: | ||
|
||
Test method should be prefixed with "test_" prefix e.g. | ||
```python | ||
test_*() | ||
``` | ||
"test_" prefix is an indication for pytest to treat method as a test for execution. | ||
It's important not to start other methods with the "test_" prefix. | ||
|
||
<a id="DestDoc"></a> | ||
### Test documentation | ||
|
||
<a id="Docstring"></a> | ||
#### Docstring | ||
|
||
Tests are documented with Docstring. Every test method documentation string should contain: Description, Expected results | ||
and Steps. These fields are required but, not limited e.g. | ||
```python | ||
def test_can_convert_polygons_to_mask(self): | ||
""" | ||
<b>Description:</b> | ||
Ensure that the dataset polygon annotation can be properly converted into dataset segmentation mask. | ||
|
||
<b>Expected results:</b> | ||
Dataset segmentation mask converted from dataset polygon annotation is equal to expected mask. | ||
|
||
<b>Steps:</b> | ||
1. Prepare dataset with polygon annotation (source dataset) | ||
2. Prepare dataset with expected mask segmentation mode (target dataset) | ||
3. Convert source dataset to target, with conversion of annotation from polygon to mask. Verify that result | ||
segmentation mask is equal to expected mask. | ||
|
||
""" | ||
|
||
``` | ||
<a id="Steps"></a> | ||
#### Steps in test body: | ||
|
||
Steps description in test body are placed as a code comment lines e.g. | ||
```python | ||
# 1. Prepare dataset with polygon annotation (source dataset) | ||
source_dataset = Dataset.from_iterable([ | ||
DatasetItem(id=1, image=np.zeros((6, 10, 3)), | ||
annotations=[ | ||
Polygon([0, 0, 4, 0, 4, 4], | ||
label=3, id=4, group=4), | ||
Polygon([5, 0, 9, 0, 5, 5], | ||
label=3, id=4, group=4), | ||
] | ||
), | ||
], categories=[str(i) for i in range(10)]) | ||
|
||
# 2. Prepare dataset with expected mask segmentation mode (target dataset) | ||
target_dataset = Dataset.from_iterable([ | ||
DatasetItem(id=1, image=np.zeros((6, 10, 3)), | ||
annotations=[ | ||
Mask(np.array([ | ||
[0, 1, 1, 1, 0, 1, 1, 1, 1, 0], | ||
[0, 0, 1, 1, 0, 1, 1, 1, 0, 0], | ||
[0, 0, 0, 1, 0, 1, 1, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | ||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], | ||
# only internal fragment (without the border), | ||
# but not everywhere... | ||
), | ||
attributes={ 'is_crowd': True }, | ||
label=3, id=4, group=4), | ||
], attributes={'id': 1} | ||
), | ||
], categories=[str(i) for i in range(10)]) | ||
|
||
# 3. Convert source dataset to target, with conversion of annotation from polygon to mask. Verify that result | ||
# segmentation mask is equal to expected mask. | ||
with TestDir() as test_dir: | ||
self._test_save_and_load(source_dataset, | ||
partial(CocoInstancesConverter.convert, segmentation_mode='mask'), | ||
test_dir, target_dataset=target_dataset) | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 feel it can quickly become a story similar to the story with comments in code. If a test is so complex it is impossible to understand quickly, it must be split and simplified. For many unit tests such description will be equal, or even bigger that the test code itself. It might be ok for complex or long integration/e2e tests, which are supposed to be like this.
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.
This high level description is dedicated to reports viewers. Viewer don't need to know particular programming language to have understanding what was tested and how.