A facade around @testing.combinations() oriented towards boolean keyword-based arguments. Basically generates a nice looking identifier based on the keywords and also sets up the argument names. E.g.:: @testing.flag_combinations( dict(lazy=False, passive=False)
(*combinations)
| 236 | |
| 237 | |
| 238 | def flag_combinations(*combinations): |
| 239 | """A facade around @testing.combinations() oriented towards boolean |
| 240 | keyword-based arguments. |
| 241 | |
| 242 | Basically generates a nice looking identifier based on the keywords |
| 243 | and also sets up the argument names. |
| 244 | |
| 245 | E.g.:: |
| 246 | |
| 247 | @testing.flag_combinations( |
| 248 | dict(lazy=False, passive=False), |
| 249 | dict(lazy=True, passive=False), |
| 250 | dict(lazy=False, passive=True), |
| 251 | dict(lazy=False, passive=True, raiseload=True), |
| 252 | ) |
| 253 | def test_fn(lazy, passive, raiseload): ... |
| 254 | |
| 255 | would result in:: |
| 256 | |
| 257 | @testing.combinations( |
| 258 | ("", False, False, False), |
| 259 | ("lazy", True, False, False), |
| 260 | ("lazy_passive", True, True, False), |
| 261 | ("lazy_passive", True, True, True), |
| 262 | id_="iaaa", |
| 263 | argnames="lazy,passive,raiseload", |
| 264 | ) |
| 265 | def test_fn(lazy, passive, raiseload): ... |
| 266 | |
| 267 | """ |
| 268 | |
| 269 | keys = set() |
| 270 | |
| 271 | for d in combinations: |
| 272 | keys.update(d) |
| 273 | |
| 274 | keys = sorted(keys) |
| 275 | |
| 276 | return config.combinations( |
| 277 | *[ |
| 278 | ("_".join(k for k in keys if d.get(k, False)),) |
| 279 | + tuple(d.get(k, False) for k in keys) |
| 280 | for d in combinations |
| 281 | ], |
| 282 | id_="i" + ("a" * len(keys)), |
| 283 | argnames=",".join(keys), |
| 284 | ) |
| 285 | |
| 286 | |
| 287 | def lambda_combinations(lambda_arg_sets, **kw): |
nothing calls this directly
no test coverage detected