Exemplo n.º 1
0
    def testIndent(self):
        self.indent_writer << 'indent 0'
        self.assertEquals(0, self.indent_writer.indent_level)

        def indent1():
            self.indent_writer << 'indent 1'
            self.assertEquals(1, self.indent_writer.indent_level)

            def indent2():
                self.indent_writer << 'indent 2'
                self.assertEquals(2, self.indent_writer.indent_level)

            test_util.do_with(self.indent_writer.indent(), indent2)

            self.assertEquals(1, self.indent_writer.indent_level)
            self.indent_writer << 'end 2'

        test_util.do_with(self.indent_writer.indent(), indent1)

        self.assertEquals(0, self.indent_writer.indent_level)
        self.indent_writer << 'end 1'

        self.assertEquals(
            'indent 0\n'
            '  indent 1\n'
            '    indent 2\n'
            '  end 2\n'
            'end 1\n', self.out.getvalue())
Exemplo n.º 2
0
  def testIndent(self):
    self.indent_writer << 'indent 0'
    self.assertEquals(0, self.indent_writer.indent_level)

    def indent1():
      self.indent_writer << 'indent 1'
      self.assertEquals(1, self.indent_writer.indent_level)

      def indent2():
        self.indent_writer << 'indent 2'
        self.assertEquals(2, self.indent_writer.indent_level)
      test_util.do_with(self.indent_writer.indent(), indent2)

      self.assertEquals(1, self.indent_writer.indent_level)
      self.indent_writer << 'end 2'
    test_util.do_with(self.indent_writer.indent(), indent1)

    self.assertEquals(0, self.indent_writer.indent_level)
    self.indent_writer << 'end 1'

    self.assertEquals('indent 0\n'
                      '  indent 1\n'
                      '    indent 2\n'
                      '  end 2\n'
                      'end 1\n',
                      self.out.getvalue())
Exemplo n.º 3
0
    def indent1():
      self.indent_writer << 'indent 1'
      self.assertEquals(1, self.indent_writer.indent_level)

      def indent2():
        self.indent_writer << 'indent 2'
        self.assertEquals(2, self.indent_writer.indent_level)
      test_util.do_with(self.indent_writer.indent(), indent2)

      self.assertEquals(1, self.indent_writer.indent_level)
      self.indent_writer << 'end 2'
Exemplo n.º 4
0
    def indent1():
      self.indent_writer << 'indent 1'
      self.assertEquals(1, self.indent_writer.indent_level)

      def indent2():
        self.indent_writer << 'indent 2'
        self.assertEquals(2, self.indent_writer.indent_level)
      test_util.do_with(self.indent_writer.indent(), indent2)

      self.assertEquals(1, self.indent_writer.indent_level)
      self.indent_writer << 'end 2'