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

Add initial approach to put Django's asserts into pytest's namespace. #97 #144

Closed
wants to merge 8 commits into from
Closed

Conversation

Stranger6667
Copy link

It's only draft version.

@blueyed
Copy link
Contributor

blueyed commented Jul 27, 2014

Great that you're working on it.

You should mention / close the related issue from your commit(s) then: #97

@pelme
Copy link
Member

pelme commented Jul 27, 2014

@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)

@Stranger6667 Stranger6667 changed the title Add initial approach to put Django's asserts into pytest's namespace Add initial approach to put Django's asserts into pytest's namespace. #97 Jul 27, 2014
@Stranger6667
Copy link
Author

@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

@pelme
Copy link
Member

pelme commented Jul 27, 2014

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.

@Stranger6667
Copy link
Author

@pelme @blueyed, can you review my code, please? I think it is already on the way to be finished in few commits

@@ -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, \
Copy link
Contributor

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

@blueyed
Copy link
Contributor

blueyed commented Aug 15, 2014

@Stranger6667
Any updates? Are you working on this still?

@Vye
Copy link

Vye commented Sep 12, 2014

@Stranger6667, I've also been looking for this functionality. Are you still working on this?

@areski
Copy link

areski commented Nov 24, 2014

+1 to see this happen

@dustinfarris
Copy link

@Stranger6667 is this abandoned?

@rougeth
Copy link

rougeth commented Mar 10, 2015

+1 to this feature!

@roganov
Copy link

roganov commented Mar 18, 2015

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')
}
Copy link

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.

Copy link
Member

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.

@pelme
Copy link
Member

pelme commented Mar 29, 2015

@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!

@pelme
Copy link
Member

pelme commented Mar 29, 2015

@roganov PEP8 aliases for the assertions would be great and look better!

@bittner
Copy link
Contributor

bittner commented Apr 15, 2015

Anyone planning to add a little love to @Stranger6667's PR? If not, should I?

@blueyed
Copy link
Contributor

blueyed commented Apr 15, 2015

@bittner
That would be great!

@pelme
Copy link
Member

pelme commented Apr 15, 2015

@bittner Please go ahead, this would be a great feature for the next release :)

@blueyed
Copy link
Contributor

blueyed commented Apr 18, 2015

I am closing this in favor of #232, where @bittner started following up on this.

@blueyed blueyed closed this Apr 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants