25 lines
808 B
Python
25 lines
808 B
Python
import os
|
|
import sys
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
|
import pytest
|
|
from unittest.mock import patch
|
|
import gui
|
|
|
|
def test_hooks_enabled_via_cli():
|
|
with patch.object(sys, 'argv', ['gui.py', '--enable-test-hooks']):
|
|
app = gui.App()
|
|
assert app.test_hooks_enabled is True
|
|
|
|
def test_hooks_disabled_by_default():
|
|
with patch.object(sys, 'argv', ['gui.py']):
|
|
if 'SLOP_TEST_HOOKS' in os.environ:
|
|
del os.environ['SLOP_TEST_HOOKS']
|
|
app = gui.App()
|
|
assert getattr(app, 'test_hooks_enabled', False) is False
|
|
|
|
def test_hooks_enabled_via_env():
|
|
with patch.object(sys, 'argv', ['gui.py']):
|
|
with patch.dict(os.environ, {'SLOP_TEST_HOOKS': '1'}):
|
|
app = gui.App()
|
|
assert app.test_hooks_enabled is True
|