MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / TestDynamicImport

Class TestDynamicImport

tests/unit/test_false_positive_reductions.py:276–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274# ===========================================================================
275
276class TestDynamicImport:
277 def test_import_in_tests_not_flagged(self):
278 """__import__() used in test discovery should not be flagged."""
279 code = """
280 backend_pkg = __import__(package)
281 test_module = __import__(test_module_name, {}, {}, test_path[-1])
282 """
283 assert findings_for_rule(code, "IMPORT825", in_tests_dir=True) == [], \
284 "IMPORT825 should not fire in test files"
285
286 def test_import_in_production_flagged(self):
287 """__import__() in production code should still be flagged."""
288 code = """
289 module = __import__(user_provided_module_name)
290 """
291 assert findings_for_rule(code, "IMPORT825", in_tests_dir=False) != [], \
292 "IMPORT825 should still fire in production code"
293
294
295# ===========================================================================

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected