Skip to content

Commit f93ce11

Browse files
committed
TST: assert that CUDD statistics interfaces issue UserWarning
specifically the methods `dd.cudd.BDD.statistics` and `dd.cudd_zdd.BDD.statistics`. This `UserWarning` was introduced to inform the users about a recent API change. Moving the function `test_str` from the module `tests/common.py` to the modules `tests/autoref_test.py`, `tests/cudd_test.py`, and `tests/cudd_zdd_test.py`, with appropriate modification in each case, turned out to be the simplest way of implementing this check. The function `nose.tools.assert_warns` is used. In the upcoming commit that switches to using `pytest` for testing, the function [`pytest.warns`][1] will be used (read also ["Asserting warnings with the warns function"][2]). [1]: https://docs.pytest.org/en/latest/reference/reference.html#pytest-warns [2]: https://docs.pytest.org/en/latest/how-to/capture-warnings.html#warns
1 parent aceff98 commit f93ce11

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

tests/autoref_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
BDDTests.DD = _bdd.BDD
1717

1818

19+
def test_str():
20+
bdd = _bdd.BDD()
21+
s = str(bdd)
22+
s + 'must be a string'
23+
24+
1925
def test_find_or_add():
2026
bdd = _bdd.BDD()
2127
bdd.declare('x', 'y')

tests/common.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ def test_contains(self):
8383
with assert_raises(AssertionError):
8484
other_true in bdd
8585

86-
def test_str(self):
87-
bdd = self.DD()
88-
s = str(bdd)
89-
s + 'must be a string'
90-
9186
def test_var_levels(self):
9287
bdd = self.DD()
9388
# single variable

tests/cudd_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33

44
from dd import cudd
5-
from nose.tools import assert_raises
5+
from nose.tools import assert_raises, assert_warns
66

77
from common import Tests
88
from common_bdd import Tests as BDDTests
@@ -18,6 +18,13 @@
1818
CuddTests.MODULE = cudd
1919

2020

21+
def test_str():
22+
bdd = cudd.BDD()
23+
with assert_warns(UserWarning):
24+
s = str(bdd)
25+
s + 'must be a string'
26+
27+
2128
def test_insert_var():
2229
bdd = cudd.BDD()
2330
level = 0

tests/cudd_zdd_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from dd import cudd
55
from dd import cudd_zdd
66
from dd import _copy
7+
from nose.tools import assert_warns
78

89
from common import Tests as Tests
910
from common_cudd import Tests as CuddTests
@@ -14,6 +15,13 @@
1415
CuddTests.MODULE = cudd_zdd
1516

1617

18+
def test_str():
19+
bdd = cudd_zdd.ZDD()
20+
with assert_warns(UserWarning):
21+
s = str(bdd)
22+
s + 'must be a string'
23+
24+
1725
def test_false():
1826
zdd = cudd_zdd.ZDD()
1927
u = zdd.false

0 commit comments

Comments
 (0)