The name guesser walks up the frames until it reaches a frame whose name is not from structlog or one of the configurable other names.
(self)
| 92 | assert "tests.test_stdlib" == LoggerFactory()().name |
| 93 | |
| 94 | def test_ignores_frames(self): |
| 95 | """ |
| 96 | The name guesser walks up the frames until it reaches a frame whose |
| 97 | name is not from structlog or one of the configurable other names. |
| 98 | """ |
| 99 | |
| 100 | # Compute the names to __main__ so it doesn't get thrown off if people |
| 101 | # install plugins that alter the frames. E.g. #370 |
| 102 | names = set() |
| 103 | f = sys._getframe() |
| 104 | while f.f_globals["__name__"] != "__main__": |
| 105 | names.add(f.f_globals["__name__"].split(".", 1)[0]) |
| 106 | f = f.f_back |
| 107 | |
| 108 | assert ( |
| 109 | "__main__" |
| 110 | == additional_frame( |
| 111 | LoggerFactory(ignore_frame_names=list(names)) |
| 112 | ).name |
| 113 | ) |
| 114 | |
| 115 | def test_deduces_correct_caller(self): |
| 116 | """ |
nothing calls this directly
no test coverage detected