~crunch.io/ubuntu/precise/codespeak-lib/unstable

« back to all changes in this revision

Viewing changes to testing/log/test_warning.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-08-01 16:24:01 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20100801162401-g37v49d1p148alpm
Tags: 1.3.3-1
* New upstream release.
* Bump Standards-Version to 3.9.1.
* Fix typo in py.test manpage.
* Prefer Breaks: over Conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
def test_forwarding_to_warnings_module():
5
5
    py.test.deprecated_call(py.log._apiwarn, "1.3", "..")
6
6
 
7
 
def test_apiwarn_functional():
 
7
def test_apiwarn_functional(recwarn):
8
8
    capture = py.io.StdCapture()
9
9
    py.log._apiwarn("x.y.z", "something", stacklevel=1)
10
10
    out, err = capture.reset()
15
15
    exp = "%s:%s" % (mypath, lno)
16
16
    assert err.find(exp) != -1
17
17
 
18
 
def test_stacklevel():
 
18
def test_stacklevel(recwarn):
19
19
    def f():
20
20
        py.log._apiwarn("x", "some", stacklevel=2)
21
21
    # 3
27
27
    warning = str(err)
28
28
    assert warning.find(":%s" % lno) != -1
29
29
 
30
 
def test_stacklevel_initpkg_with_resolve(testdir):
 
30
def test_stacklevel_initpkg_with_resolve(testdir, recwarn):
31
31
    testdir.makepyfile(modabc="""
32
32
        import py
33
33
        def f():
49
49
    loc = 'test_stacklevel_initpkg_with_resolve.py:2'
50
50
    assert warning.find(loc) != -1
51
51
 
52
 
def test_stacklevel_initpkg_no_resolve():
 
52
def test_stacklevel_initpkg_no_resolve(recwarn):
53
53
    def f():
54
54
        py.log._apiwarn("x", "some", stacklevel="apipkg")
55
55
    capture = py.io.StdCapture()
60
60
    assert warning.find(":%s" % lno) != -1
61
61
 
62
62
 
63
 
def test_function():
 
63
def test_function(recwarn):
64
64
    capture = py.io.StdCapture()
65
65
    py.log._apiwarn("x.y.z", "something", function=test_function)
66
66
    out, err = capture.reset()
67
67
    py.builtin.print_("out", out)
68
68
    py.builtin.print_("err", err)
69
69
    assert err.find("x.y.z") != -1
70
 
    lno = py.code.getrawcode(test_function).co_firstlineno 
 
70
    lno = py.code.getrawcode(test_function).co_firstlineno
71
71
    exp = "%s:%s" % (mypath, lno)
72
72
    assert err.find(exp) != -1
73
73