merged command line and gui app in one command

This commit is contained in:
Thomas Peetz
2025-01-14 13:10:24 +01:00
parent f74c07af9a
commit 276302570f
69 changed files with 589 additions and 183 deletions
+16
View File
@@ -0,0 +1,16 @@
"""
PyTest Fixtures.
"""
import pytest
from cement import fs
@pytest.fixture(scope="function")
def tmp(request):
"""
Create a `tmp` object that geneates a unique temporary directory, and file
for each test function that requires it.
"""
t = fs.Tmp()
yield t
t.remove()
+36
View File
@@ -0,0 +1,36 @@
from pytest import raises
from kontor.main import KontorTest
def test_kontor():
# test kontor without any subcommands or arguments
with KontorTest() as app:
app.run()
assert app.exit_code == 0
def test_kontor_debug():
# test that debug mode is functional
argv = ['--debug']
with KontorTest(argv=argv) as app:
app.run()
assert app.debug is True
def test_command1():
# test command1 without arguments
argv = ['command1']
with KontorTest(argv=argv) as app:
app.run()
data,output = app.last_rendered
assert data['foo'] == 'bar'
assert output.find('Foo => bar')
# test command1 with arguments
argv = ['command1', '--foo', 'not-bar']
with KontorTest(argv=argv) as app:
app.run()
data,output = app.last_rendered
assert data['foo'] == 'not-bar'
assert output.find('Foo => not-bar')