(self)
| 553 | |
| 554 | @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") |
| 555 | def test_log_collisions(self): |
| 556 | app = MyApp() |
| 557 | app.log = logging.getLogger() |
| 558 | app.log.setLevel(logging.INFO) |
| 559 | name = "config" |
| 560 | with TemporaryDirectory("_1") as td: |
| 561 | with open(pjoin(td, name + ".py"), "w") as f: |
| 562 | f.write("get_config().Bar.b = 1") |
| 563 | with open(pjoin(td, name + ".json"), "w") as f: |
| 564 | json.dump({"Bar": {"b": 2}}, f) |
| 565 | with self.assertLogs(app.log, logging.WARNING) as captured: |
| 566 | app.load_config_file(name, path=[td]) |
| 567 | app.init_bar() |
| 568 | assert app.bar.b == 2 |
| 569 | output = "\n".join(captured.output) |
| 570 | assert "Collision" in output |
| 571 | assert "1 ignored, using 2" in output |
| 572 | assert pjoin(td, name + ".py") in output |
| 573 | assert pjoin(td, name + ".json") in output |
| 574 | |
| 575 | @pytest.mark.skipif(not hasattr(TestCase, "assertLogs"), reason="requires TestCase.assertLogs") |
| 576 | def test_log_bad_config(self): |
nothing calls this directly
no test coverage detected