test_context_conditions
Hosted unit tests for compiling bundle context strings.
Run from Revit via the DevTools "Run All Tests" button, which discovers every
test_* module in this package. Regression tests for pyRevit #3988: a context
with several (...) groups used to keep only the last group, so a button could
be enabled where an earlier group said it must not be.
The tests call ScriptCommandExtendedAvail.FromContextDefinition on the
runtime assembly loaded into the host and evaluate against the active document,
so they need a document open; the evaluation tests skip without one.
Attributes
TEST_ENVIRONMENT = 'Revit'
module-attribute
TEST_LEVEL = 'Unit'
module-attribute
RUNTIME_ASSEMBLY_PREFIX = 'pyRevitLabs.PyRevit.Runtime.'
module-attribute
AVAIL_TYPE_NAME = 'PyRevitLabs.PyRevit.Runtime.ScriptCommandExtendedAvail'
module-attribute
Classes
ContextGroupCompilationTests
Bases: TestCase
Every parenthesised group compiles to its own condition.
Methods:
setUp()
test_all_groups_are_kept()
test_group_order_does_not_change_the_groups()
Group order does not change which groups are compiled.
Source code in pyrevitlib/pyrevit/unittests/test_context_conditions.py
test_three_groups_are_kept()
More than two groups are all kept.
test_group_separators_do_not_leak_into_later_groups()
A group's own separator stays with that group.
Source code in pyrevitlib/pyrevit/unittests/test_context_conditions.py
test_negation_applies_to_its_own_group_only()
A leading ! negates the next group and no other.
ContextGroupEvaluationTests
Bases: TestCase
Every group takes part in the result, whatever its position.
Methods:
setUp()
Skip without an active document or runtime assembly.
Source code in pyrevitlib/pyrevit/unittests/test_context_conditions.py
test_contradicting_groups_never_match_in_either_order()
Groups that exclude each other never match, whatever the order.
Source code in pyrevitlib/pyrevit/unittests/test_context_conditions.py
test_alternative_groups_match_in_either_order()
Any matching group is enough for an any-condition.