adjust some python tests to work with PyPy

Part of #467.

* tests/python/bdddict.py, tests/python/ltl2tgba.py,
tests/python/ltlparse.py, tests/python/ltlsimple.py,
tests/python/sccinfo.py, tests/python/simstate.py,
tests/python/split.py, tests/python/tra2tba.py: Adjust to
deal with a non-refcounted Python implementation.
This commit is contained in:
Alexandre Duret-Lutz 2021-06-29 23:16:40 +02:00
parent 47348a9755
commit 3d79022abb
8 changed files with 141 additions and 25 deletions

View file

@ -1,6 +1,6 @@
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2016-2018, 2020 Laboratoire de Recherche et Développement
# de l'Epita
# Copyright (C) 2016-2018, 2020-2021 Laboratoire de Recherche
# et Développement de l'Epita
#
# This file is part of Spot, a model checking library.
#
@ -19,6 +19,12 @@
import spot
# CPython use reference counting, so that automata are destructed
# when we expect them to be. However other implementations like
# PyPy may call destructors latter, causing different output.
from platform import python_implementation
is_cpython = python_implementation() == 'CPython'
# Test 1.
aut = spot.automaton("""
HOA: v1
@ -365,7 +371,10 @@ State: 7
--END--"""
res = spot.remove_fin(aut)
assert(res.to_str('hoa') == exp)
if is_cpython:
assert(res.to_str('hoa') == exp)
else:
assert(res.equivalent_to(spot.automaton(exp)))
# Test 9.
aut = spot.automaton("""
@ -401,7 +410,10 @@ State: 1
--END--"""
res = spot.remove_fin(aut)
assert(res.to_str('hoa') == exp)
if is_cpython:
assert(res.to_str('hoa') == exp)
else:
assert(res.equivalent_to(spot.automaton(exp)))
# Test 10.
aut = spot.automaton("""
@ -440,7 +452,10 @@ State: 2 {0}
--END--"""
res = spot.remove_fin(aut)
assert(res.to_str('hoa') == exp)
if is_cpython:
assert(res.to_str('hoa') == exp)
else:
assert(res.equivalent_to(spot.automaton(exp)))
# Test 11.
aut = spot.automaton("""
@ -477,7 +492,10 @@ State: 1
--END--"""
res = spot.remove_fin(aut)
assert(res.to_str('hoa') == exp)
if is_cpython:
assert(res.to_str('hoa') == exp)
else:
assert(res.equivalent_to(spot.automaton(exp)))
# Different order for rabin_to_buchi_if_realizable() due to merge_edges() not
# being called. This is on purpose: the edge order should match exactly the
@ -499,7 +517,10 @@ State: 1
[!0] 0 {0}
--END--"""
res = spot.rabin_to_buchi_if_realizable(aut)
assert(res.to_str('hoa') == exp2)
if is_cpython:
assert(res.to_str('hoa') == exp2)
else:
assert(res.equivalent_to(spot.automaton(exp2)))
# Test 12.
aut = spot.automaton("""
@ -543,7 +564,10 @@ State: 3 {0}
--END--"""
res = spot.remove_fin(aut)
assert(res.to_str('hoa') == exp)
if is_cpython:
assert(res.to_str('hoa') == exp)
else:
assert(res.equivalent_to(spot.automaton(exp)))
# Test 13.
aut = spot.automaton("""
@ -590,7 +614,10 @@ State: 1
--END--"""
res = spot.remove_fin(aut)
assert(res.to_str('hoa') == exp)
if is_cpython:
assert(res.to_str('hoa') == exp)
else:
assert(res.equivalent_to(spot.automaton(exp)))
# rabin_to_buchi_if_realizable() does not call merge_edges() on purpose: the
# edge order should match exactly the original automaton.
@ -616,7 +643,10 @@ State: 1
--END--"""
res = spot.rabin_to_buchi_if_realizable(aut)
assert(res.to_str('hoa') == exp2)
if is_cpython:
assert(res.to_str('hoa') == exp2)
else:
assert(res.equivalent_to(spot.automaton(exp2)))
# Test 14.
aut = spot.automaton("""
@ -650,5 +680,8 @@ State: 1
--END--"""
res = spot.remove_fin(aut)
assert(res.to_str('hoa') == exp)
if is_cpython:
assert(res.to_str('hoa') == exp)
else:
assert(res.equivalent_to(spot.automaton(exp)))
assert spot.rabin_to_buchi_if_realizable(aut) is None