Anders and Briegel in Python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
555B

  1. import abp
  2. import pytest
  3. mock = pytest.importorskip("mock")
  4. def test_json():
  5. """ Test to_json and from_json """
  6. a = mock.named_node_graph()
  7. j = a.to_json()
  8. b = abp.GraphState()
  9. b.from_json(j)
  10. assert a == b
  11. def test_json_again():
  12. """ Test to_json and from_json """
  13. # Make a random graph
  14. a = abp.GraphState(10)
  15. a.act_circuit(mock.random_graph_circuit())
  16. # Dump it to JSON
  17. j = a.to_json()
  18. # Reconstruct from JSON
  19. b = abp.GraphState()
  20. b.from_json(j)
  21. # Check equality
  22. assert a == b