PSPUtilsTest.py :  » Web-Frameworks » Webware » Webware-1.0.2 » PSP » Tests » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Frameworks » Webware 
Webware » Webware 1.0.2 » PSP » Tests » PSPUtilsTest.py
"""
  Automated tests for PSPUtils

  (c) Copyright by Winston Wolff, 2004 http://www.stratolab.com

  Permission to use, copy, modify, and distribute this software and its
  documentation for any purpose and without fee or royalty is hereby granted,
  provided that the above copyright notice appear in all copies and that
  both that copyright notice and this permission notice appear in
  supporting documentation or portions thereof, including modifications,
  that you make.

  THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO
  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
  INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  WITH THE USE OR PERFORMANCE OF THIS SOFTWARE !

"""

import unittest
from PSP import PSPUtils

if 0:
  import doctest

  def suite():
    """Combine our unittest with our doctests."""
    result = unittest.TestSuite()
    result.addTest(doctest.DocTestSuite(PSPUtils))
    result.addTest(unittest.defaultTestLoader.loadTestsFromTestCase(PSPUtilsTest))
    return result


class PSPUtilsTest(unittest.TestCase):

  def testNormalizeIndentation(self):

    before = """
            def add(a,b):
              return a+b"""
    expected = \
"""
def add(a,b):
  return a+b"""

    self.assertEquals(PSPUtils.normalizeIndentation(before), expected)

    # Comments should be ignored for the unindentation
    before = """
# Will comments throw off the indentation?
            def add(a,b):
              return a+b"""
    expected = \
"""
# Will comments throw off the indentation?
def add(a,b):
  return a+b"""

    self.assertEquals(PSPUtils.normalizeIndentation(before), expected)

    # Will blank lines cause a problem?
    before = """
# Will blank lines cause a problem?

            def add(a,b):

              return a+b"""
    expected = \
"""
# Will blank lines cause a problem?

def add(a,b):

  return a+b"""

    self.assertEquals(PSPUtils.normalizeIndentation(before), expected)

    # Different line endings OK?
    before = '#line endings\r  def add(a,b):\r  \r  return a+b'
    expected = '#line endings\rdef add(a,b):\r\rreturn a+b'

    self.assertEquals(PSPUtils.normalizeIndentation(before), expected)

  def testSplitLines(self):

    text = 'one\rtwo\rthree'
    self.assertEquals(3, len(PSPUtils.splitLines(text)))

    text = 'one\ntwo\nthree'
    self.assertEquals(3, len(PSPUtils.splitLines(text)))

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.