Skip to content

Commit

Permalink
Use pytest as test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Apr 16, 2020
1 parent e260b7b commit 3207e72
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 208 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[report]
omit =
nested_admin/tests/*
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,17 @@ before_script:
before_install:
- nvm install 11
- nvm use 11
- travis_retry travis_retry npm install
- travis_retry travis_retry npm install codecov
- travis_retry travis_retry npm install pixelmatch
- travis_retry npm install
- travis_retry npm install codecov pixelmatch
- NODE_ENV=test npm run build

install:
- pip install tox coverage codecov

script:
- |
travis_retry travis_retry travis_retry tox -- \
--selenium=chrome-headless \
--verbosity=2 \
--failfast
travis_retry travis_retry tox -- \
--selenosis-driver=chrome-headless -v --exitfirst
- npm run report
- npm run codecov
- coverage xml
Expand Down
12 changes: 6 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ Testing
django-nested-admin has fairly extensive test coverage.
The best way to run the tests is with `tox <https://testrun.org/tox/latest/>`_,
which runs the tests against all supported Django installs. To run the tests
within a virtualenv run ``python runtests.py`` from the repository directory.
The tests require a selenium webdriver to be installed. By default the tests
run with phantomjs, but it is also possible to run the tests with the chrome
webdriver by passing ``--selenium=chrome`` to runtests.py or, if running with tox,
running ``tox -- --selenium=chrome``. See ``runtests.py --help`` for a complete
list of the options available.
within a virtualenv run ``pytest`` from the repository directory. The tests
require a selenium webdriver to be installed. By default the tests run with
phantomjs, but it is also possible to run the tests with the chrome webdriver
by passing ``--selenosis-driver=chrome`` to ``pytest`` or, if running with
tox, running ``tox -- --selenosis-driver=chrome``. See ``pytest --help`` for
a complete list of the options available.

Contributing
============
Expand Down
12 changes: 6 additions & 6 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Running tests
django-nested-admin has fairly extensive test coverage.
The best way to run the tests is with `tox <https://testrun.org/tox/latest/>`_,
which runs the tests against all supported Django installs. To run the tests
within a virtualenv run ``python runtests.py`` from the repository directory.
The tests require a selenium webdriver to be installed. By default the tests
run with phantomjs, but it is also possible to run the tests with the chrome
webdriver by passing ``--selenium=chrome`` to runtests.py or, if running with tox,
running ``tox -- --selenium=chrome``. See ``runtests.py --help`` for a complete
list of the options available.
within a virtualenv run ``pytest`` from the repository directory. The tests
require a selenium webdriver to be installed. By default the tests run with
phantomjs, but it is also possible to run the tests with the chrome webdriver
by passing ``--selenosis-driver=chrome`` to ``pytest`` or, if running with
tox, running ``tox -- --selenosis-driver=chrome``. See ``pytest --help`` for
a complete list of the options available.

Pull requests are automatically run through Travis CI upon submission to
verify that the changes do not introduce regressions.
Expand Down
72 changes: 36 additions & 36 deletions nested_admin/tests/admin_widgets/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from nested_admin import NestedStackedInline, NestedTabularInline, NestedModelAdmin

from .models import (
TestAdminWidgetsRoot, TestAdminWidgetsM2M, TestAdminWidgetsRelated1,
TestAdminWidgetsRelated2, TestAdminWidgetsA, TestAdminWidgetsB,
TestAdminWidgetsC0, TestAdminWidgetsC1, TestAdminWidgetsM2MTwo,
TestWidgetMediaOrderRoot, TestWidgetMediaOrderA, TestWidgetMediaOrderB,
TestWidgetMediaOrderC0, TestWidgetMediaOrderC1)
WidgetsRoot, WidgetsM2M, WidgetsRelated1,
WidgetsRelated2, WidgetsA, WidgetsB,
WidgetsC0, WidgetsC1, WidgetsM2MTwo,
WidgetMediaOrderRoot, WidgetMediaOrderA, WidgetMediaOrderB,
WidgetMediaOrderC0, WidgetMediaOrderC1)


class TestAdminWidgetsC0Inline(NestedStackedInline):
model = TestAdminWidgetsC0
class WidgetsC0Inline(NestedStackedInline):
model = WidgetsC0
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
sortable_field_name = "position"
Expand All @@ -31,8 +31,8 @@ class TestAdminWidgetsC0Inline(NestedStackedInline):
}


class TestAdminWidgetsC1Inline(NestedTabularInline):
model = TestAdminWidgetsC1
class WidgetsC1Inline(NestedTabularInline):
model = WidgetsC1
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
sortable_field_name = "position"
Expand All @@ -48,9 +48,9 @@ class TestAdminWidgetsC1Inline(NestedTabularInline):
}


class TestAdminWidgetsBInline(NestedStackedInline):
model = TestAdminWidgetsB
inlines = [TestAdminWidgetsC0Inline, TestAdminWidgetsC1Inline]
class WidgetsBInline(NestedStackedInline):
model = WidgetsB
inlines = [WidgetsC0Inline, WidgetsC1Inline]
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
sortable_field_name = "position"
Expand All @@ -70,9 +70,9 @@ class TestAdminWidgetsBInline(NestedStackedInline):
}


class TestAdminWidgetsAInline(NestedStackedInline):
model = TestAdminWidgetsA
inlines = [TestAdminWidgetsBInline]
class WidgetsAInline(NestedStackedInline):
model = WidgetsA
inlines = [WidgetsBInline]
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
sortable_field_name = "position"
Expand All @@ -92,30 +92,30 @@ class TestAdminWidgetsAInline(NestedStackedInline):
}


@admin.register(TestAdminWidgetsRoot)
class TestAdminWidgetsRootAdmin(NestedModelAdmin):
inlines = [TestAdminWidgetsAInline]
@admin.register(WidgetsRoot)
class WidgetsRootAdmin(NestedModelAdmin):
inlines = [WidgetsAInline]


admin.site.register(TestAdminWidgetsRelated1, NestedModelAdmin)
admin.site.register(TestAdminWidgetsM2M, NestedModelAdmin)
admin.site.register(TestAdminWidgetsM2MTwo, NestedModelAdmin)
admin.site.register(WidgetsRelated1, NestedModelAdmin)
admin.site.register(WidgetsM2M, NestedModelAdmin)
admin.site.register(WidgetsM2MTwo, NestedModelAdmin)


@admin.register(TestAdminWidgetsRelated2)
class TestAdminWidgetsRelated2Admin(NestedModelAdmin):
@admin.register(WidgetsRelated2)
class WidgetsRelated2Admin(NestedModelAdmin):
ordering = ['-date_created']
search_fields = ['name']


class TestWidgetMediaOrderC0Inline(NestedStackedInline):
model = TestWidgetMediaOrderC0
class WidgetMediaOrderC0Inline(NestedStackedInline):
model = WidgetMediaOrderC0
sortable_field_name = "position"
extra = 0


class TestWidgetMediaOrderC1Inline(NestedTabularInline):
model = TestWidgetMediaOrderC1
class WidgetMediaOrderC1Inline(NestedTabularInline):
model = WidgetMediaOrderC1
prepopulated_fields = {'slug': ('name', )}
filter_horizontal = ['m2m']
extra = 0
Expand All @@ -125,22 +125,22 @@ class TestWidgetMediaOrderC1Inline(NestedTabularInline):
autocomplete_fields = ['fk3']


class TestWidgetMediaOrderBInline(NestedStackedInline):
model = TestWidgetMediaOrderB
inlines = [TestWidgetMediaOrderC0Inline, TestWidgetMediaOrderC1Inline]
class WidgetMediaOrderBInline(NestedStackedInline):
model = WidgetMediaOrderB
inlines = [WidgetMediaOrderC0Inline, WidgetMediaOrderC1Inline]
sortable_field_name = "position"
extra = 1
inline_classes = ("grp-collapse", "grp-open",)


class TestWidgetMediaOrderAInline(NestedStackedInline):
model = TestWidgetMediaOrderA
inlines = [TestWidgetMediaOrderBInline]
class WidgetMediaOrderAInline(NestedStackedInline):
model = WidgetMediaOrderA
inlines = [WidgetMediaOrderBInline]
sortable_field_name = "position"
extra = 1
inline_classes = ("grp-collapse", "grp-open",)


@admin.register(TestWidgetMediaOrderRoot)
class TestWidgetMediaOrderRootAdmin(NestedModelAdmin):
inlines = [TestWidgetMediaOrderAInline]
@admin.register(WidgetMediaOrderRoot)
class WidgetMediaOrderRootAdmin(NestedModelAdmin):
inlines = [WidgetMediaOrderAInline]
Loading

0 comments on commit 3207e72

Please sign in to comment.