|
1 | 1 | import os
|
2 |
| -import pytest |
| 2 | +import sys |
3 | 3 | import pytest_echo
|
4 | 4 |
|
5 | 5 | pytest_plugins = "pytester",
|
@@ -29,35 +29,37 @@ def test_version():
|
29 | 29 | def test_echo_env(testdir):
|
30 | 30 | os.environ['PYTESTECHO'] = '123'
|
31 | 31 | result = testdir.runpytest('--echo-env=PYTESTECHO')
|
32 |
| - assert "PYTESTECHO: 123" in result.stdout.lines |
| 32 | + result.stdout.fnmatch_lines([ |
| 33 | + "PYTESTECHO: 123", |
| 34 | + ]) |
33 | 35 |
|
34 | 36 |
|
35 | 37 | def test_echo_version(testdir):
|
36 | 38 | result = testdir.runpytest('--echo-version=pytest_echo')
|
37 |
| - assert "pytest_echo: %s" % pytest_echo.__version__ in result.stdout.lines |
| 39 | + result.stdout.fnmatch_lines(["pytest_echo: %s" % pytest_echo.__version__]) |
38 | 40 |
|
39 | 41 |
|
40 | 42 | def test_echo_all(testdir):
|
41 | 43 | os.environ['PYTESTECHO'] = '123'
|
42 | 44 | result = testdir.runpytest('--echo-version=pytest_echo',
|
43 | 45 | '--echo-env=PYTESTECHO')
|
44 |
| - assert "PYTESTECHO: 123" in result.stdout.lines |
45 |
| - assert "pytest_echo: %s" % pytest_echo.__version__ in result.stdout.lines |
| 46 | + result.stdout.fnmatch_lines(["PYTESTECHO: 123"]) |
| 47 | + result.stdout.fnmatch_lines(["pytest_echo: %s" % pytest_echo.__version__]) |
46 | 48 |
|
47 | 49 |
|
48 | 50 | def test_echo_attr(testdir):
|
49 | 51 | result = testdir.runpytest('--echo-attr=test_echo.ATTR_INT')
|
50 |
| - assert 'test_echo.ATTR_INT: 111' in result.stdout.lines |
| 52 | + result.stdout.fnmatch_lines(['test_echo.ATTR_INT: 111']) |
51 | 53 |
|
52 | 54 |
|
53 | 55 | def test_echo_attr_dict(testdir):
|
54 | 56 | result = testdir.runpytest('--echo-attr=test_echo.ATTR_DICT.key')
|
55 |
| - assert u"test_echo.ATTR_DICT.key: 'value'" in result.stdout.lines |
| 57 | + result.stdout.fnmatch_lines(["test_echo.ATTR_DICT.key: 'value'"]) |
56 | 58 |
|
57 | 59 |
|
58 | 60 | def test_echo_attr_list(testdir):
|
59 | 61 | result = testdir.runpytest('--echo-attr=test_echo.ATTR_LIST.2')
|
60 |
| - assert u"test_echo.ATTR_LIST.2: 13" in result.stdout.lines |
| 62 | + result.stdout.fnmatch_lines([u"test_echo.ATTR_LIST.2: 13"]) |
61 | 63 |
|
62 | 64 |
|
63 | 65 | def test_echo_attr_list_inner(testdir):
|
@@ -88,13 +90,16 @@ def test_echo_attr_object_attr(testdir):
|
88 | 90 |
|
89 | 91 | def test_echo_attr_module_object_attr(testdir):
|
90 | 92 | result = testdir.runpytest('--echo-attr=linecache.cache.__class__')
|
91 |
| - result.stdout.fnmatch_lines([ |
92 |
| - "linecache.cache.__class__: <type 'dict'>", |
93 |
| - ]) |
| 93 | + if sys.version_info[0] == 2: |
| 94 | + match = "linecache.cache.__class__: <type 'dict'>" |
| 95 | + elif sys.version_info[0] == 3: |
| 96 | + match = "linecache.cache.__class__: <class 'dict'>" |
| 97 | + |
| 98 | + result.stdout.fnmatch_lines([match]) |
94 | 99 |
|
95 | 100 |
|
96 | 101 | def test_django_settings(testdir):
|
97 |
| - p = testdir.makeconftest(""" |
| 102 | + testdir.makeconftest(""" |
98 | 103 | def pytest_configure(config):
|
99 | 104 | import django
|
100 | 105 | from django.conf import settings # noqa
|
|
0 commit comments