File: multiple_topic_vows.py

package info (click to toggle)
pyvows 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 500 kB
  • sloc: python: 3,884; makefile: 19; sh: 8
file content (44 lines) | stat: -rw-r--r-- 1,198 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# pyvows testing engine
# https://github.com/heynemann/pyvows

# Licensed under the MIT license:
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 Bernardo Heynemann heynemann@gmail.com

from pyvows import Vows, expect


@Vows.batch
class MultipleTopics(Vows.Context):
    class FirstLevel(Vows.Context):
        def topic(self):
            return 'a'

        def is_a(self, topic):
            expect(topic).to_equal('a')

        class SecondLevel(Vows.Context):
            def topic(self, first):
                return (first, 'b')

            def still_a(self, topic):
                expect(topic[0]).to_equal('a')

            def is_b(self, topic):
                expect(topic[1]).to_equal('b')

            class ThirdLevel(Vows.Context):
                def topic(self, second, first):
                    return (first, second[1], 'c')

                def still_a(self, topic):
                    expect(topic[0]).to_equal('a')

                def still_b(self, topic):
                    expect(topic[1]).to_equal('b')

                def is_c(self, topic):
                    expect(topic[2]).to_equal('c')