summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortoofar <toofar@spalge.com>2022-12-26 19:14:15 +1300
committertoofar <toofar@spalge.com>2022-12-26 19:14:15 +1300
commite53aca8f2a82d4300b518893bc4c4538206a38f4 (patch)
tree7adc21a3fa21f2f58df7fd4fabad50b152892d00
parent07272a8d016c72a7e62430c29bd9cadb45482bde (diff)
downloadqutebrowser-e53aca8f2a82d4300b518893bc4c4538206a38f4.tar.gz
qutebrowser-e53aca8f2a82d4300b518893bc4c4538206a38f4.zip
make configtype from_str hypothesis check skip subclasses too
We are already skipping round trip tests for partial functions made in gen_classes from compound classes (list, dict, ...). This change makes it so we skip trying it for subclasses of those compound classes too (eg FlagList and Padding). This is due to the test failing with the input "- A" to FlagList. Also switches the Dict example in the comment to be the same order as the other two. Some questions I don't know the answers to: * Why are List and Dict using `json.dumps()` in `to_str()` instead of `yaml_dump()`? * Is `to_str()` used anywhere apart from tests? * Should we have a `to_yaml()` or just use `yaml_dump()` in the test to get back the original value?
-rw-r--r--tests/unit/config/test_configtypes.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index e4351d619..99b8a5de0 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -255,11 +255,14 @@ class TestAll:
configtypes.PercOrInt, # ditto
]:
return
- elif (isinstance(klass, functools.partial) and klass.func in [
- configtypes.ListOrValue, configtypes.List, configtypes.Dict]):
- # ListOrValue: "- /" -> "/"
- # List: "- /" -> ["/"]
- # Dict: '{":": "A"}' -> ':: A'
+
+ # Dict and List deserialize to yaml but serialize to json, so we can't
+ # do a naive round trip test with them. For example:
+ # ListOrValue: "- /" -> "/"
+ # List: "- /" -> ["/"]
+ # Dict: ':: A' -> '{":": "A"}'
+ compound_types = (configtypes.ListOrValue, configtypes.List, configtypes.Dict)
+ if isinstance(typ, compound_types):
return
assert converted == s