Skip to content
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

Remove unnecessary files generated when running tox locally #1426

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/django-import-export-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
IMPORT_EXPORT_POSTGRESQL_PASSWORD: somepass
IMPORT_EXPORT_MYSQL_USER: root
IMPORT_EXPORT_MYSQL_PASSWORD: root
COVERAGE: 1
strategy:
matrix:
python-version:
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Changelog
- Fix broken link to tablib formats page (#1418)
- Fix broken image ref in `README.rst`
- Include custom form media in templates (#1038)
- Remove unnecessary files generated when running tox locally (#1426)

3.0.0-beta.1 (2022-04-11)
-------------------------
Expand Down
22 changes: 22 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Helper script to generate coverage data only if running in CI.
This script is called from tox (see tox.ini).
Coverage files are generated only if a `COVERAGE` environment variable is present.
This is necessary to prevent unwanted coverage files when running locally (issue #1424)
"""
import os


def main():
coverage_args = "-m coverage run" if os.environ.get("COVERAGE") else ""

os.system(
"python -W error::DeprecationWarning -W error::PendingDeprecationWarning "
f"{coverage_args} "
"./tests/manage.py test core --settings=settings"
)


if __name__ == "__main__":
main()

2 changes: 0 additions & 2 deletions tests/core/tests/test_admin_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ def test_import_second_resource(self):
response = self.client.post('/admin/core/book/import/', data)
self.assertEqual(response.status_code, 200)
self.assertIn('result', response.context)
with open("response.html", "wb") as f:
f.write(response.content)
self.assertFalse(response.context['result'].has_errors())
self.assertIn('confirm_form', response.context)
confirm_form = response.context['confirm_form']
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ python =

[testenv]
setenv = PYTHONPATH = {toxinidir}/tests
commands = python -W error::DeprecationWarning -W error::PendingDeprecationWarning -m coverage run {toxinidir}/tests/manage.py test core
commands = python ./runtests.py
deps =
tablibdev: -egit+https://github.com/jazzband/tablib.git#egg=tablib
django32: Django>=3.2,<4.0
Expand All @@ -25,6 +25,7 @@ deps =

# if postgres / mysql environment variables exist, we can go ahead and run db specific tests
passenv =
COVERAGE
IMPORT_EXPORT_POSTGRESQL_USER
IMPORT_EXPORT_POSTGRESQL_PASSWORD
IMPORT_EXPORT_MYSQL_USER
Expand Down