Skip to content

Commit

Permalink
Enable doctests in CI with xdoctest (open-mmlab#1479)
Browse files Browse the repository at this point in the history
* Enable doctests in CI with xdoctest

* use xdoctest in travis file

* Fix doctest warnings

* dont test eggs directory

* Ensure xdoctest is installed before running CI
  • Loading branch information
Erotemic authored and hellock committed Oct 2, 2019
1 parent d9f4f25 commit 0e9de20
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ script:
- yapf -r -d --style .style.yapf mmdet/ tools/ tests/
- python setup.py check -m -s
- python setup.py build_ext --inplace
- coverage run --source mmdet -m py.test tests -v --doctest-modules
- coverage run --source mmdet -m py.test -v --xdoctest-modules tests mmdet

after_success:
- coverage report
- coverage report
2 changes: 1 addition & 1 deletion mmdet/models/bbox_heads/convfc_bbox_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@HEADS.register_module
class ConvFCBBoxHead(BBoxHead):
"""More general bbox head, with shared conv and fc layers and two optional
r"""More general bbox head, with shared conv and fc layers and two optional
separated branches.
/-> cls convs -> cls fcs -> cls
Expand Down
2 changes: 1 addition & 1 deletion mmdet/models/bbox_heads/double_bbox_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def forward(self, x):

@HEADS.register_module
class DoubleConvFCBBoxHead(BBoxHead):
"""Bbox head used in Double-Head R-CNN
r"""Bbox head used in Double-Head R-CNN
/-> cls
/-> shared convs ->
Expand Down
1 change: 1 addition & 0 deletions mmdet/models/losses/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def weighted_loss(loss_func):
:Example:
>>> import torch
>>> @weighted_loss
>>> def l1_loss(pred, target):
>>> return (pred - target).abs()
Expand Down
2 changes: 1 addition & 1 deletion mmdet/models/mask_heads/fused_semantic_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@HEADS.register_module
class FusedSemanticHead(nn.Module):
"""Multi-level fused semantic segmentation head.
r"""Multi-level fused semantic segmentation head.
in_1 -> 1x1 conv ---
|
Expand Down
7 changes: 7 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[pytest]
addopts = --xdoctest --xdoctest-style=auto
norecursedirs = .git ignore build __pycache__ data docker docs .eggs

filterwarnings= default
ignore:.*No cfgstr given in Cacher constructor or call.*:Warning
ignore:.*Define the __nice__ method for.*:Warning
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_requirements(filename='requirements.txt'):
],
license='Apache License 2.0',
setup_requires=['pytest-runner', 'cython', 'numpy'],
tests_require=['pytest'],
tests_require=['pytest', 'xdoctest'],
install_requires=get_requirements(),
ext_modules=[
make_cython_ext(
Expand Down
3 changes: 2 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ isort
flake8
yapf
pytest-cov
codecov
codecov
xdoctest >= 0.10.0

0 comments on commit 0e9de20

Please sign in to comment.