feat(testing): Option Overrides for testing#50
Conversation
…-for-client-libraries Resolve merge conflicts: - main.yml: Keep musl build targets and CLI change detection - main.py: Merge wrapper function approach with string-option support - values.json: Keep deletion (values now generated via CLI from examples/configs/)
There was a problem hiding this comment.
not the best convention to include imports here in init.py, but needed due to packaging purposes for the client
| fi | ||
|
|
||
| # Set SENTRY_OPTIONS_DIR to absolute path for tests | ||
| export SENTRY_OPTIONS_DIR="${PWD}/sentry-options" |
There was a problem hiding this comment.
so that it doesn't matter which directory you're running python/rust tests
…-for-client-libraries
There was a problem hiding this comment.
i don't think this belonged here
| flush=True, | ||
| ) | ||
|
|
||
| def get_string_value(): |
There was a problem hiding this comment.
this makes it easier to unit test overrides
| static GLOBAL_OPTIONS: OnceLock<RustOptions> = OnceLock::new(); | ||
|
|
||
| // Hook for testing module to register override checker | ||
| static OVERRIDE_HOOK: OnceLock<Py<PyAny>> = OnceLock::new(); |
There was a problem hiding this comment.
Once testing module is imported, it will set this hook and each get() will use values from python dict that includes overrided values
| impl NamespaceOptions { | ||
| /// Get an option value, returning the schema default if not set. | ||
| fn get(&self, py: Python<'_>, key: &str) -> PyResult<Py<PyAny>> { | ||
| if let Some(value) = get_override(&self.namespace, key) { |
There was a problem hiding this comment.
this overhead should be negligible, there are ways around this but requires overengineering this IMO and don't think that is worth it right now.
There was a problem hiding this comment.
i think i understand, so in the rust version, we can compile without the get override stuff for production, but in python, we currently don't allow that?
There was a problem hiding this comment.
exactly, i tried to make it work well for python but don't think there's a clean way
| thread_local! { | ||
| static OVERRIDES: RefCell<HashMap<String, HashMap<String, Value>>> = RefCell::new(HashMap::new()); | ||
| } |
There was a problem hiding this comment.
perhaps im just lost but is there not a way to use the same OVERRIDES object thats found in rust/src/lib because this library is a wrapper over that anyways?
There was a problem hiding this comment.
it cannot, since that is only compiled with the testing feature
There was a problem hiding this comment.
although, now that i am thinking about it wonder if they both should just be consistent lol
| impl NamespaceOptions { | ||
| /// Get an option value, returning the schema default if not set. | ||
| fn get(&self, py: Python<'_>, key: &str) -> PyResult<Py<PyAny>> { | ||
| if let Some(value) = get_override(&self.namespace, key) { |
There was a problem hiding this comment.
i think i understand, so in the rust version, we can compile without the get override stuff for production, but in python, we currently don't allow that?
…ging After the module restructuring in #50, maturin stopped inferring the ABI3 minimum from requires-python and fell back to cp38. Explicitly passing pyo3/abi3-py311 ensures wheels are tagged abi3-cp311. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
No description provided.