Commit Graph

26 Commits

Author SHA1 Message Date
Terence Honles
4296189283
fix dist test by moving --no-pkgroot to runtests.py (#9129)
This change fixes the dist test by moving the --no-pkgroot option from
pytest to the runtests script.

The current "filterwarnings" setting for pytest includes rest_framework,
which causes an early import of the module. As a result the current
--no-pkgroot behavior fails with an assertion error. Trying to remove
the module from sys.modules will cause the warning filter to not apply,
so this change moves this code before pytest parses the config and loads
the "filterwarnings".
2023-10-05 12:33:53 +06:00
Mariusz Felisiak
bc075212cb
Fix running runtests.py without arguments. (#7954)
Regression in aa12a5f967.
2021-05-24 09:47:44 +02:00
Adam Johnson
aa12a5f967
Lint with pre-commit (#7900)
Following [my comment here](https://github.com/encode/django-rest-framework/pull/7589#issuecomment-813301322) and [Django's own move to pre-commit](https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#pre-commit-checks).

* Add pre-commit config file to run flake8 and isort.
* Add extra "common sense" hooks.
* Run pre-commit on GitHub actions using the [official action](https://github.com/pre-commit/action/). This is a good way to get up-and-running but it would be better if we activated [pre-commit.ci](https://pre-commit.ci/), which is faster and will auto-update the hooks for us going forwards.
* Remove `runtests.py` code for running linting tools.
* Remove `runtests.py --fast` flag, since that would now just run `pytest -q`, which can be done with `runtests.py -q` instead.
* Remove tox configuration and requirements files for linting.
* Update the contributing guide to mention setting up pre-commit.
2021-04-05 12:08:52 +01:00
David Smith
355afcf64b
isort v5 (#7484) 2020-08-17 13:26:56 -07:00
Jon Dufresne
1e519486e1 Fixup isort command/config (#6639) 2019-05-01 17:42:10 -07:00
Carlton Gibson
0407a0df8a
Dropped Python 2 compatibility. (#6615)
Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com>
2019-04-30 17:53:44 +02:00
Daniel Hahler
06526cafe5 runtests.py: clean up PYTEST_ARGS (#6040)
1. `tests` and `--tb=short` is not necessary, since it is in
`pytest.addopts` already.
2. removes `-s` (shortcut for --capture=no): it is typically a good idea
   to not display output from successful tests.
2018-06-21 14:28:25 +01:00
Daniel Hahler
c17b4ad0d0 Include coverage for tests (#5970)
It is useful to see if tests itself are covered after all - missing
coverage there typically indicates dead/missed code paths.

This also uses `source=.` and includes (with run and report), to help
Codecov with reporting.
Ref: https://github.com/encode/django-rest-framework/pull/5956
2018-05-08 14:02:45 +01:00
Daniel Hahler
2854679f56 Upgrade isort (#5817)
* Fix isort

* runtests: add --diff to ISORT_ARGS

* requirements-codestyle: bump isort to 4.3.3

* isort: move config to setup.cfg
2018-02-14 20:12:14 +00:00
Ryan P Kilby
68519c092f Test staticfiles (#5701)
* Remove 'MIDDLEWARE_CLASSES' compat setting

* Remove 'django.setup()' compat import

* Move '--no-pkgroot' handling to conftest

* Add staticfiles handling to dist build
2018-01-02 11:35:56 +01:00
Ryan P Kilby
d12005cf90 Add 'dist' build (#5656) 2017-12-14 11:48:03 +01:00
Daniel Hahler
89276e6cfc Move flake8 config to setup.cfg
This allows for flake8 to pick it up when running it by itself.
2017-05-16 12:18:33 +02:00
Tom Christie
6ff9840bde Schemas & client libraries. (#4179)
* Added schema generation support.
* New tutorial section.
* API guide on schema generation.
* Topic guide on API clients.
2016-07-04 16:38:17 +01:00
Tom Christie
994e1ba927 Django 1.10 support. (#4158)
* Added TEMPLATES setting to tests
* Remove deprecated view-string in URL conf
* Replace 'urls = ...' in test classes with override_settings('ROOT_URLCONF=...')
* Refactor UsingURLPatterns to use override_settings(ROOT_URLCONF=...) style
* Get model managers and names in a version-compatible manner.
* Apply override_settings to a TestCase, not a mixin class
* Use '.callback' property instead of private attributes when inspecting urlpatterns
* Pass 'user' to template explicitly
* Correct sorting of import statements.
* Remove unused TEMPLATE_LOADERS setting, in favor of TEMPLATES.
* Remove code style issue
* BaseFilter test requires a concrete model
* Resolve tox.ini issues
* Resolve isort differences between local and tox environments
2016-06-01 15:31:00 +01:00
Xavier Ordoquy
a4ce897d28 Display py.test internal warnings 2015-12-16 13:27:40 +01:00
Nic Young
739d3892c5 Fix codecov on Travis CI
The coverage report needs to be explicitly created with arguments passed
in to pytest-cov
2015-10-07 22:20:46 -07:00
Tom Christie
806b0b34da Include nested objects in metadata for OPTIONS. Closes #3156. Closes #2915. 2015-07-16 15:17:18 +01:00
Tom Christie
db40b7eb91 Add coverage to runtests. Closes #2936. 2015-07-16 12:39:01 +01:00
Tom Christie
cde7154c59 Runtests should not suppress stdout. In the context of a web app only serves to hide erronous print statements. 2015-07-16 11:50:22 +01:00
Tom Christie
a03b89f326 Restrict isort to rest_framework and tests directories 2015-07-02 10:18:08 +01:00
Tom Christie
36e4f20111 Update runtests.py 2015-06-29 09:39:27 +01:00
José Padilla
0f1d9217f0 Print helpful command if isort fails 2015-06-27 16:06:53 -04:00
José Padilla
b4ba8ef4d7 Setup isort for code style linting 2015-06-26 09:16:33 -04:00
Xavier Ordoquy
a7567efa8d Use compact traceback for errors reporting. 2015-01-21 19:26:57 +01:00
Tymur Maryokhin
d9930181ee Removed unused imports, pep8 fixes, typo fixes 2014-12-05 00:29:28 +01:00
Tom Christie
bf09c32de8 Code linting and added runtests.py 2014-08-19 13:28:07 +01:00