-
Notifications
You must be signed in to change notification settings - Fork 346
Add initial approach to put Django's asserts into pytest's namespace. #97 #144
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
Conversation
Great that you're working on it. You should mention / close the related issue from your commit(s) then: #97 |
@Stranger6667 Very nice to meet you and thank you very much for working on this. Do you plan to finalize this PR or are you happy if someone else continues with it? (It's good to know any way so that someone else can continue if you don't have the time/interest to continue) |
@pelme, for me too. I think, it will be done in a few days (or sooner), I definitely interested in it :) But anyway, I'll appreciate any help |
Great :) It looks good to me, but we need to keep a list that we manually keep up to date with all the assertions. We then need a tests (in our own test suite) which compares our own hard coded list to the actual assertion methods in Django and fails the test as soon as there is a new one to add to that list. Also, the assertion methods themselves needs to be wrapped in new functions which does the actual import when they are invoked. Let me know if you need more help or explanations of this and I'll try to give a more detailed explanation. |
Conflicts: pytest_django/lazy_django.py pytest_django/plugin.py
@@ -13,7 +12,8 @@ | |||
admin_client, rf, settings, live_server, | |||
_live_server_helper) | |||
|
|||
from .lazy_django import skip_if_no_django, django_settings_is_configured | |||
from .lazy_django import skip_if_no_django, django_settings_is_configured, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better write this as from ... import ( ... )
.
See https://github.com/timothycrosley/isort for a nice tool to sort imports automatically.
I use the following command with Vim:
command! -range=% Isort :<line1>,<line2>! isort -
/cc @pelme
@Stranger6667 |
@Stranger6667, I've also been looking for this functionality. Are you still working on this? |
+1 to see this happen |
@Stranger6667 is this abandoned? |
+1 to this feature! |
Any updates on this? Also, wouldn't it be better to use pep8 names of the assertions? |
'assertNotContains', 'assertNumQueries', 'assertQuerysetEqual', | ||
'assertRaisesMessage', 'assertRedirects', 'assertTemplateNotUsed', | ||
'assertTemplateUsed', 'assertXMLEqual', 'assertXMLNotEqual') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it should be possible to collect these methods directly from django's SimpleTestCase, TestCase and TransactionTestCase classes rather than hardcoding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with dynamically collecting these names is that Django may not be fully loaded when pytest_namespace is called.
@Vye @areski @dustinfarris @rougeth This PR hasn't seen any updates in a while, feel free to continue working on it. Please drop a comment here if you do so that others know. I'd be happy to answer any questions! |
@roganov PEP8 aliases for the assertions would be great and look better! |
Anyone planning to add a little love to @Stranger6667's PR? If not, should I? |
@bittner |
@bittner Please go ahead, this would be a great feature for the next release :) |
It's only draft version.