-
Notifications
You must be signed in to change notification settings - Fork 21
Move tests folder to top and use pytest to run all tests #96
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
37b32db
Move tests dir to top level
bobleesj fa20e3d
Implement test helper as fixture
bobleesj a36af71
Remove unittest run files
bobleesj ccce7f2
Remove content of pytest.ini
bobleesj cc5305d
Run init files for unittest
bobleesj 2d5e571
Use conftest within unittesT
bobleesj 19a7da8
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
[pytest] | ||
testpaths= src/diffpy/utils/tests | ||
python_files = test_*.py | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,18 +6,20 @@ | |
import unittest | ||
|
||
import numpy | ||
import pytest | ||
|
||
from diffpy.utils.parsers import loadData | ||
from diffpy.utils.tests.testhelpers import datafile | ||
|
||
loaddata01 = datafile("loaddata01.txt") | ||
loaddatawithheaders = datafile("loaddatawithheaders.txt") | ||
|
||
|
||
############################################################################## | ||
class TestLoadData(unittest.TestCase): | ||
@pytest.fixture(autouse=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Trick to use |
||
def prepare_fixture(self, datafile): | ||
self.datafile = datafile | ||
|
||
def test_loadData_default(self): | ||
"""check loadData() with default options""" | ||
loaddata01 = self.datafile("loaddata01.txt") | ||
d2c = numpy.array([[3, 31], [4, 32], [5, 33]]) | ||
self.assertRaises(IOError, loadData, "doesnotexist") | ||
# the default minrows=10 makes it read from the third line | ||
|
@@ -35,6 +37,7 @@ def test_loadData_default(self): | |
|
||
def test_loadData_1column(self): | ||
"""check loading of one-column data.""" | ||
loaddata01 = self.datafile("loaddata01.txt") | ||
d1c = numpy.arange(1, 6) | ||
d = loadData(loaddata01, usecols=[0], minrows=1) | ||
self.assertTrue(numpy.array_equal(d1c, d)) | ||
|
@@ -46,6 +49,7 @@ def test_loadData_1column(self): | |
|
||
def test_loadData_headers(self): | ||
"""check loadData() with headers options enabled""" | ||
loaddatawithheaders = self.datafile("loaddatawithheaders.txt") | ||
hignore = ["# ", "// ", "["] # ignore lines beginning with these strings | ||
delimiter = ": " # what our data should be separated by | ||
hdata = loadData(loaddatawithheaders, headers=True, hdel=delimiter, hignore=hignore) | ||
|
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
pytest automatically detects files starting with
test_.