def test_option_requires(): some_option = 'something' unset_option = None set_option = '와 짠이다' option_requires( option='--some-option', requires_all=['--set_option'], scope=locals() ) option_requires( option='--some-option', requires_any=[ '--set_option', '--unset-option'], scope=locals() ) with pytest.raises(UsageError): option_requires( option='--some-option', requires_all=[ '--set-option', '--unset-option'], scope=locals() ) with pytest.raises(UsageError): option_requires( option='--some-option', requires_any=[ '--unset-option'], scope=locals() )
def test_option_requires_conditional_value(): unset_option = None set_option = '대박' some_option = 'magic' option_requires(option='--some-option', conditional_value='magic', requires_any=['--set-option', '--unset-option'], scope=locals()) some_option = 'not magic' option_requires(option='--some-option', conditional_value='magic', requires_any=['--unset-option'], scope=locals()) some_option = '' option_requires(option='--some-option', conditional_value='', requires_any=['--unset-option'], scope=locals()) with pytest.raises(UsageError): some_option = 'magic' option_requires(option='--some-option', conditional_value='magic', requires_any=['--unset-option'], scope=locals())
def test_option_requires_conditional_value(): with pytest.raises(Exception): option_requires( option='--some-option', conditional_value='magic', requires_any=[ '--set_option', '--unset-option'], scope=locals() ) some_option = 'not magic' option_requires( option='--some-option', conditional_value='magic', requires_any=[ '--set_option', '--unset-option'], scope=locals() ) some_option = 'magic' with pytest.raises(UsageError): option_requires( option='--some-option', conditional_value='magic', requires_any=[ '--set_option', '--unset-option'], scope=locals() ) some_option = '' with pytest.raises(UsageError): option_requires( option='--some-option', conditional_value='', requires_any=[ '--set_option', '--unset-option'], scope=locals() )