Anders and Briegel in Python
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
518B

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