Fix unit test borkage due to loading from /dls_sw#867
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #867 +/- ##
==========================================
+ Coverage 95.52% 95.54% +0.01%
==========================================
Files 125 125
Lines 5343 5343
==========================================
+ Hits 5104 5105 +1
+ Misses 239 238 -1 ☔ View full report in Codecov by Sentry. |
| "i24": mock_paths, | ||
| } | ||
|
|
||
| BANNED_PATHS = [Path("/dls"), Path("/dls_sw")] |
There was a problem hiding this comment.
Can we just ban absolute paths altogether? /dev/null we can still get with os.devnull, otherwise everything should be included with the module
There was a problem hiding this comment.
I didn't want to exclude /tmp as there are lots of things that write to the tmp directory. As it's a patch on the open builtin I didn't want to be too overreaching in case some dependency of ours tries to do something reasonable.
I think this will catch 99% of things, I don't know what other directories we are likely to be touching ourselves.
DominicOram
left a comment
There was a problem hiding this comment.
I'm not really sure why we need this? The unit tests should fail in CI if we're doing this accidentally anyway or are we just trying to be extra cautious in catching things locally?
In theory, yes CI should catch it, however it can be difficult to debug where things are going wrong if it only happens in CI, especially if you don't get all the exception info. We do already have this in mx-bluesky where I introduced it a while back. |
DominicOram
left a comment
There was a problem hiding this comment.
I don't think I personally find it useful to have this locally but I have no strong objection to it if it helps others so all good :)
74a344a to
54c9f54
Compare
Prevents unit tests loading files from places where they shouldn't, this is a port from code that's already in the mx-bluesky unit tests.
Instructions to reviewer on how to test:
BANNED_PATHSinside a unit test will result in an exception (at least inside those files that are in submodules of where the affectedconftest.pymodule is.Checks for reviewer
dodal connect ${BEAMLINE}