-
Notifications
You must be signed in to change notification settings - Fork 36
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
Changed testing framework (Pytest) #275
Conversation
@vishav1771 Nice work! I'm not able to review this PR right now (nor am I assigned) but I wanted to say thank you, since this is a pretty large task. 😄 |
I agree, this is fantastic! I'll have a look at this as soon as possible. |
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.
@vishav1771 Thank you for spearheading this effort! That's awesome!
I've started reviewing, but it will obviously take a bit of time to actually complete this due to the sheer volume of proposed changes. I can already promise that I will not be able to do this before the beginning of next week.
However, if you could in the meantime respond to my initial comments and change requests and also look into reasons behind the falling CI pipeline that would help accelerate the process and be very much appreciated.
tests/test_buffered_mode.py
Outdated
|
||
def test_basic_and_nested(self): | ||
def test_basic_and_nested(self,setUp): |
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 help me understand the purpose of the setUp
argument?
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.
setUp
is the function we want to run before running test
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.
But it is not actually executed, is it?
Also, I forgot to mention: You've marked the PR as work-in-progress ([WIP]), GitHub has recently added a feature to mark PRs as work-in-progress directly when you open them. Would be great if you could use that feature next time, because it prevents the bot from automatically assigning reviewers and you have better control in signalling them when the PR is actually ready for review. |
Sure, I will keep in mind next time :) |
Codecov Report
@@ Coverage Diff @@
## master #275 +/- ##
==========================================
+ Coverage 64.91% 64.93% +0.02%
==========================================
Files 40 40
Lines 5626 5635 +9
==========================================
+ Hits 3652 3659 +7
- Misses 1974 1976 +2
Continue to review full report at Codecov.
|
Great, this looks like it's almost done! There are a few minor things that should be fixed, but overall pretty good. One thing that I would like to see applied across all files is that the name pattern for Also, if you could make sure that the changes are meeting our formatting guidelines, which are listed in the contribution guidelines. You can use tools like |
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 accidentally introduced a typo with this commit, otherwise good.
@vishav1771 Would you mind assigning yourself to the related issue: #212 ? |
Sorry for the inconvenience, but I am not able to assign myself this issue. I tried following the official guide, but still, no results. Can you please guide me! |
@csadorf @vishav1771 Vishav does not have permissions to assign himself, and we cannot assign him unless he comments on the issue. Some repos have an “assigner bot” that allows users to claim issues. The bot watches for a comment like “assign me” or “take this issue” and it has write access to add them as an assignee since they have commented. More info: https://help.github.com/en/github/managing-your-work-on-github/assigning-issues-and-pull-requests-to-other-github-users
|
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.
Ok, great! Looks good! One last thing from my side: Can you update the instructions for test execution in the README?
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.
LGTM! 👍
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 am requesting some changes, and I will apply those changes directly so this PR can move forward (otherwise it will block progress on some other PRs that affect tests).
changelog.txt
Outdated
@@ -19,6 +19,7 @@ Changed | |||
+++++++ | |||
|
|||
- Workspace directory is created when ``Project`` is initialized (#267, #271). | |||
- Changed testing framework from ``unittest`` to ``pytest`` (#212, #275) |
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.
- Changed testing framework from ``unittest`` to ``pytest`` (#212, #275) | |
- Changed testing framework from ``unittest`` to ``pytest`` (#212, #275). |
tests/test_collection.py
Outdated
|
||
def test_contains(self): | ||
self.assertFalse('0' in self.c) | ||
assert not ('0' in self.c) |
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.
assert not ('0' in self.c) | |
assert '0' not in self.c |
tests/test_collection.py
Outdated
del self.c[_id] | ||
self.assertFalse(_id in self.c) | ||
assert not (_id in self.c) |
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 might do a search for assert not
to make sure that this gets changed across the whole PR. In general x not in y
is better than not (x in y)
.
assert not (_id in self.c) | |
assert _id not in self.c |
tests/test_job.py
Outdated
|
||
def test_interface_deepcopy(self): | ||
job = self.open_job(dict(a=0)).init() | ||
copy.deepcopy(job.sp).a = 1 | ||
self.assertFalse(job in self.project) | ||
assert not (job in self.project) |
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.
assert not (job in self.project) | |
assert job not in self.project |
tests/test_sync.py
Outdated
@@ -2,7 +2,7 @@ | |||
# All rights reserved. | |||
# This software is licensed under the BSD 3-Clause License. | |||
import os | |||
import unittest | |||
|
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.
tests/test_synced_attrdict.py
Outdated
@@ -1,14 +1,15 @@ | |||
# Copyright (c) 2017 The Regents of the University of Michigan | |||
# All rights reserved. | |||
# This software is licensed under the BSD 3-Clause License. | |||
import unittest | |||
|
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.
tests/test_synced_attrdict.py
Outdated
@@ -516,10 +518,6 @@ def test_nested_types_dict_conversion(self): | |||
sad.items() | |||
assert type(sad['a']) is SAD | |||
sad.values() | |||
assert type(sad['a']) is SAD | |||
assert type(sad['a']), SAD |
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.
assert type(sad['a']), SAD | |
assert type(sad['a']) is SAD |
tests/test_synced_attrdict.py
Outdated
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
assert type(sad['a']), SAD |
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.
assert type(sad['a']), SAD | |
assert type(sad['a']) is SAD |
@vishav1771 I don't have permissions to push to your fork. Can you enable "Allow edits from maintainers" on 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.
A couple of small changes, then this is good to go! Thanks for the huge effort on this PR.
tests/test_buffered_mode.py
Outdated
sleep(1.0) | ||
with open(job.doc._filename, 'wb') as file: | ||
file.write(json.dumps({'a': not x}).encode()) | ||
self.assertIn(job.doc._filename, cm.exception.files) | ||
print(cm.value) | ||
print(job.doc._filename) |
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.
Please remove these prints.
tests/test_indexing.py
Outdated
collection.reset_mock() | ||
for fn in ('a_0.txt', 'a_1.txt'): | ||
os.remove(os.path.join(self._tmp_dir.name, fn)) | ||
N = len(index) | ||
index = list(signac.index(root=self._tmp_dir.name, tags={'test1'})) | ||
self.assertEqual(len(index), N - 1) | ||
assert len(index) == N - 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.
assert len(index) == N - 1 | |
assert len(index) == (N - 1) |
tests/test_jsondict.py
Outdated
assert bool(jsd) | ||
assert len(jsd) == 1 | ||
assert key in jsd | ||
assert key in jsd |
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 we delete this line? This test is identical to the one above.
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, this is deliberately testing twice.
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 need to correct myself, doesn't look like this duplication here is crucial.
Enabled :) |
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.
Thanks again @vishav1771, I think this is complete.
Description
Changed testing framework from
Unittest
toPytest
Motivation and Context
Fixes #212
Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist:
If necessary:
Example for a changelog entry:
Fix issue with launching rockets to the moon (#101, #212).