diff options
author | Anthony Sottile <asottile@umich.edu> | 2018-08-23 09:06:17 -0700 |
---|---|---|
committer | Anthony Sottile <asottile@umich.edu> | 2018-08-23 09:06:17 -0700 |
commit | 85482d575e6a868c829fe6f9b9d9fe3a6cab4a53 (patch) | |
tree | 54dd3579c46e42cd8f80ca6159efc904c14f516e /testing/test_cacheprovider.py | |
parent | 6f7365509dbf3f734c160e9fe94dfc99f6b0f6fd (diff) | |
download | pytest-85482d575e6a868c829fe6f9b9d9fe3a6cab4a53.tar.gz |
Replace Source with dedent where possible
Diffstat (limited to 'testing/test_cacheprovider.py')
-rw-r--r-- | testing/test_cacheprovider.py | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/testing/test_cacheprovider.py b/testing/test_cacheprovider.py index 7ec73ec63..cfeb4a0cf 100644 --- a/testing/test_cacheprovider.py +++ b/testing/test_cacheprovider.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, division, print_function import sys +import textwrap import py -import _pytest import pytest import os import shutil @@ -224,17 +224,17 @@ class TestLastFailed(object): result = testdir.runpytest() result.stdout.fnmatch_lines(["*2 failed*"]) p.write( - _pytest._code.Source( - """ - def test_1(): - assert 1 + textwrap.dedent( + """\ + def test_1(): + assert 1 - def test_2(): - assert 1 + def test_2(): + assert 1 - def test_3(): - assert 0 - """ + def test_3(): + assert 0 + """ ) ) result = testdir.runpytest("--lf") @@ -252,19 +252,19 @@ class TestLastFailed(object): def test_failedfirst_order(self, testdir): testdir.tmpdir.join("test_a.py").write( - _pytest._code.Source( + textwrap.dedent( + """\ + def test_always_passes(): + assert 1 """ - def test_always_passes(): - assert 1 - """ ) ) testdir.tmpdir.join("test_b.py").write( - _pytest._code.Source( + textwrap.dedent( + """\ + def test_always_fails(): + assert 0 """ - def test_always_fails(): - assert 0 - """ ) ) result = testdir.runpytest() @@ -277,14 +277,14 @@ class TestLastFailed(object): def test_lastfailed_failedfirst_order(self, testdir): testdir.makepyfile( **{ - "test_a.py": """ + "test_a.py": """\ def test_always_passes(): assert 1 - """, - "test_b.py": """ + """, + "test_b.py": """\ def test_always_fails(): assert 0 - """, + """, } ) result = testdir.runpytest() @@ -298,16 +298,16 @@ class TestLastFailed(object): def test_lastfailed_difference_invocations(self, testdir, monkeypatch): monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1) testdir.makepyfile( - test_a=""" + test_a="""\ def test_a1(): assert 0 def test_a2(): assert 1 - """, - test_b=""" + """, + test_b="""\ def test_b1(): assert 0 - """, + """, ) p = testdir.tmpdir.join("test_a.py") p2 = testdir.tmpdir.join("test_b.py") @@ -317,11 +317,11 @@ class TestLastFailed(object): result = testdir.runpytest("--lf", p2) result.stdout.fnmatch_lines(["*1 failed*"]) p2.write( - _pytest._code.Source( + textwrap.dedent( + """\ + def test_b1(): + assert 1 """ - def test_b1(): - assert 1 - """ ) ) result = testdir.runpytest("--lf", p2) @@ -332,18 +332,18 @@ class TestLastFailed(object): def test_lastfailed_usecase_splice(self, testdir, monkeypatch): monkeypatch.setenv("PYTHONDONTWRITEBYTECODE", 1) testdir.makepyfile( - """ + """\ def test_1(): assert 0 - """ + """ ) p2 = testdir.tmpdir.join("test_something.py") p2.write( - _pytest._code.Source( + textwrap.dedent( + """\ + def test_2(): + assert 0 """ - def test_2(): - assert 0 - """ ) ) result = testdir.runpytest() |