зеркало из https://github.com/microsoft/pybryt.git
added tests for existing invariants
This commit is contained in:
Родитель
1930f4df50
Коммит
f54fc951ed
13
Makefile
13
Makefile
|
@ -6,8 +6,10 @@
|
|||
# the `testcov` target can be used to build a local copy of the code coverage in HTML
|
||||
# $ make testcov
|
||||
|
||||
TESTPATH="tests"
|
||||
PYTESTOPTS="-v"
|
||||
PYTEST = pytest
|
||||
TESTPATH = tests
|
||||
PYTESTOPTS = -v
|
||||
COVERAGE = coverage
|
||||
|
||||
release:
|
||||
rm dist/* || :
|
||||
|
@ -17,7 +19,10 @@ release:
|
|||
hub release create -a dist/*.tar.gz -a dist/*.whl -m 'v$(VERSION)' $(VERSION)
|
||||
|
||||
test:
|
||||
pytest $(TESTPATH) $(PYTESTOPTS)
|
||||
$(PYTEST) $(TESTPATH) $(PYTESTOPTS)
|
||||
|
||||
testcov:
|
||||
coverage run --source=. -m pytest $(TESTPATH) $(PYTESTOPTS) && coverage html
|
||||
$(COVERAGE) run --source=pybryt -m pytest $(TESTPATH) $(PYTESTOPTS)
|
||||
|
||||
covhtml: testcov
|
||||
$(COVERAGE) html
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
"""Tests for value annotation invariants"""
|
||||
|
||||
import numpy as np
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from pybryt.annotations.invariants import *
|
||||
|
||||
|
||||
def test_call_structure():
|
||||
with mock.patch.object(invariant, "run") as mocked_run:
|
||||
invariant()
|
||||
mocked_run.assert_called()
|
||||
|
||||
assert invariant([]) is None
|
||||
|
||||
|
||||
def test_string_capitalization():
|
||||
np.random.seed(42)
|
||||
values = ["someString", "some_otherO!I(I*$NDdnnfkf", 120484, ["hi", "there"], np.random.uniform(size=100)]
|
||||
expected_values = [s.lower() if isinstance(s, str) else s for s in values]
|
||||
np.testing.assert_equal(string_capitalization(values), expected_values)
|
||||
|
Загрузка…
Ссылка в новой задаче