Skip to content

Commit 8e6df7b

Browse files
ticosaxSaurabh Kumar
authored andcommitted
Fix dotenv list command
- Compute test coverage only if tests succeeds - Add changelog Thanks @ticosax closes theskumar#41
1 parent 2f82454 commit 8e6df7b

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ install:
1212
- pip install --editable .
1313
script:
1414
- pytest -v --tb=native --cov --flake8
15-
after_script:
15+
after_success:
1616
- coveralls
1717
deploy:
1818
provider: pypi

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ Changelog
246246

247247
dev
248248
----------
249+
- Fix `dotenv list` command (@ticosax)
249250
- Add iPython Suport (@tillahoffmann)
250251

251252
0.6.0
@@ -268,6 +269,7 @@ dev
268269
- cli: Added ``-q/--quote`` option to control the behaviour of quotes around values in ``.env``. (Thanks `@hugochinchilla`_).
269270
- Improved test coverage.
270271

272+
.. _@ticosax: https://github.com/ticosax
271273
.. _@tillahoffmann: https://github.com/tillahoffmann
272274
.. _@hugochinchilla: https://github.com/hugochinchilla
273275
.. _@isms: https://github.com/isms

dotenv/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def list(ctx):
2626
'''Display all the stored key/value.'''
2727
file = ctx.obj['FILE']
2828
dotenv_as_dict = dotenv_values(file)
29-
for k, v in dotenv_as_dict:
29+
for k, v in dotenv_as_dict.items():
3030
click.echo('%s="%s"' % (k, v))
3131

3232

tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1+
import pytest
2+
13
from .fixtures import * # noqa
4+
5+
6+
@pytest.fixture
7+
def dotenv_file(tmpdir):
8+
file_ = tmpdir.mkdir('dotenv_file').join('.env')
9+
file_.write('')
10+
return str(file_)

tests/test_cli.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
3-
42
from os import environ
53
from os.path import dirname, join
64

@@ -23,6 +21,19 @@ def test_get_key():
2321
assert success is None
2422

2523

24+
def test_list(cli, dotenv_file):
25+
success, key_to_set, value_to_set = dotenv.set_key(dotenv_file, 'HELLO', 'WORLD')
26+
result = cli.invoke(dotenv.cli.cli, ['--file', dotenv_file, 'list'])
27+
assert result.exit_code == 0, result.output
28+
assert result.output == 'HELLO="WORLD"\n'
29+
30+
31+
def test_list_wo_file(cli):
32+
result = cli.invoke(dotenv.cli.cli, ['--file', 'doesnotexists', 'list'])
33+
assert result.exit_code == 2, result.output
34+
assert 'Invalid value for "-f"' in result.output
35+
36+
2637
def test_key_value_without_quotes():
2738
with open(dotenv_path, 'w') as f:
2839
f.write("TEST = value \n")

0 commit comments

Comments
 (0)