-
Notifications
You must be signed in to change notification settings - Fork 42
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
test: Use pytest for testing #121
Conversation
123d9f9
to
89ba141
Compare
89ba141
to
134ece6
Compare
- also fix some tests that required patching settings. - reducing time for tests running on travis by running them for lesser environments(still cover all versions) - add support for python3.9 fix Radi85#119 fix Radi85#112
134ece6
to
e9b43f1
Compare
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.
In general I have compared current test with pytest and the current test is still faster. So do you think we need pytest anymore?!
Also can you please remove the text related to the icon from your commit? It's nice on github but let's try to not spam the commits/git history with icon text.
@@ -40,16 +40,16 @@ def test_is_edited_for_anonymous_comment(self): | |||
comment = self.create_anonymous_comment(posted=timezone.now() - timezone.timedelta(days=1)) | |||
self.assertFalse(comment.is_edited) | |||
|
|||
@patch.object(settings, 'COMMENT_FLAGS_ALLOWED', 1) |
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.
COMMENT_FLAGS_ALLOWED
is a boolean so please use True
instead of 1
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.
no, it is not.
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.
you are right!
The variable name points to a boolean value. I think this name would be more descriptive COMMENT_MAX_FLAGS_NUMBER_ALLOWED
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 variable name points to a boolean value.
something like COMMONT_IS_FLAG_ALLOWED
appears more outrightly boolean to me.
I think this name would be more descriptive COMMENT_MAX_FLAGS_NUMBER_ALLOWED
this seems to be more of a whimsical comment to me 😆 , COMMENT_MAX_FLAG_ALLOWED
seems better to me but any such change will require a major version bump. Also, if we go down this route, maybe we might need to change almost all of the defaults.
|
||
def test_id_generator_generates_different_ids(self): | ||
self.assertNotEqual(id_generator(), id_generator()) | ||
assert id_generator() != id_generator() |
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.
can you please change this test as suggested to get rid of SonarLint error
assert id_generator() != id_generator() | |
first_id = id_generator() | |
second_id = id_generator() | |
assert first_id != second_id |
@@ -337,36 +336,34 @@ def test_for_drf(self): | |||
self.assertEqual(EmailInfo.CONFIRMATION_SENT, response) | |||
|
|||
|
|||
class UtilsTest(TestCase): | |||
class TestUtils: |
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.
Why TestCase
is removed from this test only? I would prefer using the self.assert*
rather than python assert keyword.
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.
Why TestCase is removed from this test only?
this is a luxury that you can use with pytest
. You don't need to pass unittest
's TestCase
or even django's TestCase
when using pytest-django
, it does it for you. You can read more about it in their documentation https://docs.pytest.org/en/latest/.
There is a bit of magic, it doesn't necessarily use python's
assert
statement. It automatically does some magic behind the scenes and does all the comparison for you so that you don't have to remember and write different statements(self.assertEqual
, self.assertTrue
) for different use-cases.
I would prefer using the self.assert* rather than python assert keyword.
If that is the case, there is very little point in switching to the pytest
. Feel free to close this one then.
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 see that the form of assertion self.assertEqual
and self.assertTrue
is more explicit on the type of the value that's why I would prefer it.
Moreover, I wouldn't prefer to stick with one testing framework.
You have already done the work for #112, if you like you can just revert pytest changes and we can still merge this PR.
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 current change to pytest
was made after the issue was discussed. Reverting things because one of us doesn't like the change, seems a lot of waste of time for both of us. This also makes the process more irritating than enjoyable for me.
I think we need to build consensus and be more clear before any code is written so that both of us doesn't waste time.
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.
First of all I would appreciate you contribution to the project.
There should not be an issue if we try something and revert it after finding out that it doesn't fit our need.
In regard to the pytest, I have told you that I never used this framework and didn't have time to fiddle with it before you implement the changes so I am sorry to waste your time.
Lastly, I think it is a good time to create some labels to tag issues that are ready for implementation to avoid wasting people's time :)
In order to reduce the time, we will need to re-write most of the current tests. I don't think I meant that at any stage. What I meant was if we need
okay 😢, although spam maybe is too strong a word. if it were "spam", it probably wouldn't have been used in framework as popular as |
I have two points on this topic:
Fastapi:
Our tree:
I don't like to see such commit |
I never said anything about this being good or bad. You might be going down the route of Strawman argument.
I will do it as you say, but maybe I want more creative freedom around the project. I do agree that the icon text just has somewhat of overhead, but I like it 😭 |
@Radi85 it seems wise to me to close this pull-request and make a new one for #112 I'm doing as of what you say, but Also, jokes apart some current tests were actually passing because of the sequence in which Lastly, one more thing, and I kind of feel a bit weird doing this, but wanted to tell you that I was looking for a job. It would be great of you, if you have any opening where you can refer me. |
fix #119
fix #112