Skip to content

Commit d976fbd

Browse files
authored
Fix behave tests on master. (dbcli#904)
* Possibly fix behave tests on master. * Run behave with --no-capture.
1 parent 17f093d commit d976fbd

File tree

7 files changed

+12
-16
lines changed

7 files changed

+12
-16
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ matrix:
1212

1313
install:
1414
- pip install -r requirements-dev.txt
15-
- pip install -e .
15+
- pip install --no-cache-dir -e .
1616
- sudo rm -f /etc/mysql/conf.d/performance-schema.cnf
1717
- sudo service mysql restart
1818

mycli/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(self, sqlexecute=None, prompt=None,
152152
c['main'].as_bool('auto_vertical_output')
153153

154154
# Write user config if system config wasn't the last config loaded.
155-
if c.filename not in self.system_config_files:
155+
if c.filename not in self.system_config_files and not os.path.exists(myclirc):
156156
write_default_config(self.default_config_file, myclirc)
157157

158158
# audit log

requirements-dev.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ pytest!=3.3.0
33
pytest-cov==2.4.0
44
tox
55
twine==1.12.1
6-
behave
7-
pexpect
6+
behave>=1.2.4
7+
pexpect==3.3
88
coverage==5.0.4
99
codecov==2.0.9
1010
autopep8==1.3.3

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class test(TestCommand):
6565
def initialize_options(self):
6666
TestCommand.initialize_options(self)
6767
self.pytest_args = ''
68-
self.behave_args = ''
68+
self.behave_args = '--no-capture'
6969

7070
def run_tests(self):
7171
unit_test_errno = subprocess.call(

test/features/environment.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def before_all(context):
1616
os.environ['LINES'] = "100"
1717
os.environ['COLUMNS'] = "100"
1818
os.environ['EDITOR'] = 'ex'
19-
os.environ['LC_ALL'] = 'en_US.utf8'
19+
os.environ['LC_ALL'] = 'en_US.UTF-8'
2020
os.environ['PROMPT_TOOLKIT_NO_CPR'] = '1'
2121

2222
test_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@@ -118,11 +118,12 @@ def after_scenario(context, _):
118118
host = context.conf['host']
119119
dbname = context.currentdb
120120
context.cli.expect_exact(
121-
'{0}@{1}:{2}> '.format(
121+
'{0}@{1}:{2}>'.format(
122122
user, host, dbname
123123
),
124124
timeout=5
125125
)
126+
context.cli.sendcontrol('c')
126127
context.cli.sendcontrol('d')
127128
context.cli.expect_exact(pexpect.EOF, timeout=5)
128129

test/features/steps/crud_database.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,13 @@ def step_see_prompt(context):
6464
user = context.conf['user']
6565
host = context.conf['host']
6666
dbname = context.currentdb
67-
wrappers.expect_exact(context, '{0}@{1}:{2}> '.format(
68-
user, host, dbname), timeout=5)
69-
context.atprompt = True
67+
wrappers.wait_prompt(context, '{0}@{1}:{2}> '.format(user, host, dbname))
7068

7169

7270
@then('we see help output')
7371
def step_see_help(context):
7472
for expected_line in context.fixture_data['help_commands.txt']:
75-
wrappers.expect_exact(context, expected_line + '\r\n', timeout=1)
73+
wrappers.expect_exact(context, expected_line, timeout=1)
7674

7775

7876
@then('we see database created')
@@ -96,10 +94,7 @@ def step_see_db_dropped_no_default(context):
9694
context.currentdb = None
9795

9896
wrappers.expect_exact(context, 'Query OK, 0 rows affected', timeout=2)
99-
wrappers.expect_exact(context, '{0}@{1}:{2}> '.format(
100-
user, host, database), timeout=5)
101-
102-
context.atprompt = True
97+
wrappers.wait_prompt(context, '{0}@{1}:{2}>'.format(user, host, database))
10398

10499

105100
@then('we see database connected')

test/features/steps/wrappers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def wait_prompt(context, prompt=None):
8888
user = context.conf['user']
8989
host = context.conf['host']
9090
dbname = context.currentdb
91-
prompt = '{0}@{1}:{2}> '.format(
91+
prompt = '{0}@{1}:{2}>'.format(
9292
user, host, dbname),
9393
expect_exact(context, prompt, timeout=5)
9494
context.atprompt = True

0 commit comments

Comments
 (0)