|
| 1 | +--- a/tests/unit/test_logger.py |
| 2 | ++++ b/tests/unit/test_logger.py |
| 3 | +@@ -699,7 +699,7 @@ |
| 4 | + ) |
| 5 | + |
| 6 | + |
| 7 | +-def test_configure_logging_to_log_file_instead_of_syslog(): |
| 8 | ++def test_configure_logging_to_log_file_instead_of_syslog(tmp_path): |
| 9 | + flexmock(module).should_receive('add_custom_log_levels') |
| 10 | + flexmock(module.logging).ANSWER = module.ANSWER |
| 11 | + fake_formatter = flexmock() |
| 12 | +@@ -716,20 +716,21 @@ |
| 13 | + ) |
| 14 | + flexmock(module.os.path).should_receive('exists').never() |
| 15 | + flexmock(module.logging.handlers).should_receive('SysLogHandler').never() |
| 16 | +- file_handler = logging.handlers.WatchedFileHandler('/tmp/logfile') |
| 17 | ++ log_file = str(tmp_path / 'logfile') |
| 18 | ++ file_handler = logging.handlers.WatchedFileHandler(log_file) |
| 19 | + flexmock(module.logging.handlers).should_receive('WatchedFileHandler').with_args( |
| 20 | +- '/tmp/logfile', |
| 21 | ++ log_file, |
| 22 | + ).and_return(file_handler).once() |
| 23 | + |
| 24 | + module.configure_logging( |
| 25 | + console_log_level=logging.INFO, |
| 26 | + syslog_log_level=logging.DISABLED, |
| 27 | + log_file_log_level=logging.DEBUG, |
| 28 | +- log_file='/tmp/logfile', |
| 29 | ++ log_file=log_file, |
| 30 | + ) |
| 31 | + |
| 32 | + |
| 33 | +-def test_configure_logging_to_both_log_file_and_syslog(): |
| 34 | ++def test_configure_logging_to_both_log_file_and_syslog(tmp_path): |
| 35 | + flexmock(module).should_receive('add_custom_log_levels') |
| 36 | + flexmock(module.logging).ANSWER = module.ANSWER |
| 37 | + fake_formatter = flexmock() |
| 38 | +@@ -752,20 +753,21 @@ |
| 39 | + flexmock(module.logging.handlers).should_receive('SysLogHandler').with_args( |
| 40 | + address='/dev/log', |
| 41 | + ).and_return(syslog_handler).once() |
| 42 | +- file_handler = logging.handlers.WatchedFileHandler('/tmp/logfile') |
| 43 | ++ log_file = str(tmp_path / 'logfile') |
| 44 | ++ file_handler = logging.handlers.WatchedFileHandler(log_file) |
| 45 | + flexmock(module.logging.handlers).should_receive('WatchedFileHandler').with_args( |
| 46 | +- '/tmp/logfile', |
| 47 | ++ log_file, |
| 48 | + ).and_return(file_handler).once() |
| 49 | + |
| 50 | + module.configure_logging( |
| 51 | + console_log_level=logging.INFO, |
| 52 | + syslog_log_level=logging.DEBUG, |
| 53 | + log_file_log_level=logging.DEBUG, |
| 54 | +- log_file='/tmp/logfile', |
| 55 | ++ log_file=log_file, |
| 56 | + ) |
| 57 | + |
| 58 | + |
| 59 | +-def test_configure_logging_to_log_file_formats_with_custom_log_format(): |
| 60 | ++def test_configure_logging_to_log_file_formats_with_custom_log_format(tmp_path): |
| 61 | + flexmock(module).should_receive('add_custom_log_levels') |
| 62 | + flexmock(module.logging).ANSWER = module.ANSWER |
| 63 | + flexmock(module).should_receive('Log_prefix_formatter').with_args( |
| 64 | +@@ -786,15 +788,16 @@ |
| 65 | + ) |
| 66 | + flexmock(module.os.path).should_receive('exists').with_args('/dev/log').and_return(True) |
| 67 | + flexmock(module.logging.handlers).should_receive('SysLogHandler').never() |
| 68 | +- file_handler = logging.handlers.WatchedFileHandler('/tmp/logfile') |
| 69 | ++ log_file = str(tmp_path / 'logfile') |
| 70 | ++ file_handler = logging.handlers.WatchedFileHandler(log_file) |
| 71 | + flexmock(module.logging.handlers).should_receive('WatchedFileHandler').with_args( |
| 72 | +- '/tmp/logfile', |
| 73 | ++ log_file, |
| 74 | + ).and_return(file_handler).once() |
| 75 | + |
| 76 | + module.configure_logging( |
| 77 | + console_log_level=logging.INFO, |
| 78 | + log_file_log_level=logging.DEBUG, |
| 79 | +- log_file='/tmp/logfile', |
| 80 | ++ log_file=log_file, |
| 81 | + log_file_format='{message}', |
| 82 | + ) |
| 83 | + |
| 84 | +--- a/tests/integration/config/test_generate.py |
| 85 | ++++ b/tests/integration/config/test_generate.py |
| 86 | +@@ -315,10 +315,10 @@ |
| 87 | + module.write_configuration('config.yaml', 'config: yaml') |
| 88 | + |
| 89 | + |
| 90 | +-def test_write_configuration_with_already_existing_file_and_overwrite_does_not_raise(): |
| 91 | ++def test_write_configuration_with_already_existing_file_and_overwrite_does_not_raise(tmp_path): |
| 92 | + flexmock(os.path).should_receive('exists').and_return(True) |
| 93 | + |
| 94 | +- module.write_configuration('/tmp/config.yaml', 'config: yaml', overwrite=True) |
| 95 | ++ module.write_configuration(str(tmp_path / 'config.yaml'), 'config: yaml', overwrite=True) |
| 96 | + |
| 97 | + |
| 98 | + def test_write_configuration_with_already_existing_directory_does_not_raise(): |
| 99 | +--- a/tests/integration/config/test_validate.py |
| 100 | ++++ b/tests/integration/config/test_validate.py |
| 101 | +@@ -222,11 +222,11 @@ |
| 102 | + assert logs == [] |
| 103 | + |
| 104 | + |
| 105 | +-def test_parse_configuration_raises_for_missing_config_file(): |
| 106 | ++def test_parse_configuration_raises_for_missing_config_file(tmp_path): |
| 107 | + with pytest.raises(FileNotFoundError): |
| 108 | + module.parse_configuration( |
| 109 | +- '/tmp/config.yaml', |
| 110 | +- '/tmp/schema.yaml', |
| 111 | ++ str(tmp_path / 'nonexistent' / 'config.yaml'), |
| 112 | ++ str(tmp_path / 'nonexistent' / 'schema.yaml'), |
| 113 | + arguments={'global': flexmock()}, |
| 114 | + ) |
| 115 | + |
0 commit comments