Skip to content

Commit d3a9fce

Browse files
committed
TST: Add tests for a single file at a time.
1 parent ca9aa90 commit d3a9fce

File tree

9 files changed

+36
-47
lines changed

9 files changed

+36
-47
lines changed

README.rst

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,6 @@
11
.. These are examples of badges you might want to add to your README:
22
please update the URLs accordingly
33
4-
.. image:: https://api.cirrus-ci.com/github/<USER>/check-python-h-first.svg?branch=main
5-
:alt: Built Status
6-
:target: https://cirrus-ci.com/github/<USER>/check-python-h-first
7-
.. image:: https://readthedocs.org/projects/check-python-h-first/badge/?version=latest
8-
:alt: ReadTheDocs
9-
:target: https://check-python-h-first.readthedocs.io/en/stable/
10-
.. image:: https://img.shields.io/coveralls/github/<USER>/check-python-h-first/main.svg
11-
:alt: Coveralls
12-
:target: https://coveralls.io/r/<USER>/check-python-h-first
13-
.. image:: https://img.shields.io/pypi/v/check-python-h-first.svg
14-
:alt: PyPI-Server
15-
:target: https://pypi.org/project/check-python-h-first/
16-
.. image:: https://img.shields.io/conda/vn/conda-forge/check-python-h-first.svg
17-
:alt: Conda-Forge
18-
:target: https://anaconda.org/conda-forge/check-python-h-first
19-
.. image:: https://pepy.tech/badge/check-python-h-first/month
20-
:alt: Monthly Downloads
21-
:target: https://pepy.tech/project/check-python-h-first
22-
.. image:: https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Twitter
23-
:alt: Twitter
24-
:target: https://twitter.com/check-python-h-first
25-
264
.. image:: https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold
275
:alt: Project generated with PyScaffold
286
:target: https://pyscaffold.org/

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ version_scheme = "no-guess-dev"
1010

1111
[project.scripts]
1212
check_python_h_first = "check_python_h_first.__main__:main"
13+
14+
[project]
15+
dynamic = ["version", "readme", "optional-dependencies"]
16+
name = "check-python-h-first"
17+
description = "Script to check whether Python.h is included first in any relevant files."

tests/myheader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <Python.h>

tests/numpy_system.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include "numpy/npy_common.h"
2+
#include <sys/time.h>

tests/python_h_only.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <Python.h>

tests/python_h_system.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include <Python.h>
2+
#include <sys/time.h>

tests/system_python_h.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#include <sys/time.h>
2+
#include <Python.h>

tests/test_single_file.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""Test check_python_h_included_first on a single file at a time."""
2+
3+
import glob
4+
import os.path
5+
6+
import pytest
7+
8+
from check_python_h_first.single_file import check_python_h_included_first
9+
10+
THIS_DIR = os.path.dirname(__file__)
11+
12+
HEADER_LIST = glob.glob(os.path.join(THIS_DIR, "*.h"))
13+
SOURCE_LIST = glob.glob(os.path.join(THIS_DIR, "*.c"))
14+
15+
16+
@pytest.mark.parametrize("file", HEADER_LIST + SOURCE_LIST)
17+
def test_files(file: str):
18+
"""Test whether function on a single file."""
19+
actual = check_python_h_included_first(file)
20+
if os.path.basename(file).startswith("system"):
21+
assert actual > 0
22+
else:
23+
assert actual == 0

tests/test_skeleton.py

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

0 commit comments

Comments
 (0)