Skip to content

Commit 3576225

Browse files
committed
Test without typing
The dependency on the `typing` package is now optional for Python 3.4. This commit runs (part of) the test suite in when that package is absent, to make sure the dependency isn't reintroduced accidentally.
1 parent d93324a commit 3576225

5 files changed

Lines changed: 13 additions & 5 deletions

File tree

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ matrix:
1414
env: TOXENV=py27
1515
- python: "3.4"
1616
env: TOXENV=py34
17+
- python: "3.4"
18+
env: TOXENV=py34-no-typing
1719
- python: "3.5"
1820
env: TOXENV=py35
1921
- python: "3.6"

src/dotenv/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def is_type_checking():
1212
# type: () -> bool
1313
try:
1414
from typing import TYPE_CHECKING
15-
except ImportError: # pragma: no cover
15+
except ImportError:
1616
return False
1717
return TYPE_CHECKING
1818

src/dotenv/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def make_regex(string, extra_flags=0):
3939
Binding = typing.NamedTuple("Binding", [("key", typing.Optional[typing.Text]),
4040
("value", typing.Optional[typing.Text]),
4141
("original", typing.Text)])
42-
except ImportError: # pragma: no cover
42+
except ImportError:
4343
from collections import namedtuple
4444
Binding = namedtuple("Binding", ["key", # type: ignore
4545
"value",

tests/test_core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import pytest
1111
import sh
12-
from IPython.terminal.embed import InteractiveShellEmbed
1312

1413
from dotenv import dotenv_values, find_dotenv, load_dotenv, set_key
1514
from dotenv.compat import PY2, StringIO
@@ -117,6 +116,7 @@ def test_load_dotenv_in_current_dir(tmp_path):
117116

118117

119118
def test_ipython(tmp_path):
119+
from IPython.terminal.embed import InteractiveShellEmbed
120120
os.chdir(str(tmp_path))
121121
dotenv_file = tmp_path / '.env'
122122
dotenv_file.write_text("MYNEWVALUE=q1w2e3\n")
@@ -127,6 +127,7 @@ def test_ipython(tmp_path):
127127

128128

129129
def test_ipython_override(tmp_path):
130+
from IPython.terminal.embed import InteractiveShellEmbed
130131
os.chdir(str(tmp_path))
131132
dotenv_file = tmp_path / '.env'
132133
os.environ["MYNEWVALUE"] = "OVERRIDE"

tox.ini

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = lint,py{27,34,35,36,37},pypy,pypy3,manifest,coverage-report
2+
envlist = lint,py{27,34,35,36,37,34-no-typing},pypy,pypy3,manifest,coverage-report
33

44
[testenv]
55
deps =
@@ -8,10 +8,15 @@ deps =
88
sh
99
click
1010
py{27,py}: ipython<6.0.0
11-
py34: ipython<7.0.0
11+
py34{,-no-typing}: ipython<7.0.0
1212
py{35,36,37,py3}: ipython
1313
commands = coverage run --parallel -m pytest {posargs}
1414

15+
[testenv:py34-no-typing]
16+
commands =
17+
pip uninstall --yes typing
18+
coverage run --parallel -m pytest -k 'not test_ipython' {posargs}
19+
1520
[testenv:lint]
1621
skip_install = true
1722
deps =

0 commit comments

Comments
 (0)