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

Implement the --django-debug plugin option with tests #463

Closed
wants to merge 7 commits into from

Conversation

dulacp
Copy link

@dulacp dulacp commented Feb 20, 2017

Follows the #228 issue, and the un-merged #231 PR.

I've taken into account @blueyed comment, and included a comprehensive list of tests.

Cheers

@karyon
Copy link

karyon commented Feb 21, 2017

fwiw, starting from django 1.11 (to be released in april), django's test runner will have that option: https://docs.djangoproject.com/en/dev/ref/django-admin/#cmdoption-test-debug-mode

@blueyed
Copy link
Contributor

blueyed commented Feb 21, 2017

@karyon
Nice find.

It gets passed through to setup_test_environment (https://github.com/django/django/blob/5a6f70b4281817656db2f36c5919036d38fcce7f/django/test/runner.py#L461), which we should do then, too (in

setup_test_environment()
).

@dulaccc
Can you change this PR accordingly?
It should pass it in for Django 1.11+, but change the setting (as done currently) for older versions.

@dulacp
Copy link
Author

dulacp commented Feb 22, 2017

Sure, I will try to update that soon!

@auvipy
Copy link
Contributor

auvipy commented Apr 17, 2017

is this going out of radar?

@blueyed
Copy link
Contributor

blueyed commented May 16, 2017

@dulaccc
Can you update this please? (we might have a release soon)

@codecov-io
Copy link

codecov-io commented Oct 10, 2017

Codecov Report

Merging #463 into master will increase coverage by 0.18%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #463      +/-   ##
==========================================
+ Coverage    97.9%   98.08%   +0.18%     
==========================================
  Files          32       32              
  Lines        1863     1883      +20     
  Branches      147      149       +2     
==========================================
+ Hits         1824     1847      +23     
+ Misses         26       24       -2     
+ Partials       13       12       -1
Impacted Files Coverage Δ
tests/test_django_settings_module.py 100% <100%> (ø) ⬆️
pytest_django/plugin.py 94.14% <100%> (+0.12%) ⬆️
tests/test_db_setup.py 100% <0%> (ø) ⬆️
tests/conftest.py 100% <0%> (ø) ⬆️
pytest_django/live_server_helper.py 96.87% <0%> (+4.68%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17cdcda...b64c795. Read the comment docs.

Copy link
Contributor

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use new API wiith Django 1.11+ (see above).

@dulacp dulacp force-pushed the add-django-debug-option branch 2 times, most recently from 38a959e to 936931c Compare December 2, 2017 11:42
@dulacp
Copy link
Author

dulacp commented Dec 2, 2017

I fixed the PR with the Django 1.11 new setup_test_environment API.
And I used the naming convention --django-debug-mode.

Is that okay for you?

Cheers

@karyon
Copy link

karyon commented Dec 3, 2017

fyi, the tests failed :)

@dulacp
Copy link
Author

dulacp commented Dec 3, 2017

@karyon are you sure the tests are stable between builds? because I've only 3 commits above the 4145f73 commit (which is marked as green on master). And the failed tests on travis are totally non-related to my additions.

I'll investigate,
Cheers

@karyon
Copy link

karyon commented Dec 3, 2017

sorry, i'm not a maintainer of pytest-django, i just saw that the tests failed and thought i let you know because i myself often don't notice that :)

@dulacp
Copy link
Author

dulacp commented Dec 3, 2017

Oh, alright. Thanks for the heads-up @karyon! :)

@dulacp
Copy link
Author

dulacp commented Dec 3, 2017

Hey @blueyed,

All the jobs targeting Python 2.7 are failing on Travis.
I suspect that something in the stack changed during the past 15 days (because 15 days ago the commit 4145f73 was green).

Do you have other feedbacks on such an issue?

@blueyed
Copy link
Contributor

blueyed commented Dec 3, 2017

Tests are failing with pytest 3.3 (and the other jobs are using an older version (cache likely?!))
See #550.

@blueyed
Copy link
Contributor

blueyed commented Dec 3, 2017

Please rebase, since our tests in master were failing with pytest 3.3.

@dulacp
Copy link
Author

dulacp commented Dec 4, 2017

@blueyed nice catch for the pytest version and the caching issue!
I guess everything is green now 🍻

@dulacp
Copy link
Author

dulacp commented Dec 11, 2017

@blueyed can you merge this before master diverge?
Cheers

Copy link
Contributor

@blueyed blueyed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrased the doc a bit - please review.
Left some other comments.

pytest_django/plugin.py Outdated Show resolved Hide resolved
pytest_django/plugin.py Outdated Show resolved Hide resolved
@samueldotj
Copy link

@dulacp This issue took a solid 45 minutes to track it down - I guess a lot of other developers would have faced the same issue. It would be great if you could get this committed.

@richardARPANET
Copy link

Just wasted 30 minutes of my life due to this. Would be great to get this merged.

Copy link
Contributor

@auvipy auvipy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rebase

@blueyed
Copy link
Contributor

blueyed commented May 17, 2019

@samueldotj @richardARPANET
What exactly took you time to track it down? IIRC this is about adding a new option to control the DEBUG setting only, isn't it?

Also it clearly cannot be "just merged" given 4 conflicting files.

@richardARPANET
Copy link

@blueyed My application was configured by env vars. One for the DEBUG setting.

DEBUG = os.environ['DEBUG'].lower() == 'true'

It worked at run-time, but not at test run-time. Which let to me trying/checking all sorts of things, I didn't expect pytest-django to be overriding this setting at all.

@blueyed
Copy link
Contributor

blueyed commented May 17, 2019

I see.
FWIW this can also be controlled through settings, i.e.

@pytest.fixture(scope="session", autouse=True)
def dj_debug(settings):
    settings.DEBUG = True

(or per test)

Django itself has --debug-mode, used by setup_test_environment (where we should/could pass this then also).

@blueyed
Copy link
Contributor

blueyed commented May 17, 2019

@dulacp
I'll pick it up later I guess - please let me know if you want / can do it instead.

@auvipy
These kind of (obvious) "reviews" are not useful.

With regard to debugging you might be interested in #725 - I'd appreciate a review of it in return.

@blueyed
Copy link
Contributor

blueyed commented May 30, 2019

@dulacp
Thanks!

I've pushed a fixup commit, let me know if this looks good to you, and we can finally (squash-)merge this then.

@dulacp
Copy link
Author

dulacp commented May 31, 2019

Thanks for the fixup commit! It looks great :)

@blueyed
Copy link
Contributor

blueyed commented May 31, 2019

Great. Just wondered about the name - it mentions --django-debug initially, but is django-debug-option. I'd prefer the shorter one, what do you think?
(sorry if this was changed / discussed before, just a quick thought)

@blueyed
Copy link
Contributor

blueyed commented Jun 4, 2019

I think we should use --django-debug and --django-no-debug flags here.

@dulacp
Copy link
Author

dulacp commented Jul 14, 2019

I've made the changes to use django-debug now.

Cheers

@Andrew-Chen-Wang
Copy link

@blueyed Should the master branch be merged to incorporate some new tests and pytest 5.4.0 or is this good to go?

@bluetech
Copy link
Member

Oops, I was not aware of this PR and added a similar solution in #888. Only I used an ini option and called it django_debug_mode. Since that one is already merged, I'll close this one. Sorry for missing it, but let me know if you have any comments.

@bluetech bluetech closed this Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants