forked from nameko/nameko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix
nameko test
command (nameko#750)
- Loading branch information
1 parent
02ba742
commit 727c4fa
Showing
2 changed files
with
66 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import subprocess | ||
from textwrap import dedent | ||
|
||
import pytest | ||
|
||
|
||
def test_test_pass(tmpdir, capsys): | ||
|
||
tmpdir.join('__init__.py') | ||
testfile = tmpdir.join('test_test_pass.py') | ||
testfile.write(dedent(""" | ||
def test_foo(): | ||
assert True | ||
""")) | ||
|
||
proc = subprocess.Popen( | ||
["nameko", "test", testfile.strpath], stdout=subprocess.PIPE | ||
) | ||
proc.wait() | ||
assert proc.returncode == 0 | ||
|
||
|
||
def test_test_fail(tmpdir, capsys): | ||
|
||
tmpdir.join('__init__.py') | ||
testfile = tmpdir.join('test_test_fail.py') | ||
testfile.write(dedent(""" | ||
def test_foo(): | ||
assert False | ||
""")) | ||
|
||
proc = subprocess.Popen( | ||
["nameko", "test", testfile.strpath], stdout=subprocess.PIPE | ||
) | ||
proc.wait() | ||
assert proc.returncode == 1 | ||
|
||
|
||
def test_suppress_warning(tmpdir, capsys): # pragma: no cover | ||
|
||
if tuple(map(int, pytest.__version__.split("."))) < (6, 1): | ||
pytest.skip("-W flag ignored on older pytests") | ||
|
||
tmpdir.join('__init__.py') | ||
testfile = tmpdir.join('test_test_pass.py') | ||
testfile.write(dedent(""" | ||
def test_foo(): | ||
assert True | ||
""")) | ||
|
||
proc = subprocess.Popen( | ||
["nameko", "test", testfile.strpath], stdout=subprocess.PIPE | ||
) | ||
proc.wait() | ||
|
||
out = "".join(map(bytes.decode, proc.stdout.readlines())) | ||
assert "Module already imported so cannot be rewritten: nameko" not in out |