-
Notifications
You must be signed in to change notification settings - Fork 85
/
test_logging.py
33 lines (26 loc) · 995 Bytes
/
test_logging.py
1
2
3
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
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
"""Tests the logging mechanism in the library"""
import os
INTERPRET_C_LOGS = 'INTERPRET_C_LOGS'
def test_import_tabular():
not_existing_dir = 'not_existing_dir'
not_existing_path = os.path.join(not_existing_dir, 'interpret_community_log.txt')
if os.path.exists(not_existing_path):
os.remove(not_existing_path)
os.rmdir(not_existing_dir)
os.environ[INTERPRET_C_LOGS] = not_existing_path
import importlib
import interpret_community
importlib.reload(interpret_community)
assert os.path.exists(not_existing_path)
del os.environ[INTERPRET_C_LOGS]
importlib.reload(interpret_community)
import logging
importlib.reload(logging)
try:
os.remove(not_existing_path)
os.rmdir(not_existing_dir)
except PermissionError:
pass