Skip to content

Commit

Permalink
Test added
Browse files Browse the repository at this point in the history
  • Loading branch information
andfoy committed Jul 28, 2017
1 parent 269320b commit ca9f751
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions spyder_terminal/tests/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
TERM_UP = 10000
WINDOWS = os.name == 'nt'

EXIT = 'exit'
CLEAR = 'clear'
if WINDOWS:
CLEAR = 'cls'
Expand All @@ -36,6 +37,7 @@
PWD = 'cd'



def check_pwd(termwidget):
"""Check if pwd command is executed."""
if WEBENGINE:
Expand Down Expand Up @@ -81,8 +83,9 @@ def test_terminal_tab_title(qtbot):
terminal = setup_terminal(qtbot)
qtbot.wait(TERM_UP)
terminal.create_new_term()
num_1 = int(terminal.tabwidget.tabText(0)[-1])
num_2 = int(terminal.tabwidget.tabText(1)[-1])
terminal.create_new_term()
num_1 = int(terminal.tabwidget.tabText(1)[-1])
num_2 = int(terminal.tabwidget.tabText(2)[-1])
assert num_2 == num_1 + 1
terminal.closing_plugin()

Expand Down Expand Up @@ -131,3 +134,25 @@ def test_output_redirection(qtbot):
stderr = osp.join(getcwd(), 'spyder_terminal_err.log')
assert osp.exists(stdout) and osp.exists(stderr)
terminal.closing_plugin()


def test_close_terminal_manually(qtbot):
# Setup widget
terminal = setup_terminal(qtbot)
qtbot.wait(TERM_UP)

# Test if server is running
port = terminal.port
status_code = requests.get('http://127.0.0.1:{}'.format(port)).status_code
assert status_code == 200

terminal.create_new_term()
initial_num = terminal.tabwidget.count()
term = terminal.get_current_term()
qtbot.wait(1000)

term.exec_cmd(EXIT)
qtbot.wait(1000)

final_num = terminal.tabwidget.count()
assert final_num == initial_num - 1

0 comments on commit ca9f751

Please sign in to comment.