|
1 | 1 | import json |
2 | | -import logging |
3 | 2 | import os |
4 | 3 | import pytest |
5 | 4 | import string |
6 | 5 | import time_machine |
7 | | -from contextlib import contextmanager |
8 | 6 | from os import getcwd, path, remove |
9 | 7 | from pathlib import Path |
10 | 8 | from shutil import rmtree |
@@ -35,15 +33,6 @@ def runner() -> CliRunner: |
35 | 33 | return CliRunner(env={"COLUMNS": "80"}) |
36 | 34 |
|
37 | 35 |
|
38 | | -@contextmanager |
39 | | -def disable_logging(): |
40 | | - logging.disable(logging.CRITICAL) |
41 | | - try: |
42 | | - yield |
43 | | - finally: |
44 | | - logging.disable(logging.NOTSET) |
45 | | - |
46 | | - |
47 | 36 | def create_example_project(temp_dir, template=ProjectTemplate.DEFAULT) -> None: |
48 | 37 | """ |
49 | 38 | Sets up CLI tests requiring a real SQLMesh project by: |
@@ -795,8 +784,7 @@ def test_run_cron_not_elapsed(runner, tmp_path, caplog): |
795 | 784 | init_prod_and_backfill(runner, tmp_path) |
796 | 785 |
|
797 | 786 | # No error if `prod` environment exists and cron has not elapsed |
798 | | - with disable_logging(): |
799 | | - result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "run"]) |
| 787 | + result = runner.invoke(cli, ["--log-file-dir", tmp_path, "--paths", tmp_path, "run"]) |
800 | 788 | assert result.exit_code == 0 |
801 | 789 |
|
802 | 790 | assert ( |
@@ -843,18 +831,17 @@ def test_table_name(runner, tmp_path): |
843 | 831 | # Create and backfill `prod` environment |
844 | 832 | create_example_project(tmp_path) |
845 | 833 | init_prod_and_backfill(runner, tmp_path) |
846 | | - with disable_logging(): |
847 | | - result = runner.invoke( |
848 | | - cli, |
849 | | - [ |
850 | | - "--log-file-dir", |
851 | | - tmp_path, |
852 | | - "--paths", |
853 | | - tmp_path, |
854 | | - "table_name", |
855 | | - "sqlmesh_example.full_model", |
856 | | - ], |
857 | | - ) |
| 834 | + result = runner.invoke( |
| 835 | + cli, |
| 836 | + [ |
| 837 | + "--log-file-dir", |
| 838 | + tmp_path, |
| 839 | + "--paths", |
| 840 | + tmp_path, |
| 841 | + "table_name", |
| 842 | + "sqlmesh_example.full_model", |
| 843 | + ], |
| 844 | + ) |
858 | 845 | assert result.exit_code == 0 |
859 | 846 | assert result.output.startswith("db.sqlmesh__sqlmesh_example.sqlmesh_example__full_model__") |
860 | 847 |
|
|
0 commit comments