File: setupdata.py

package info (click to toggle)
codespeak-lib 0.9.1-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,212 kB
  • ctags: 5,409
  • sloc: python: 33,390; ansic: 961; xml: 582; makefile: 90
file content (100 lines) | stat: -rw-r--r-- 2,341 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import py

def setup_module(mod):
    mod.datadir = setupdatadir()
    mod.tmpdir = py.test.ensuretemp(mod.__name__) 

def setupdatadir():
    datadir = py.test.ensuretemp("datadir")
    names = [x.basename for x in datadir.listdir()]
    for name, content in namecontent:
        if name not in names:
            datadir.join(name).write(content)
    return datadir

namecontent = [
('syntax_error.py', "this is really not python\n"),

('disabled_module.py', py.code.Source('''
        disabled = True

        def setup_module(mod):
            raise ValueError

        class TestClassOne:
            def test_func(self):
                raise ValueError

        class TestClassTwo:
            def setup_class(cls):
                raise ValueError
            def test_func(self):
                raise ValueError
''')),

('brokenrepr.py', py.code.Source('''

    import py

    class BrokenRepr1:
        """A broken class with lots of broken methods. Let's try to make the test framework 
        immune to these."""
        foo=0
        def __repr__(self):
            raise Exception("Ha Ha fooled you, I'm a broken repr().")

    class BrokenRepr2:
        """A broken class with lots of broken methods. Let's try to make the test framework 
        immune to these."""
        foo=0
        def __repr__(self):
            raise "Ha Ha fooled you, I'm a broken repr()."

        
    class TestBrokenClass:

        def test_explicit_bad_repr(self):
            t = BrokenRepr1()
            py.test.raises(Exception, 'repr(t)')
            
        def test_implicit_bad_repr1(self):
            t = BrokenRepr1()
            assert t.foo == 1

        def test_implicit_bad_repr2(self):
            t = BrokenRepr2()
            assert t.foo == 1
    ''')),

    ('failingimport.py', py.code.Source('''

     import gruetzelmuetzel

    ''')),

    ('filetest.py', py.code.Source('''
        def test_one(): 
            assert 42 == 43

        class TestClass(object): 
            def test_method_one(self): 
                assert 42 == 43 

    ''')),

    ('testspecial_importerror.py', py.code.Source('''

        import asdasd

    ''')),

    ('disabled.py', py.code.Source('''
        class TestDisabled:
            disabled = True
            def test_method(self): 
                pass
    ''')),
]