-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates cli calls to exit more gracefully, and added coverage tests for cli
- Loading branch information
Showing
6 changed files
with
411 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,60 @@ | ||
#import time | ||
#from pybci.CliTests.testSimple import main as mainSimple | ||
#from pybci.CliTests.testSklearn import main as mainSklearn | ||
#from pybci.CliTests.testPyTorch import main as mainPyTorch | ||
#from pybci.CliTests.testTensorflow import main as mainTensorflow | ||
|
||
import threading | ||
from pybci.CliTests.testSimple import main as mainSimple | ||
from pybci.CliTests.testSklearn import main as mainSklearn | ||
from pybci.CliTests.testPyTorch import main as mainPyTorch | ||
from pybci.CliTests.testTensorflow import main as mainTensorflow | ||
from unittest.mock import patch | ||
|
||
# Example usage | ||
def test_cli(): | ||
#mainSimple(min_epochs_train=1, min_epochs_test=2, timeout=10) | ||
#time.sleep(15) | ||
#m#ainSklearn(min_epochs_train=1, min_epochs_test=2, timeout=10) | ||
#time.sleep(15) | ||
#mainPyTorch(min_epochs_train=1, min_epochs_test=2, timeout=10) | ||
#time.sleep(15) | ||
#mainTensorflow(min_epochs_train=1, min_epochs_test=2, timeout=10) | ||
#time.sleep(15) | ||
assert True | ||
|
||
#def test_cli(): | ||
def test_cli_simple_timeout(): | ||
with patch('builtins.input', return_value='stop'): | ||
timeout = 30 # timeout in seconds | ||
my_bci_wrapper = None | ||
|
||
def run_main(): | ||
nonlocal my_bci_wrapper | ||
my_bci_wrapper = mainSimple(createPseudoDevice=True, min_epochs_train=1, min_epochs_test=2, timeout=timeout) | ||
|
||
main_thread = threading.Thread(target=run_main) | ||
main_thread.start() | ||
main_thread.join() | ||
|
||
def test_cli_sklearn_timeout(): | ||
with patch('builtins.input', return_value='stop'): | ||
timeout = 30 # timeout in seconds | ||
my_bci_wrapper = None | ||
|
||
def run_main(): | ||
nonlocal my_bci_wrapper | ||
my_bci_wrapper = mainSklearn(createPseudoDevice=True, min_epochs_train=1, min_epochs_test=2, timeout=timeout) | ||
|
||
main_thread = threading.Thread(target=run_main) | ||
main_thread.start() | ||
main_thread.join() | ||
|
||
def test_cli_pytorch_timeout(): | ||
with patch('builtins.input', return_value='stop'): | ||
timeout = 30 # timeout in seconds | ||
my_bci_wrapper = None | ||
|
||
def run_main(): | ||
nonlocal my_bci_wrapper | ||
my_bci_wrapper = mainPyTorch(createPseudoDevice=True, min_epochs_train=1, min_epochs_test=2, timeout=timeout) | ||
|
||
main_thread = threading.Thread(target=run_main) | ||
main_thread.start() | ||
main_thread.join() | ||
|
||
def test_cli_tensorflow_timeout(): | ||
with patch('builtins.input', return_value='stop'): | ||
timeout = 30 # timeout in seconds | ||
my_bci_wrapper = None | ||
|
||
def run_main(): | ||
nonlocal my_bci_wrapper | ||
my_bci_wrapper = mainTensorflow(createPseudoDevice=True, min_epochs_train=1, min_epochs_test=2, timeout=timeout) | ||
|
||
main_thread = threading.Thread(target=run_main) | ||
main_thread.start() | ||
main_thread.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.