Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add semantic model test to
test_contracts_graph_parsed.py
(#8654)
* Add semantic model test to `test_contracts_graph_parsed.py` The tests in `test_contracts_graph_parsed.py` are meant to ensure that we can go from objects to dictionaries and back without any changes. We've had a desire to simplify these tests. Most tests in this file have three to four fixtures, this test only has one. What a test of this format ensures is that parsing a SemanticModel from a dictionary doesn't add/drop any keys from the dictionary and that when going back to the dictionary no keys are dropped. This style of test will still break whenever the semantic model (or sub objects) change. However now when that happens, only one fixture will have to be updated (whereas previously we had to update 3-4 fixtures). * Begin using hypothesis package for symmetry testing Hypothesis is a python package for doing property testing. The `@given` parameterizes a test, with it generating the arguements it has following `strategies`. The main strategies we use is `builds` this takes in a callable passes any sub strategies for named arguements, and will try to infer any other arguments if the callable is typed. I found that even though the test was run many many times, some of the `SemanticModel` properties weren't being changed. For instance `dimensions`, `entities`, and `measures` were always empty lists. Because of this I defined sub strategies for some attributes of `SemanticModel`s. * Update unittest readme to have details on test_contracts_graph_parsed methodology
- Loading branch information