Skip to content

Commit

Permalink
Fix: move to hatch scripts for tests, move to pytest + CI (#90)
Browse files Browse the repository at this point in the history
* Fix: move to hatch scripts for tests and move to pytest
* Fix: setup ci for tests
* Fix: python version in quotes
  • Loading branch information
lwasser authored Feb 21, 2024
1 parent 2b883ca commit 11ba036
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 37 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run pyos meta tests

on:
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Hatch
run: pipx install hatch
- name: Run tests
run: hatch run test:run-tests
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## Unreleased

* Enh: Use `hatch_vcs` for dynamic versioning (@lwasser, #82)

* Fix: migrate to pytest for tests and setup hatch scripts (#89, @lwasser)

## v.0.2
lots of stuff here... :) none of it documented
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ Contributions of any kind welcome!

[CONTRIBUTING.md](./CONTRIBUTING.md)

## Development

[Development guide](./development.md)

## Change log

[CHANGELOG.md](./CHANGELOG.md)
Expand Down
17 changes: 17 additions & 0 deletions development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Development Guide

## Packaging

pyosMeta uses hatch and hatchling as it's build back end.

## Running tests

To install tests:

`python -m pip install ".[tests]"`

We use Hatch scripts to automate workflows.

To run tests, you can use:

`hatch run test:run-tests`
29 changes: 16 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ maintainers = [
]

classifiers = [
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 4 - Beta",

# Indicate who your project is intended for
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",

Expand Down Expand Up @@ -50,15 +44,11 @@ license = { text = "MIT" }

[project.optional-dependencies]
dev = [
"pre-commit",
"hatch"
"pre-commit"
]
# Examples listed include a pattern for specifying where the package tracks
# issues, where the source is hosted, where to say thanks to the package
# maintainers, and where to support the project financially. The key is
# what's used to render the link text on PyPI.

[project.urls]
"Homepage" = "https://www.pyopensci.org"
"Homepage" = "https://github.com/pyopensci/pyosmeta/"
"Bug Reports" = "https://github.com/pyopensci/pyosmeta/issues"
"Source" = "https://github.com/pyopensci/pyosmeta/issues"

Expand All @@ -71,10 +61,23 @@ update-contributors = "pyosmeta.cli.update_contributors:main"
update-reviews = "pyosmeta.cli.process_reviews:main"
update-review-teams = "pyosmeta.cli.update_review_teams:main"

### Hatch config ###

[tool.hatch]
version.source = "vcs"
build.hooks.vcs.version-file = "src/pyosmeta/_version.py"

[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-cov",
]

[tool.hatch.envs.test.scripts]
#run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov=tests"
#run = "run-coverage --no-cov"
run-tests = "pytest"

[tool.black]
line-length = 79
target-version = ['py310']
Expand Down
41 changes: 18 additions & 23 deletions src/tests/test_parse_user_names.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
from unittest import TestCase
import pytest

from pyosmeta.parse_issues import parse_user_names


class TestParseUserNames(TestCase):
def setUp(self) -> None:
self.name1 = "Test User (@test1user)"
self.name2 = "(@test2user)"
self.name3 = "Test (user) 3 (@test3user)"
self.name4 = "@test4user"

def test_parse_1(self):
d = {"name": "Test User", "github_username": "test1user"}
self.assertDictEqual(d, parse_user_names(self.name1))

def test_parse_2(self):
d = {"name": "", "github_username": "test2user"}
self.assertDictEqual(d, parse_user_names(self.name2))

def test_parse_3(self):
d = {"name": "Test user 3", "github_username": "test3user"}
self.assertDictEqual(d, parse_user_names(self.name3))

def test_parse_4(self):
d = {"name": "", "github_username": "test4user"}
self.assertDictEqual(d, parse_user_names(self.name4))
@pytest.mark.parametrize(
"name, expected_result",
[
(
"Test User (@test1user)",
{"name": "Test User", "github_username": "test1user"},
),
("(@test2user)", {"name": "", "github_username": "test2user"}),
(
"Test (user) 3 (@test3user)",
{"name": "Test user 3", "github_username": "test3user"},
),
("@test4user", {"name": "", "github_username": "test4user"}),
],
)
def test_parse_user_names(name, expected_result):
assert parse_user_names(name) == expected_result

0 comments on commit 11ba036

Please sign in to comment.