Skip to content

Commit

Permalink
Use python testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Dec 17, 2023
1 parent f57e5b4 commit b4de0d5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ hyperfine_*.deb

# Python
.venv
*.pyc

# JS
node_modules/
Expand Down
4 changes: 2 additions & 2 deletions lib/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ Build the pip package, and run the `python/try.py` script:
./scripts/build-python.sh
```

Or just run the script:
Or just run the tests:

```bash
source .venv/bin/activate
python python/try.py
python -m pytest python/tests/
```

### 🟨 Run JavaScript
Expand Down
6 changes: 3 additions & 3 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Install maturin:
```bash
python -m venv .venv
source .venv/bin/activate
pip install "maturin[patchelf]"
pip install "maturin[patchelf]" pytest
```

## Develop
Expand All @@ -18,10 +18,10 @@ Start in dev:
maturin develop
```

Try the python lib:
Run the tests with:

```bash
python try.py
python -m pytest
```

## Build
Expand Down
1 change: 1 addition & 0 deletions python/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests."""
17 changes: 17 additions & 0 deletions python/tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import unittest

from curies_rs import Record, Converter


class TestAPI(unittest.TestCase):
"""Test the API."""

def test_converter(self):
"""Test the converter."""
rec1 = Record("doid", "http://purl.obolibrary.org/obo/DOID_", [], [])

converter = Converter()
converter.add_record(rec1)

uri = converter.compress("http://purl.obolibrary.org/obo/DOID_1234")
self.assertEqual("doid:1234", uri)
12 changes: 0 additions & 12 deletions python/try.py

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/build-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ cd python

maturin develop

python try.py
python -m pip install pytest
python -m pytest

0 comments on commit b4de0d5

Please sign in to comment.