-
Notifications
You must be signed in to change notification settings - Fork 41
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
Use PyTest tmpdir fixture instead of manually handling them #123
Conversation
tests/test_utils.py
Outdated
@@ -10,20 +9,20 @@ def test_get_bugs(): | |||
bugs = utils.get_bugs() | |||
assert(isinstance(bugs, list)) | |||
|
|||
@pytest.fixture(scope='session') |
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 tests are not fixtures
tests/test_utils.py
Outdated
@@ -10,20 +9,20 @@ def test_get_bugs(): | |||
bugs = utils.get_bugs() | |||
assert(isinstance(bugs, list)) | |||
|
|||
@pytest.fixture(scope='session') | |||
def test_mkdir(tmpdir_factory): |
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.
Use tmpdir
and the path as a string is tmpdir.strpath
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.
See review comments.
Updated. Please check. |
tests/test_utils.py
Outdated
utils.mkdir(direc_path) | ||
def test_mkdir(tmpdir): | ||
dir_path = tmpdir.strpath + "/test" | ||
utils.mkdir(dir_path) |
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.
Changing the name of the variable is unnecessary and leads to changes everywhere, it's better to leave it as it was
tests/test_utils.py
Outdated
@@ -47,12 +45,12 @@ def test_read_labels(): | |||
assert(isinstance(labels, dict)) | |||
|
|||
|
|||
def test_write_labels(): | |||
@pytest.fixture(scope='session') |
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.
Again, tests are not fixtures
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.
missed it. updated now. Please check.
tests/test_utils.py
Outdated
file_path = d.name + "/test.csv" | ||
utils.write_labels(label, file_name=file_path) | ||
assert(os.path.exists(file_path)) | ||
fn = tmpdir.mkdir("data").join("test.csv") |
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 need to create a new directory, use tmpdir directly.
Also, don't change the name of the variable
tests/test_utils.py
Outdated
|
||
|
||
def test_load_image(tmpdir): | ||
d = TemporaryDirectory() | ||
fn = tmpdir.mkdir("data").join("Image.jpg") |
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 need to create another directory, use tmpdir directly
Codecov Report
@@ Coverage Diff @@
## master #123 +/- ##
==========================================
- Coverage 24.24% 23.91% -0.33%
==========================================
Files 10 10
Lines 693 690 -3
Branches 84 84
==========================================
- Hits 168 165 -3
Misses 524 524
Partials 1 1
Continue to review full report at Codecov.
|
96f3d4c
to
d6fdf8a
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.
Thanks! Looks good now!
Please provide your feedback on this pull request here. Privacy statement: We don't store any personal information such as your email address or name. We ask for GitHub authentication as an anonymous identifier to account for duplicate feedback entries and to see people specific preferences. |
Fixes #70