test_script_module
Hosted unit tests for the pyrevit.script module.
Run from Revit via the DevTools "Script Module Tests" button (zero-doc context) or the "Run All Tests" aggregator. The tests assert the command-runtime contract: logger/output access, bundle file resolution, data file helpers, and environment variable round trips.
Classes
ScriptInfoTests
Bases: TestCase
Command metadata exposed to running scripts.
Methods:
setUp()
Resolve the running command info object.
Command resolution matches bundle directories against the known command subclasses, so the components module must be imported first; in engines that never loaded it, subclasses() is empty and get_info() resolves to None.
Source code in pyrevitlib/pyrevit/unittests/test_script_module.py
test_info_available()
test_unique_name_format()
Unique command name is lowercase with no whitespace.
Source code in pyrevitlib/pyrevit/unittests/test_script_module.py
test_script_file_exists()
Resolved script file exists inside the bundle.
ScriptLoggerTests
Bases: TestCase
Logger wrapper exposes the extended level methods.
Methods:
setUp()
test_standard_levels()
Standard logging levels are callable.
test_extended_levels()
BundleFileTests
Bases: TestCase
Bundle resource resolution relative to the command bundle.
Methods:
setUp()
test_get_bundle_file_missing_returns_nonexistent_path()
Missing resources resolve to a joined path that does not exist.
Source code in pyrevitlib/pyrevit/unittests/test_script_module.py
test_get_bundle_files_missing_raises()
Missing sub-paths raise an OS error from the directory listing.
Source code in pyrevitlib/pyrevit/unittests/test_script_module.py
test_get_bundle_file_existing()
Bundle metadata file resolves to an existing path.
Source code in pyrevitlib/pyrevit/unittests/test_script_module.py
test_bundle_directory_exists()
The resolved bundle directory exists on disk.
DataFileTests
Bases: TestCase
Data file helpers create, read, and remove slot files.
Methods:
setUp()
tearDown()
test_instance_data_file_round_trip()
Instance data files persist content between calls in a session.
Source code in pyrevitlib/pyrevit/unittests/test_script_module.py
EnvVarTests
Bases: TestCase
Environment variable helpers round trip values.
Methods:
test_set_get_envvar()
Stored env var values are returned by the getter.