add tests
This commit is contained in:
@@ -1,7 +1,3 @@
|
|||||||
[build-system]
|
|
||||||
requires = ["setuptools", "setuptools-scm"]
|
|
||||||
build-backend = "setuptools.build_meta"
|
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "fvr"
|
name = "fvr"
|
||||||
dynamic = ["version"]
|
dynamic = ["version"]
|
||||||
@@ -34,7 +30,7 @@ dependencies = [
|
|||||||
|
|
||||||
[project.optional-dependencies]
|
[project.optional-dependencies]
|
||||||
docs = ["sphinx", "furo"]
|
docs = ["sphinx", "furo"]
|
||||||
test = ["pytest"]
|
test = ["pytest>=9.0"]
|
||||||
dev = [
|
dev = [
|
||||||
# recursive optional dependencies
|
# recursive optional dependencies
|
||||||
"fvr[docs,test]",
|
"fvr[docs,test]",
|
||||||
@@ -51,6 +47,10 @@ dev = [
|
|||||||
# "pipdeptree",
|
# "pipdeptree",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools", "setuptools-scm"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[tool.setuptools.dynamic]
|
[tool.setuptools.dynamic]
|
||||||
version = {attr = "fvr.__version__"}
|
version = {attr = "fvr.__version__"}
|
||||||
|
|
||||||
@@ -58,3 +58,15 @@ version = {attr = "fvr.__version__"}
|
|||||||
where = ["src"]
|
where = ["src"]
|
||||||
include = ["fvr*"]
|
include = ["fvr*"]
|
||||||
# namespaces = false
|
# namespaces = false
|
||||||
|
|
||||||
|
[tool.pytest]
|
||||||
|
addopts = ["--doctest-modules", "--doctest-continue-on-failure"]
|
||||||
|
testpaths = [
|
||||||
|
"tests",
|
||||||
|
"src/fvr",
|
||||||
|
]
|
||||||
|
filterwarnings = [
|
||||||
|
# "ignore::DeprecationWarning",
|
||||||
|
# in ezdxf/queryparser.py
|
||||||
|
"ignore:'.*' deprecated - use '.*':DeprecationWarning",
|
||||||
|
]
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ class polygon:
|
|||||||
r"""Determine the area of a simple polygon.
|
r"""Determine the area of a simple polygon.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>>> fvr.geom.polygon([[0, 0], [0, 1], [1, 1], [1, 0]]).area
|
>>> polygon([[0, 0], [0, 1], [1, 1], [1, 0]]).area
|
||||||
>>> fvr.geom.polygon('[[0, 0], [0, 1], [1, 1], [1, 0]]').area
|
1.0
|
||||||
|
>>> polygon('[[0, 0], [0, 1], [1, 1], [1, 0]]').area
|
||||||
|
1.0
|
||||||
|
|
||||||
Shoelace formula, Gauss's area formula, surveyor's formula
|
Shoelace formula, Gauss's area formula, surveyor's formula
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
import numpy as np
|
import numpy.typing
|
||||||
from numpy.typing import NDArray
|
|
||||||
|
|
||||||
type FloatArray = Sequence[float] | NDArray[np.float64]
|
type FloatArray = Sequence[float] | numpy.typing.NDArray[numpy.float64]
|
||||||
|
|||||||
20
tests/test_structure.py
Normal file
20
tests/test_structure.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
"""Test of structure module.
|
||||||
|
|
||||||
|
"""
|
||||||
|
import unittest
|
||||||
|
import fvr.structure
|
||||||
|
|
||||||
|
class TestStructureBeam(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.obj = fvr.structure.beam(1, 2, 3, 4, 5)
|
||||||
|
def test_volume(self):
|
||||||
|
self.assertEqual(self.obj.V, 12, 'incorrect volume after creation')
|
||||||
|
def test_volume_a(self):
|
||||||
|
self.obj.A = 6
|
||||||
|
self.assertEqual(self.obj.V, 24, 'incorrect volume after changing A')
|
||||||
|
def test_volume_l(self):
|
||||||
|
self.obj.L = 7
|
||||||
|
self.assertEqual(self.obj.V, 21, 'incorrect volume after changing L')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user