File diff e07a47ec8f8b → 32b62df5405f
tests/test_cliutil.py
Show inline comments
...
 
@@ -24,12 +24,17 @@ import re
 
import traceback
 

	
 
import pytest
 

	
 
from conservancy_beancount import cliutil
 

	
 
class AlwaysEqual:
 
    def __eq__(self, other):
 
        return True
 

	
 

	
 
class MockTraceback:
 
    def __init__(self, stack=None, index=0):
 
        if stack is None:
 
            stack = inspect.stack(context=False)
 
        self._stack = stack
 
        self._index = index
...
 
@@ -88,14 +93,18 @@ def test_excepthook_traceback(caplog):
 
    caplog.set_level(logging.DEBUG)
 
    with pytest.raises(SystemExit) as exc_check:
 
        cliutil.ExceptHook()(*args)
 
    assert caplog.records
 
    assert caplog.records[-1].message == ''.join(traceback.format_exception(*args))
 

	
 
def test_is_main_script():
 
    assert not cliutil.is_main_script()
 
@pytest.mark.parametrize('prog_name,expected', [
 
    ('', False),
 
    (AlwaysEqual(), True),
 
])
 
def test_is_main_script(prog_name, expected):
 
    assert cliutil.is_main_script(prog_name) == expected
 

	
 
@pytest.mark.parametrize('arg,expected', [
 
    ('debug', logging.DEBUG),
 
    ('info', logging.INFO),
 
    ('warning', logging.WARNING),
 
    ('warn', logging.WARNING),