Skip to content

Commit 78d1048

Browse files
committed
Add tests, iosrt, flake8, codecov
1 parent bc92906 commit 78d1048

File tree

10 files changed

+76
-67
lines changed

10 files changed

+76
-67
lines changed

.codecov.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ coverage:
1010
status:
1111
patch:
1212
default:
13-
target: '80'
13+
target: '70'
1414
if_no_uploads: error
1515
if_not_found: success
1616
if_ci_failed: failure
@@ -20,12 +20,13 @@ coverage:
2020
target: auto
2121
if_no_uploads: error
2222
if_not_found: success
23-
if_ci_failed: failure
23+
if_ci_failed: error
2424
paths: '!*/tests/.*'
2525

2626
tests:
2727
target: 97.9%
2828
paths: '*/tests/.*'
29+
if_not_found: success
2930

3031
flags:
3132
tests:

.flake8

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@ exclude =
44
__pycache__,
55
build,
66
dist,
7-
doc/source/conf.py,
8-
*/doc/source/conf.py,
9-
hooks/post_gen_project.py,
10-
*/__init__.py,
11-
*/debug.py
12-
builtins = cookiecutter
7+
doc/source/conf.py
138
max-line-length = 115
14-
# Ignore some style 'errors' produced while formatting by 'black' (see link below)
9+
# Ignore some style 'errors' produced while formatting by 'black'
1510
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
1611
extend-ignore = E203

.isort.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[settings]
2+
line_length = 115
3+
multi_line_output = 3
4+
include_trailing_comma = True

.pre-commit-config.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
default_language_version:
2-
python: python3
2+
python: python3
33
ci:
4-
autofix_commit_msg: |
5-
[pre-commit.ci] auto fixes from pre-commit hooks
6-
autofix_prs: true
7-
autoupdate_branch: 'pre-commit-autoupdate'
8-
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
9-
autoupdate_schedule: monthly
10-
skip: [no-commit-to-branch]
11-
submodules: false
4+
autofix_commit_msg: |
5+
[pre-commit.ci] auto fixes from pre-commit hooks
6+
autofix_prs: true
7+
autoupdate_branch: 'pre-commit-autoupdate'
8+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
9+
autoupdate_schedule: monthly
10+
skip: [no-commit-to-branch]
11+
submodules: false
1212
repos:
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
1414
rev: v4.6.0
1515
hooks:
1616
- id: check-yaml
17-
exclude: 'environment.yml'
1817
- id: end-of-file-fixer
1918
- id: trailing-whitespace
20-
exclude: '\.(rst|txt)$'
19+
- id: check-case-conflict
20+
- id: check-merge-conflict
21+
- id: check-toml
22+
- id: check-added-large-files
2123
- repo: https://github.com/psf/black
2224
rev: 24.4.2
2325
hooks:
2426
- id: black
25-
exclude: '.*\.py'
2627
- repo: https://github.com/pycqa/flake8
2728
rev: 7.0.0
2829
hooks:

LICENSE_DANSE.txt

Lines changed: 0 additions & 34 deletions
This file was deleted.

news/TEMPLATE.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

tests/conftest.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
7+
@pytest.fixture
8+
def user_filesystem(tmp_path):
9+
base_dir = Path(tmp_path)
10+
home_dir = base_dir / "home_dir"
11+
home_dir.mkdir(parents=True, exist_ok=True)
12+
cwd_dir = base_dir / "cwd_dir"
13+
cwd_dir.mkdir(parents=True, exist_ok=True)
14+
15+
home_config_data = {"username": "home_username", "email": "[email protected]"}
16+
with open(home_dir / "diffpyconfig.json", "w") as f:
17+
json.dump(home_config_data, f)
18+
19+
yield tmp_path

tests/test_recipeorganizer.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
from diffpy.srfit.equation.builder import EquationFactory
2424
from diffpy.srfit.fitbase.calculator import Calculator
2525
from diffpy.srfit.fitbase.parameter import Parameter
26-
from diffpy.srfit.fitbase.recipeorganizer import (
27-
RecipeContainer,
28-
RecipeOrganizer,
29-
equationFromString,
30-
)
26+
from diffpy.srfit.fitbase.recipeorganizer import RecipeContainer, RecipeOrganizer, equationFromString
3127

3228
# ----------------------------------------------------------------------------
3329

tests/test_sgconstraints.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@
1818
import unittest
1919

2020
import numpy
21-
from utils import (
22-
_msg_nopyobjcryst,
23-
_msg_nostructure,
24-
datafile,
25-
has_pyobjcryst,
26-
has_structure,
27-
)
21+
from utils import _msg_nopyobjcryst, _msg_nostructure, datafile, has_pyobjcryst, has_structure
2822

2923
# ----------------------------------------------------------------------------
3024

tests/test_version.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Unit tests for __version__.py
2+
"""
3+
4+
import diffpy.srfit
5+
6+
7+
def test_package_version():
8+
"""Ensure the package version is defined and not set to the initial placeholder."""
9+
assert hasattr(diffpy.srfit, "__version__")
10+
assert diffpy.srfit.__version__ != "0.0.0"

0 commit comments

Comments
 (0)