Commit 3e3c1b9
committed
Fix ImportError in analyzer tests
This commit fixes an `ImportError: attempted relative import beyond top-level package` that occurred when running tests in `examples/google-ads-account-analyzer-demo/tests/test_analyzer.py` using standard test discovery.
The import mechanism for the `analyzer` module within `test_analyzer.py` has been made more robust by dynamically adding the parent directory (`examples/google-ads-account-analyzer-demo`) to `sys.path` before attempting the import. This ensures that the `analyzer` module can be correctly located regardless of how the tests are invoked (e.g., direct execution, `unittest discover`).
The changes ensure that tests can be reliably run from the repository root using commands like `python -m unittest discover -s examples/google-ads-account-analyzer-demo/tests -p test_analyzer.py`.1 parent b6aa2c9 commit 3e3c1b9
File tree
1 file changed
+35
-3
lines changed- examples/google-ads-account-analyzer-demo/tests
1 file changed
+35
-3
lines changedLines changed: 35 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
3 | 37 | | |
4 | | - | |
5 | | - | |
6 | 38 | | |
7 | 39 | | |
8 | 40 | | |
| |||
0 commit comments