-
Notifications
You must be signed in to change notification settings - Fork 5
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
Change to pytest #111
Merged
Merged
Change to pytest #111
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7c35f85
use pytest: unittest -> pytest translation
stenczelt f5661e5
use pytest: CI update & dependencies, including coverage
stenczelt 284807a
pytest in dev dependencies
stenczelt f28b199
empty tests/__init__.py
stenczelt 4dcb3b3
Update .github/workflows/ci.yml
stenczelt 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 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,32 +1,37 @@ | ||
name: ci | ||
|
||
on: [push, pull_request] | ||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11", "3.12"] | ||
python-version: [ "3.9", "3.10", "3.11", "3.12" ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install poetry | ||
run: pipx install poetry | ||
- name: Install poetry | ||
run: pipx install poetry | ||
|
||
- name: Install python dependencies | ||
run: | | ||
poetry env use ${{ matrix.python-version }} | ||
poetry install --with dev | ||
- name: Install python dependencies | ||
run: | | ||
poetry env use ${{ matrix.python-version }} | ||
poetry install --with dev | ||
|
||
- name: Run unit tests | ||
run: | | ||
poetry run python -m unittest -v tests | ||
- name: Run unit tests | ||
run: | | ||
poetry run pytest --cov=abcd --cov-report xml --cov-report term:skip-covered | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v4.0.1 | ||
stenczelt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
This file contains 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
This file contains 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,9 +0,0 @@ | ||
import unittest | ||
from tests.parsers import ParsingQueries, ParsingExtras | ||
from tests.database import Mongo | ||
|
||
import logging | ||
|
||
if __name__ == '__main__': | ||
logging.basicConfig(level=logging.INFO) | ||
unittest.main(verbosity=1, exit=False) | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
import mongomock | ||
|
||
from abcd import ABCD | ||
|
||
from io import StringIO | ||
from ase.io import read | ||
|
||
|
||
@pytest.fixture | ||
@mongomock.patch(servers=(('localhost', 27017),)) | ||
def abcd_mongodb(): | ||
url = 'mongodb://localhost' | ||
abcd = ABCD.from_url(url) | ||
abcd.print_info() | ||
|
||
return abcd | ||
|
||
|
||
def test_thing(abcd_mongodb): | ||
print(abcd_mongodb.info()) | ||
|
||
|
||
def test_push(abcd_mongodb): | ||
xyz = StringIO("""2 | ||
Properties=species:S:1:pos:R:3 s="sadf" _vtk_test="t e s t _ s t r" pbc="F F F" | ||
Si 0.00000000 0.00000000 0.00000000 | ||
Si 0.00000000 0.00000000 0.00000000 | ||
""") | ||
|
||
atoms = read(xyz, format='extxyz') | ||
atoms.set_cell([1, 1, 1]) | ||
|
||
abcd_mongodb.destroy() | ||
abcd_mongodb.push(atoms) | ||
new = list(abcd_mongodb.get_atoms())[0] | ||
|
||
assert atoms == new |
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.
Any reason for pinning to 4.0.1 specifically? I think the most recent release is 4.4.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 special intention, the codecov instructions provided this snippet